aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorXinhui2017-06-05 16:47:06 +0200
committerRobert2017-06-05 17:24:59 +0200
commit7982b2654967fc7e6517fa78da3dba7ad0e4d185 (patch)
tree8ff564194a6c6b0e790a4a787350b34875a16e9d /app
parenta992b6ca99c94e7c9703db430ddd00372ec2156a (diff)
downloadchouette-core-7982b2654967fc7e6517fa78da3dba7ad0e4d185.tar.bz2
Referential Cleanup add date_type
Refs #3662
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/cleanup.coffee9
-rw-r--r--app/controllers/clean_ups_controller.rb2
-rw-r--r--app/models/clean_up.rb4
-rw-r--r--app/views/referentials/show.html.slim4
4 files changed, 17 insertions, 2 deletions
diff --git a/app/assets/javascripts/cleanup.coffee b/app/assets/javascripts/cleanup.coffee
new file mode 100644
index 000000000..169a006a9
--- /dev/null
+++ b/app/assets/javascripts/cleanup.coffee
@@ -0,0 +1,9 @@
+$(document).on("change", 'input[name="clean_up[date_type]"]', (e) ->
+ type = $(this).val()
+ end_date = $('.cleanup_end_date_wrapper')
+
+ if type == 'between'
+ end_date.removeClass('hidden').show()
+ else
+ end_date.hide()
+)
diff --git a/app/controllers/clean_ups_controller.rb b/app/controllers/clean_ups_controller.rb
index 1e4835775..b9ff225b3 100644
--- a/app/controllers/clean_ups_controller.rb
+++ b/app/controllers/clean_ups_controller.rb
@@ -14,6 +14,6 @@ class CleanUpsController < ChouetteController
end
def clean_up_params
- params.require(:clean_up).permit(:keep_lines, :keep_stops, :keep_companies, :keep_networks, :keep_group_of_lines, :begin_date, :end_date)
+ params.require(:clean_up).permit(:date_type, :begin_date, :end_date)
end
end
diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb
index a44bb46a4..457e90b65 100644
--- a/app/models/clean_up.rb
+++ b/app/models/clean_up.rb
@@ -1,9 +1,13 @@
class CleanUp < ActiveRecord::Base
+ extend Enumerize
include AASM
belongs_to :referential
has_one :clean_up_result
+ enumerize :date_type, in: %i(between before after)
+
validates :begin_date, presence: true
+ validates :date_type, presence: true
after_commit :perform_cleanup, :on => :create
def perform_cleanup
diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim
index 9c60c2768..3c1e36302 100644
--- a/app/views/referentials/show.html.slim
+++ b/app/views/referentials/show.html.slim
@@ -75,8 +75,10 @@
.container-fluid
.row
.col-lg-8.col-ld-offset-2.col-md-8.col-md-offset-2.col-sm-8.col-sm-offset-2.col-xs-12
+ = f.input :date_type, as: :radio_buttons, label: false
= f.input :begin_date, as: :date, label: t('titles.clean_up.begin_date'),:wrapper_html => { class: 'date', title: t('titles.clean_up.begin_date') }
- = f.input :end_date, as: :date, label: t('titles.clean_up.end_date'), :wrapper_html => { class: 'date', title: t('titles.clean_up.end_date') }
+
+ = f.input :end_date, as: :date, label: t('titles.clean_up.end_date'), :wrapper_html => { class: 'date cleanup_end_date_wrapper hidden', title: t('titles.clean_up.end_date') }
.modal-footer
button.btn.btn-link type='button' data-dismiss='modal' Annuler