aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/lines_controller.rb20
-rw-r--r--app/helpers/referentials_helper.rb6
-rw-r--r--app/views/lines/_filters.html.slim20
-rw-r--r--app/views/lines/index.html.slim4
4 files changed, 44 insertions, 6 deletions
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index 27a9bf9be..6b002e4f6 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -89,7 +89,9 @@ class LinesController < ChouetteController
params[:q]["#{filter}_blank"] = '1'
end
end
- @q = line_referential.lines.search(params[:q])
+
+ scope = ransack_status line_referential.lines
+ @q = scope.search(params[:q])
if sort_column && sort_direction
@lines ||= @q.result(:distinct => true).order(sort_column + ' ' + sort_direction).paginate(:page => params[:page]).includes([:network, :company])
@@ -145,4 +147,20 @@ class LinesController < ChouetteController
)
end
+ # Fake ransack filter
+ def ransack_status scope
+ return scope unless params[:q].try(:[], :status)
+ return scope if params[:q][:status].values.uniq.length == 1
+
+ @status = {
+ activated: params[:q][:status]['activated'] == 'true',
+ deactivated: params[:q][:status]['deactivated'] == 'true',
+ }
+
+ scope = Chouette::Line.where(deactivated: @status[@status.key(true)])
+
+ params[:q].delete :status
+ scope
+end
+
end
diff --git a/app/helpers/referentials_helper.rb b/app/helpers/referentials_helper.rb
index e464ec8a5..9c3852322 100644
--- a/app/helpers/referentials_helper.rb
+++ b/app/helpers/referentials_helper.rb
@@ -2,12 +2,12 @@ module ReferentialsHelper
# Outputs a green check icon and the text "Oui" or a red exclamation mark
# icon and the text "Non" based on `status`
def line_status(status)
- if status
+ if status
content_tag(:span, nil, class: 'fa fa-exclamation-circle fa-lg text-danger') +
- t('false')
+ t('activerecord.attributes.line.deactivated')
else
content_tag(:span, nil, class: 'fa fa-check-circle fa-lg text-success') +
- t('true')
+ t('activerecord.attributes.line.activated')
end
end
diff --git a/app/views/lines/_filters.html.slim b/app/views/lines/_filters.html.slim
index 67ba297cf..c221a02a1 100644
--- a/app/views/lines/_filters.html.slim
+++ b/app/views/lines/_filters.html.slim
@@ -23,6 +23,26 @@
= f.label Chouette::Line.human_attribute_name(:transport_submode), required: false, class: 'control-label'
= f.input :transport_submode_eq_any, collection: StifTransportSubmodeEnumerations.sorted_transport_submodes, as: :check_boxes, label: false, label_method: lambda{|l| ("<span>" + t("enumerize.transport_submode.#{l}") + "</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list'}
+ .form-group.togglable class=filter_item_class(params[:q], :status)
+ = f.label Chouette::Line.human_attribute_name(:state), required: false, class: 'control-label'
+ .form-group.checkbox_list
+ = f.simple_fields_for :status do |p|
+ = p.input :activated,
+ label: ("<span>#{t('activerecord.attributes.line.activated')}<span class='fa fa-check-circle text-success'></span></span>").html_safe,
+ as: :boolean,
+ wrapper_html: { class: 'checkbox-wrapper' },
+ checked_value: true,
+ unchecked_value: false,
+ input_html: { checked: @status.try(:[], :confirmed) }
+ = p.input :deactivated,
+ label: ("<span>#{t('activerecord.attributes.line.deactivated')}<span class='fa fa-exclamation-circle text-danger'></span></span>").html_safe,
+ as: :boolean,
+ wrapper_html: { class: 'checkbox-wrapper' },
+ checked_value: true,
+ unchecked_value: false,
+ input_html: { checked: @status.try(:[], :deactivated) }
+
+
.actions
= link_to 'Effacer', @workbench, class: 'btn btn-link'
= f.submit 'Filtrer', class: 'btn btn-default'
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim
index 2d64e5f73..e77518d57 100644
--- a/app/views/lines/index.html.slim
+++ b/app/views/lines/index.html.slim
@@ -29,8 +29,8 @@
end \
), \
TableBuilderHelper::Column.new( \
- key: :deactivated, \
- attribute: Proc.new { |n| line_status(n.deactivated?) } \
+ name: t('activerecord.attributes.line.state'), \
+ attribute: Proc.new { |n| line_status(n.deactivated) } \
), \
TableBuilderHelper::Column.new( \
key: 'networks.name', \