diff options
| author | cedricnjanga | 2017-07-31 17:32:18 +0200 | 
|---|---|---|
| committer | cedricnjanga | 2017-07-31 17:44:01 +0200 | 
| commit | 6291e883bc30ccdeaf37338febea9a640467f5d7 (patch) | |
| tree | ce43ea1290c0bcc44f971bebadbb0596c2b7eaa6 | |
| parent | a513676379ed3fe4c3b2ad01afbd1aba7316f47b (diff) | |
| download | chouette-core-6291e883bc30ccdeaf37338febea9a640467f5d7.tar.bz2 | |
Refs #4005 Period filters for time_table and referentials
| -rw-r--r-- | app/assets/javascripts/time_table.coffee | 14 | ||||
| -rw-r--r-- | app/assets/javascripts/workbench.coffee | 14 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 1 | ||||
| -rw-r--r-- | app/views/time_tables/_filter.html.slim | 2 | ||||
| -rw-r--r-- | app/views/time_tables/index.html.slim | 3 | ||||
| -rw-r--r-- | app/views/workbenches/_filters.html.slim | 2 | ||||
| -rw-r--r-- | app/views/workbenches/show.html.slim | 3 | ||||
| -rw-r--r-- | config/locales/referentials.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/referentials.fr.yml | 1 | ||||
| -rw-r--r-- | config/locales/time_tables.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/time_tables.fr.yml | 1 | 
11 files changed, 40 insertions, 3 deletions
| diff --git a/app/assets/javascripts/time_table.coffee b/app/assets/javascripts/time_table.coffee new file mode 100644 index 000000000..8789cb226 --- /dev/null +++ b/app/assets/javascripts/time_table.coffee @@ -0,0 +1,14 @@ + $(document).on("click", "#time_table_filter_btn", (e) -> +   dates = [1, 2, 3].reduce (arr, key) -> +     arr.push $("#q_start_date_gteq_#{key}i").val(), $("#q_end_date_lteq_#{key}i").val() +     arr +   , [] + +   validDate = dates.every (date) -> !!date + +   noDate = dates.every (date) -> !date + +   unless (validDate || noDate) +     e.preventDefault() +     alert(window.I18n.fr.time_tables.error_period_filter) + ) diff --git a/app/assets/javascripts/workbench.coffee b/app/assets/javascripts/workbench.coffee new file mode 100644 index 000000000..971462e98 --- /dev/null +++ b/app/assets/javascripts/workbench.coffee @@ -0,0 +1,14 @@ + $(document).on("click", "#referential_filter_btn", (e) -> +   dates = [1, 2, 3].reduce (arr, key) -> +     arr.push $("#q_validity_period_begin_gteq_#{key}i").val(), $("#q_validity_period_end_gteq__#{key}i").val() +     arr +   , [] + +   validDate = dates.every (date) -> !!date + +   noDate = dates.every (date) -> !date + +   unless (validDate || noDate) +     e.preventDefault() +     alert(window.I18n.fr.referentials.error_period_filter) + ) diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 0054963c9..2ff7a2c3a 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -161,7 +161,6 @@ class TimeTablesController < ChouetteController    private    def ransack_periode scope      return scope unless params[:q] -    return scope unless params[:q]['end_date_lteq(1i)'].present?      begin_range = flatten_date('start_date_gteq')      end_range   = flatten_date('end_date_lteq') diff --git a/app/views/time_tables/_filter.html.slim b/app/views/time_tables/_filter.html.slim index 392dc4f50..043aa87d0 100644 --- a/app/views/time_tables/_filter.html.slim +++ b/app/views/time_tables/_filter.html.slim @@ -20,4 +20,4 @@    .actions      = link_to 'Effacer', @workbench, class: 'btn btn-link' -    = f.submit 'Filtrer', class: 'btn btn-default' +    = f.submit 'Filtrer', class: 'btn btn-default', id: 'time_table_filter_btn' diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim index 72c025bc1..5ee854c58 100644 --- a/app/views/time_tables/index.html.slim +++ b/app/views/time_tables/index.html.slim @@ -62,3 +62,6 @@        .row.mt-xs          .col-lg-12            = replacement_msg t('time_tables.search_no_results') + += javascript_tag do +  | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe}; diff --git a/app/views/workbenches/_filters.html.slim b/app/views/workbenches/_filters.html.slim index 8da7ecf51..8da629e9c 100644 --- a/app/views/workbenches/_filters.html.slim +++ b/app/views/workbenches/_filters.html.slim @@ -30,4 +30,4 @@    .actions      = link_to t('actions.erase'), @workbench, class: 'btn btn-link' -    = f.submit t('actions.filter'), class: 'btn btn-default' +    = f.submit t('actions.filter'), class: 'btn btn-default', id: 'referential_filter_btn' diff --git a/app/views/workbenches/show.html.slim b/app/views/workbenches/show.html.slim index 6a41ca569..2f845ed96 100644 --- a/app/views/workbenches/show.html.slim +++ b/app/views/workbenches/show.html.slim @@ -71,3 +71,6 @@        .row.mt-xs          .col-lg-12            = replacement_msg t('referentials.search_no_results') + += javascript_tag do +  | window.I18n = #{(I18n.backend.send(:translations).to_json).html_safe}; diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index e29df7cf4..9ae6bfe35 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -5,6 +5,7 @@ en:        name: 'Search by name'        line: 'Seach by associated lines'      search_no_results: 'No data space matching your query' +    error_period_filter: "The period filter must have valid bounding dates"      index:        title: 'Data spaces'      edit: diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index 643295c0e..a201ccadd 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -5,6 +5,7 @@ fr:        name: 'Indiquez un nom de référentiel...'        line: 'Indiquez une ligne...'      search_no_results: 'Aucun jeu de données ne correspond à votre recherche' +    error_period_filter: "Le filtre par période doit contenir une date de début et de fin valides"      index:        title: 'Jeux de données'      edit: diff --git a/config/locales/time_tables.en.yml b/config/locales/time_tables.en.yml index 24750f0af..ed2f9758e 100644 --- a/config/locales/time_tables.en.yml +++ b/config/locales/time_tables.en.yml @@ -2,6 +2,7 @@ en:    time_tables:      duplicate_success: "duplication succeded"      search_no_results: 'No calendar matching your query' +    error_period_filter: "The period filter must have valid bounding dates"      time_table:        empty: "empty"        bounding: "from %{start} to %{end}" diff --git a/config/locales/time_tables.fr.yml b/config/locales/time_tables.fr.yml index 886aaa263..cf6888d0f 100644 --- a/config/locales/time_tables.fr.yml +++ b/config/locales/time_tables.fr.yml @@ -2,6 +2,7 @@ fr:    time_tables:      duplicate_success: "duplication terminée"      search_no_results: 'Aucun calendrier ne correspond à votre recherche' +    error_period_filter: "Le filtre par période doit contenir une date de début et de fin valides"      time_table:        empty: "vide"        bounding: "du %{start} au %{end}" | 
