diff options
| author | Robert | 2017-10-26 09:47:03 +0200 |
|---|---|---|
| committer | Xinhui | 2017-11-03 12:26:41 +0100 |
| commit | 1b2176d73336fce7baa57d2b6a017f0e2653cd43 (patch) | |
| tree | 10afc7151c51dd1380b6a7d80919e8f2f7e427dd | |
| parent | 13a42deb92b149811214ed2c7ecc3007c0436ae2 (diff) | |
| download | chouette-core-1b2176d73336fce7baa57d2b6a017f0e2653cd43.tar.bz2 | |
Refs: #4774@1h; Structure of filter views scaffolded
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 1 | ||||
| -rw-r--r-- | app/views/compliance_control_sets/show.html.slim | 89 | ||||
| -rw-r--r-- | app/views/compliance_controls/_filters.html.slim | 24 |
3 files changed, 75 insertions, 39 deletions
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 0c9f3067a..1d6f88068 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- class StopAreasController < InheritedResources::Base include ApplicationHelper diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim index 28d602eb5..621c188e4 100644 --- a/app/views/compliance_control_sets/show.html.slim +++ b/app/views/compliance_control_sets/show.html.slim @@ -28,10 +28,17 @@ .col-lg-12 h2 = transport_mode("", "") + - direct_controls = @compliance_controls.delete nil + - if params[:q].present? or direct_controls.any? + .row + .col-lg-12 + = render '/compliance_controls/filter', controls: direct_controls + + - if direct_controls.any? .row .col-lg-12 .select_table - = table_builder_2 @compliance_controls.delete(nil), + = table_builder_2 direct_controls, [ \ TableBuilderHelper::Column.new( \ key: :code, \ @@ -58,45 +65,51 @@ model: ComplianceControl - @compliance_controls.each do |block, compliance_controls| - .row - .col-lg-12 - h2 - = transport_mode(block.transport_mode, block.transport_submode) - .btn-group - .btn.dropdown-toggle{ data-toggle="dropdown" } - .span.fa.fa-cog - ul.dropdown-menu - li - = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) - = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')} + - if params[:q].present? or compliance_controls.any? + .row + .col-lg-12 + = render '/compliance_controls/filter', controls: compliance_controls + + - if compliance_controls.any? .row .col-lg-12 - .select_table - = table_builder_2 compliance_controls, - [ \ - TableBuilderHelper::Column.new( \ - key: :code, \ - attribute: 'code' \ - ), \ - TableBuilderHelper::Column.new( \ - key: :name, \ - attribute: 'name', \ - link_to: lambda do |compliance_control| \ - compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \ - end \ - ), \ - TableBuilderHelper::Column.new( \ - key: :criticity, \ - attribute: 'criticity' \ - ), \ - TableBuilderHelper::Column.new( \ - key: :comment, \ - attribute: 'comment' \ - ), \ - ], - sortable: true, - cls: 'table has-filter has-search', - model: ComplianceControl + h2 + = transport_mode(block.transport_mode, block.transport_submode) + .btn-group + .btn.dropdown-toggle{ data-toggle="dropdown" } + .span.fa.fa-cog + ul.dropdown-menu + li + = link_to t('compliance_control_sets.actions.edit'), edit_compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id) + = link_to t('compliance_control_sets.actions.destroy'), compliance_control_set_compliance_control_block_path(@compliance_control_set.id, block.id), :method => :delete, :data => {:confirm => t('compliance_control_sets.actions.destroy_confirm')} + .row + .col-lg-12 + .select_table + = table_builder_2 compliance_controls, + [ \ + TableBuilderHelper::Column.new( \ + key: :code, \ + attribute: 'code' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name', \ + link_to: lambda do |compliance_control| \ + compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \ + end \ + ), \ + TableBuilderHelper::Column.new( \ + key: :criticity, \ + attribute: 'criticity' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :comment, \ + attribute: 'comment' \ + ), \ + ], + sortable: true, + cls: 'table has-filter has-search', + model: ComplianceControl .select_toolbox ul li.st_action.with_text diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim new file mode 100644 index 000000000..1a54a4ccc --- /dev/null +++ b/app/views/compliance_controls/_filters.html.slim @@ -0,0 +1,24 @@ += search_form_for q_for_form, url: compliance_control_set_compliance_controls_path, builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f| +// Rewriting the ransack filter copied from cc_stes/_filter + + .ffg-row + .input-group.search_bar + = f.search_field :name_cont, class: 'form-control', placeholder: t('compliance_control_sets.filters.name') + span.input-group-btn + button.btn.btn-default type='submit' + span.fa.fa-search + .ffg-row + .form-group.togglable + = f.label t('activerecord.models.organisation.one'), required: false, class: 'control-label' + = f.input :organisation_name_eq_any, collection: organisations_filters_values, as: :check_boxes, label: false, label_method: lambda {|w| ("<span>#{w.name}</span>").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'} + + .form-group.togglable + = f.label Import.human_attribute_name(:updated_at), required: false, class: 'control-label' + .filter_menu + = f.simple_fields_for :updated_at do |p| + = p.input :start_date, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @begin_range, include_blank: @begin_range ? false : true + = p.input :end_date, as: :date, label: false, wrapper_html: {class: 'date smart_date filter_menu-item'}, default: @end_range, include_blank: @end_range ? false : true + + .actions + = link_to t('actions.erase'), @compliance_control_set, class: 'btn btn-link' + = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_control_set_filter_btn' |
