aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume2017-09-20 11:31:29 +0200
committerGuillaume2017-09-20 11:31:29 +0200
commit8007f0140f3fc5183e9a3d27b19fe90e4da839d2 (patch)
treea9d3558998dd61f8f1f456280ec56c5b1b786138
parent2661aed29a0078bc3984424a6a4225cefc8394f3 (diff)
downloadchouette-core-8007f0140f3fc5183e9a3d27b19fe90e4da839d2.tar.bz2
add ransack filter for compliance_control_sets collection
-rw-r--r--app/controllers/compliance_control_sets_controller.rb7
-rw-r--r--app/views/compliance_control_sets/_filters.html.slim29
-rw-r--r--app/views/compliance_control_sets/index.html.slim10
-rw-r--r--config/locales/compliance_control_sets.fr.yml5
-rw-r--r--config/routes.rb2
5 files changed, 17 insertions, 36 deletions
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 1b23becaa..6edfa3fcc 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -4,8 +4,9 @@ class ComplianceControlSetsController < BreadcrumbController
def index
index! do |format|
+ @q_for_form = @compliance_control_sets.ransack(params[:q])
format.html {
- @compliance_control_sets = decorate_compliance_control_sets(@compliance_control_sets)
+ @compliance_control_sets = decorate_compliance_control_sets(@q_for_form.result)
}
end
end
@@ -23,11 +24,9 @@ class ComplianceControlSetsController < BreadcrumbController
)
end
- protected
-
private
def compliance_control_set_params
- params.require(:compliance_control_set).permit(:name)
+ params.require(:compliance_control_set).permit(:name, :id)
end
end
diff --git a/app/views/compliance_control_sets/_filters.html.slim b/app/views/compliance_control_sets/_filters.html.slim
index 8da629e9c..7ee050636 100644
--- a/app/views/compliance_control_sets/_filters.html.slim
+++ b/app/views/compliance_control_sets/_filters.html.slim
@@ -1,33 +1,10 @@
-= search_form_for @q_for_form, url: workbench_path(@workbench.id), builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
+= search_form_for @q_for_form, url: compliance_control_sets_path, builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
.ffg-row
.input-group.search_bar
- = f.search_field :name_cont, class: 'form-control', placeholder: t('referentials.filters.name')
+ = 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
- = f.label t('activerecord.models.line.one').upcase, required: false, class: 'control-label'
- = f.input :associated_lines_id_eq, as: :select, collection: @workbench.lines.includes(:company).order(:name), input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': t('referentials.filters.line') }, label: false, label_method: :display_name, wrapper_html: { class: 'select2ed'}
-
- .form-group.togglable
- = f.label Referential.human_attribute_name(:status), required: false, class: 'control-label'
- .form-group.checkbox_list
- = f.input :archived_at_not_null, label: ("<span>#{t('activerecord.attributes.referential.archived_at')}<span class='fa fa-archive'></span></span>").html_safe, as: :boolean, wrapper_html: { class: 'checkbox-wrapper' }
- = f.input :archived_at_null, label: ("<span>#{t('activerecord.attributes.referential.archived_at_null')}<span class='sb sb-lg sb-preparing'></span></span>").html_safe, as: :boolean, wrapper_html: { class: 'checkbox-wrapper' }
-
- .form-group.togglable
- = f.label t('activerecord.models.organisation.one'), required: false, class: 'control-label'
- = f.input :organisation_name_eq_any, collection: Organisation.order('name').pluck(:name), as: :check_boxes, label: false, label_method: lambda{|w| ("<span>#{w}</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }
-
- .form-group.togglable
- = f.label Referential.human_attribute_name(:validity_period), required: false, class: 'control-label'
- .filter_menu
- = f.simple_fields_for :validity_period do |p|
- = p.input :begin_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @begin_range, include_blank: @begin_range ? false : true
- = p.input :end_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @end_range, include_blank: @end_range ? false : true
-
.actions
- = link_to t('actions.erase'), @workbench, class: 'btn btn-link'
+ = link_to t('actions.erase'), @compliance_control_set, class: 'btn btn-link'
= f.submit t('actions.filter'), class: 'btn btn-default', id: 'referential_filter_btn'
diff --git a/app/views/compliance_control_sets/index.html.slim b/app/views/compliance_control_sets/index.html.slim
index fa85c38f7..95833a01c 100644
--- a/app/views/compliance_control_sets/index.html.slim
+++ b/app/views/compliance_control_sets/index.html.slim
@@ -14,7 +14,7 @@
.container-fluid
.row
.col-lg-12
- /= render 'filters'
+ = render 'filters'
.row
.col-lg-12
.select_table
@@ -40,11 +40,15 @@
attribute: 'control_numbers' \
), \
TableBuilderHelper::Column.new( \
- key: :update, \
- attribute: '' \
+ key: :updated_at, \
+ attribute: Proc.new { |n| l(n.updated_at, format: :long) if n.updated_at }, \
) \
],
sortable: true,
cls: 'table has-filter has-search'
+ - unless @compliance_control_sets.any?
+ .row.mt-xs
+ .col-lg-12
+ = replacement_msg t('compliance_control_sets.search_no_results')
diff --git a/config/locales/compliance_control_sets.fr.yml b/config/locales/compliance_control_sets.fr.yml
index c230d593c..fedfeede7 100644
--- a/config/locales/compliance_control_sets.fr.yml
+++ b/config/locales/compliance_control_sets.fr.yml
@@ -9,6 +9,9 @@ fr:
edit: Editer
destroy: Supprimer
destroy_confirm: Etes vous sûr de supprimer ce jeux de contrôle ?
+ filters:
+ name: 'Indiquez un nom de jeux de contrôle...'
+ search_no_results: 'Aucun jeu de contrôle ne correspond à votre recherche'
activerecord:
models:
compliance_control_set: Calendrier
@@ -18,4 +21,4 @@ fr:
assignment: Affectation
owner_jdc: Propriétaire du jeu de contrôle
control_numbers: Nb contrôle
- update: Mis a jour \ No newline at end of file
+ updated_at: Mis a jour \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 97e0257c2..ef625db1f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,8 +12,6 @@ ChouetteIhm::Application.routes.draw do
end
end
- resources :compliance_control_sets
-
devise_for :users, :controllers => {
:registrations => 'users/registrations', :invitations => 'users/invitations'
}