aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/time_tables_controller.rb19
-rw-r--r--app/helpers/newapplication_helper.rb2
-rw-r--r--app/views/time_tables/_filter.html.slim4
-rw-r--r--app/views/time_tables/index.html.slim2
4 files changed, 23 insertions, 4 deletions
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index eedfef07c..b23345607 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -99,6 +99,7 @@ class TimeTablesController < ChouetteController
params[:q].delete("tag_search")
scope = select_time_tables.tagged_with(tags, :wild => true, :any => true) if tags.any?
end
+ scope = ransack_periode(scope)
@q = scope.search(params[:q])
if sort_column && sort_direction
@@ -126,6 +127,24 @@ class TimeTablesController < ChouetteController
end
private
+ # Fake ransack filter
+ def ransack_periode scope
+ return scope unless params[:q]
+ periode = params[:q]
+ return scope if periode['end_date_lteq(1i)'].empty? || periode['start_date_gteq(1i)'].empty?
+
+ begin_range = Date.civil(periode["start_date_gteq(1i)"].to_i, periode["start_date_gteq(2i)"].to_i, periode["start_date_gteq(3i)"].to_i)
+ end_range = Date.civil(periode["end_date_lteq(1i)"].to_i, periode["end_date_lteq(2i)"].to_i, periode["end_date_lteq(3i)"].to_i)
+
+ if begin_range > end_range
+ flash.now[:error] = t('referentials.errors.validity_period')
+ else
+ @begin_range = begin_range
+ @end_range = end_range
+ end
+ scope
+ end
+
def sort_column
referential.time_tables.column_names.include?(params[:sort]) ? params[:sort] : 'comment'
end
diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb
index 42fca489f..804f6dab4 100644
--- a/app/helpers/newapplication_helper.rb
+++ b/app/helpers/newapplication_helper.rb
@@ -16,7 +16,7 @@ module NewapplicationHelper
end
columns.map do |k, v|
- if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante"].include? k
+ if ["ID Codif", "Oid", "OiD", "ID Reflex", "Arrêt de départ", "Arrêt d'arrivée", "Période de validité englobante", "Période englobante"].include? k
hcont << content_tag(:th, k)
else
hcont << content_tag(:th, sortable_columns(collection, k))
diff --git a/app/views/time_tables/_filter.html.slim b/app/views/time_tables/_filter.html.slim
index b5d8185f0..d29c628a9 100644
--- a/app/views/time_tables/_filter.html.slim
+++ b/app/views/time_tables/_filter.html.slim
@@ -17,8 +17,8 @@
.form-group.togglable
= f.label @time_tables.human_attribute_name(:bounding_dates), required: false, class: 'control-label'
.filter_menu
- = f.input :start_date_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date filter_menu-item' }
- = f.input :end_date_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date filter_menu-item' }
+ = f.input :start_date_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date filter_menu-item' }, default: @begin_range, include_blank: @begin_range ? false : true
+ = f.input :end_date_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date filter_menu-item' }, default: @end_range, include_blank: @end_range ? false : true
.actions
diff --git a/app/views/time_tables/index.html.slim b/app/views/time_tables/index.html.slim
index 4e803e18f..5ca3c7569 100644
--- a/app/views/time_tables/index.html.slim
+++ b/app/views/time_tables/index.html.slim
@@ -16,7 +16,7 @@
.col-lg-12
= table_builder @time_tables,
{ :comment => 'comment', :color => Proc.new{|tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' },
- "Période de validité englobante" => Proc.new{ |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) }, :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} },
+ "Période englobante" => Proc.new{ |tt| tt.bounding_dates.empty? ? '-' : t('bounding_dates', debut: l(tt.bounding_dates.min), end: l(tt.bounding_dates.max)) }, :calendar => Proc.new{ |tt| tt.calendar ? tt.calendar.try(:name) : '-' }, :updated_at => Proc.new {|tt| l(tt.updated_at, format: :short)} },
[:show, :edit, :duplicate, :delete],
[],
'table has-search'