aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorcedricnjanga2017-07-31 17:32:18 +0200
committercedricnjanga2017-07-31 17:44:01 +0200
commit6291e883bc30ccdeaf37338febea9a640467f5d7 (patch)
treece43ea1290c0bcc44f971bebadbb0596c2b7eaa6 /app
parenta513676379ed3fe4c3b2ad01afbd1aba7316f47b (diff)
downloadchouette-core-6291e883bc30ccdeaf37338febea9a640467f5d7.tar.bz2
Refs #4005 Period filters for time_table and referentials
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/time_table.coffee14
-rw-r--r--app/assets/javascripts/workbench.coffee14
-rw-r--r--app/controllers/time_tables_controller.rb1
-rw-r--r--app/views/time_tables/_filter.html.slim2
-rw-r--r--app/views/time_tables/index.html.slim3
-rw-r--r--app/views/workbenches/_filters.html.slim2
-rw-r--r--app/views/workbenches/show.html.slim3
7 files changed, 36 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};