diff options
| author | af83 | 2017-07-06 12:18:31 +0200 |
|---|---|---|
| committer | af83 | 2017-07-06 12:18:31 +0200 |
| commit | a78db962d1f25f569ff3e8294cd565137ede92d3 (patch) | |
| tree | a310f54f17077b7939365740fa694026cf839e9e /app | |
| parent | ebd292c7a6abaab5aeb90b37e34e21253184979f (diff) | |
| download | chouette-core-a78db962d1f25f569ff3e8294cd565137ede92d3.tar.bz2 | |
Change wording for clean up + add exclusive dates for between clean up
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/javascripts/cleanup.coffee | 11 | ||||
| -rw-r--r-- | app/models/clean_up.rb | 10 | ||||
| -rw-r--r-- | app/views/referentials/show.html.slim | 2 |
3 files changed, 14 insertions, 9 deletions
diff --git a/app/assets/javascripts/cleanup.coffee b/app/assets/javascripts/cleanup.coffee index 169a006a9..7f6594018 100644 --- a/app/assets/javascripts/cleanup.coffee +++ b/app/assets/javascripts/cleanup.coffee @@ -2,8 +2,13 @@ $(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 + if type == 'before' + end_date.hide() + $("label[for='clean_up_begin_date_3i']").html("Date de fin de purge"); + else if type == 'after' end_date.hide() + $("label[for='clean_up_begin_date_3i']").html("Date de début de purge"); + else + $("label[for='clean_up_begin_date_3i']").html("Date de début de purge"); + end_date.show() ) diff --git a/app/models/clean_up.rb b/app/models/clean_up.rb index cbcde72f5..75fedc732 100644 --- a/app/models/clean_up.rb +++ b/app/models/clean_up.rb @@ -6,8 +6,8 @@ class CleanUp < ActiveRecord::Base enumerize :date_type, in: %i(between before after) - validates :begin_date, presence: true - validates :date_type, presence: true + validates_presence_of :begin_date, message: :presence + validates_presence_of :date_type, message: :presence after_commit :perform_cleanup, :on => :create def perform_cleanup @@ -30,7 +30,7 @@ class CleanUp < ActiveRecord::Base end def destroy_time_tables_between - time_tables = Chouette::TimeTable.where('end_date <= ? AND start_date >= ?', self.end_date, self.begin_date) + time_tables = Chouette::TimeTable.where('end_date < ? AND start_date > ?', self.end_date, self.begin_date) self.destroy_time_tables(time_tables) end @@ -53,7 +53,7 @@ class CleanUp < ActiveRecord::Base end def destroy_time_tables_dates_between - Chouette::TimeTableDate.in_dates.where('date >= ? AND date <= ?', self.begin_date, self.end_date).destroy_all + Chouette::TimeTableDate.in_dates.where('date > ? AND date < ?', self.begin_date, self.end_date).destroy_all end def destroy_time_tables_periods_before @@ -65,7 +65,7 @@ class CleanUp < ActiveRecord::Base end def destroy_time_tables_periods_between - Chouette::TimeTablePeriod.where('period_start >= ? AND period_end <= ?', self.begin_date, self.end_date).destroy_all + Chouette::TimeTablePeriod.where('period_start > ? AND period_end < ?', self.begin_date, self.end_date).destroy_all end def overlapping_periods diff --git a/app/views/referentials/show.html.slim b/app/views/referentials/show.html.slim index 81cd0ebfd..17ba8ad88 100644 --- a/app/views/referentials/show.html.slim +++ b/app/views/referentials/show.html.slim @@ -70,7 +70,7 @@ = 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 smart_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 cleanup_end_date_wrapper hidden smert_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 smart_date', title: t('titles.clean_up.end_date'), id: "end_date" } .modal-footer button.btn.btn-link type='button' data-dismiss='modal' Annuler |
