From 703c6cab6b0a5cc8699c846796777937e372a9ad Mon Sep 17 00:00:00 2001
From: Robert
Date: Fri, 27 Oct 2017 12:49:47 +0200
Subject: Refs: #4774;
DB Setup for specs
---
.../compliance_control_sets_controller.rb | 9 ++++-
app/helpers/table_builder_helper.rb | 1 +
.../compliance_control_sets/grouping.html.slim | 39 ++++++++++++++++++++++
.../layouts/navigation/_main_nav_left.html.slim | 21 ++++++------
config/routes.rb | 1 +
spec/features/complience_control_sets_spec.rb | 36 ++++++++++++++++++++
spec/features/connection_links_spec.rb | 2 +-
spec/models/compliance_control_spec.rb | 4 ---
8 files changed, 97 insertions(+), 16 deletions(-)
create mode 100644 app/views/compliance_control_sets/grouping.html.slim
create mode 100644 spec/features/complience_control_sets_spec.rb
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 570204065..7d695a197 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -29,6 +29,13 @@ class ComplianceControlSetsController < InheritedResources::Base
redirect_to(compliance_control_sets_path)
end
+ def grouping
+ show! do | format |
+ format.html do
+ @controls = @compliance_control_set.compliance_controls.to_a
+ end
+ end
+ end
protected
def begin_of_association_chain
@@ -54,4 +61,4 @@ class ComplianceControlSetsController < InheritedResources::Base
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
end
-end
\ No newline at end of file
+end
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 95f53a90d..3eacffa9e 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -116,6 +116,7 @@ module TableBuilderHelper
hcont << content_tag(:th, checkbox(id_name: '0', value: 'all'))
end
+ require 'pry'; binding.pry
columns.each do |column|
if overhead.empty?
hcont << content_tag(:th, build_column_header(
diff --git a/app/views/compliance_control_sets/grouping.html.slim b/app/views/compliance_control_sets/grouping.html.slim
new file mode 100644
index 000000000..d527601b2
--- /dev/null
+++ b/app/views/compliance_control_sets/grouping.html.slim
@@ -0,0 +1,39 @@
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = definition_list t('metadatas'),
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
+ .row
+ .col-lg-12
+ h2
+ = transport_mode("", "")
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @coontrols, \
+ [ \
+ 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'
+
diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim
index 062c9383c..837b9cb73 100644
--- a/app/views/layouts/navigation/_main_nav_left.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left.html.slim
@@ -31,16 +31,17 @@
#miTwo.panel-collapse.collapse
.list-group
- = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
- span Jeux de données
- = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
- span Import
- = link_to calendars_path, class: 'list-group-item' do
- span Modèles de calendrier
- = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
- span Rapport de contrôle
- = link_to compliance_control_sets_path, class: 'list-group-item' do
- span Jeux de contrôle
+ - if current_user
+ = link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
+ span Jeux de données
+ = link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
+ span Import
+ = link_to calendars_path, class: 'list-group-item' do
+ span Modèles de calendrier
+ = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do
+ span Rapport de contrôle
+ = link_to compliance_control_sets_path, class: 'list-group-item' do
+ span Jeux de contrôle
.menu-item.panel
.panel-heading
diff --git a/config/routes.rb b/config/routes.rb
index b105e77d6..41897e159 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -75,6 +75,7 @@ ChouetteIhm::Application.routes.draw do
resources :compliance_control_sets do
get :clone, on: :member
+ get :grouping, on: :member
resources :compliance_controls, except: :index do
get :select_type, on: :collection
end
diff --git a/spec/features/complience_control_sets_spec.rb b/spec/features/complience_control_sets_spec.rb
new file mode 100644
index 000000000..0acf42d7f
--- /dev/null
+++ b/spec/features/complience_control_sets_spec.rb
@@ -0,0 +1,36 @@
+RSpec.describe "ComplianceControlSets", type: :feature do
+
+ login_user
+
+ let( :control_set ){ create :compliance_control_set }
+ let( :min_max_class ){ GenericAttributeControl::MinMax }
+ let( :pattern_class ){ GenericAttributeControl::Pattern }
+
+ let( :common_atts ){{
+ compliance_control_set: control_set,
+ }}
+
+
+ let(:blox){
+ 3.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set }
+ }
+
+ before do
+ blox.each do | block |
+ create( :generic_attribute_control_min_max, code: random_string, compliance_control_block: block, **common_atts )
+ create( :generic_attribute_control_pattern, code: random_string, compliance_control_block: block, **common_atts )
+ end
+ end
+
+ describe 'show' do
+ it 'check setup' do
+ each_kind_count = 3
+ expect( min_max_class.count ).to eq(each_kind_count)
+ expect( pattern_class.count ).to eq(each_kind_count)
+ query = ComplianceControl.group(:compliance_control_block)
+ require 'pry'; binding.pry
+ end
+
+ end
+
+end
diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb
index 7272242fe..2f6283dcd 100644
--- a/spec/features/connection_links_spec.rb
+++ b/spec/features/connection_links_spec.rb
@@ -1,4 +1,4 @@
-RSpec.describe "ConnectionLinks", :type => :feature do
+RSpec.describe "ConnectionLinks", type: :feature do
login_user
let!(:connection_links) { Array.new(2) { create(:connection_link) } }
diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb
index db73dab21..4267459ea 100644
--- a/spec/models/compliance_control_spec.rb
+++ b/spec/models/compliance_control_spec.rb
@@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do
let(:compliance_control) { build_stubbed :compliance_control }
- it 'should have a valid factory' do
- expect(compliance_control).to be_valid
- end
-
it { should belong_to :compliance_control_set }
it { should belong_to :compliance_control_block }
--
cgit v1.2.3
From 17bf95ca2a8cd645e1310fd64d514adb4044744d Mon Sep 17 00:00:00 2001
From: Robert
Date: Wed, 25 Oct 2017 11:55:02 +0200
Subject: Refs: #4774;
table_builder2 modified to accept an array of objects
- add optional param `model:` which is needed for header display **only**
if collection does not return the `model` itself
initial [amend me] [skip ci]
---
app/helpers/table_builder_helper.rb | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index 3eacffa9e..37f01ce0d 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -83,17 +83,21 @@ module TableBuilderHelper
cls: '',
# A set of content, over the th line...
- overhead: []
+ overhead: [],
+
+ # Possibility to override the result of collection.model
+ model: nil
+
)
content_tag :table,
- thead(collection, columns, sortable, selectable, links.any?, overhead) +
+ thead(collection, columns, sortable, selectable, links.any?, overhead, model || collection.model) +
tbody(collection, columns, selectable, links, overhead),
class: cls
end
private
- def thead(collection, columns, sortable, selectable, has_links, overhead)
+ def thead(collection, columns, sortable, selectable, has_links, overhead, model )
content_tag :thead do
# Inserts overhead content if any specified
over_head = ''
@@ -116,13 +120,12 @@ module TableBuilderHelper
hcont << content_tag(:th, checkbox(id_name: '0', value: 'all'))
end
- require 'pry'; binding.pry
columns.each do |column|
if overhead.empty?
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -138,7 +141,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -148,7 +151,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -161,7 +164,7 @@ module TableBuilderHelper
hcont << content_tag(:th, build_column_header(
column,
sortable,
- collection.model,
+ model,
params,
params[:sort],
params[:direction]
@@ -300,14 +303,14 @@ module TableBuilderHelper
def build_column_header(
column,
table_is_sortable,
- collection_model,
+ model,
params,
sort_on,
sort_direction
)
if !table_is_sortable || !column.sortable
- return column.header_label(collection_model)
+ return column.header_label(model)
end
direction =
@@ -332,7 +335,7 @@ module TableBuilderHelper
arrow_icons = content_tag :span, arrow_up + arrow_down, class: 'orderers'
(
- column.header_label(collection_model) +
+ column.header_label(model) +
arrow_icons
).html_safe
end
--
cgit v1.2.3
From 13a42deb92b149811214ed2c7ecc3007c0436ae2 Mon Sep 17 00:00:00 2001
From: Robert
Date: Wed, 25 Oct 2017 17:25:25 +0200
Subject: Refs: #4774@1.5h;
Table Builder Helper table_builder2 with explicit model: parameter integrated into the view
TODO:
- Feature specs
- Add Ransack Filters
---
.../compliance_control_sets_controller.rb | 11 ++----
.../compliance_control_sets/grouping.html.slim | 39 ----------------------
app/views/compliance_control_sets/show.html.slim | 12 ++++---
config/routes.rb | 1 -
4 files changed, 10 insertions(+), 53 deletions(-)
delete mode 100644 app/views/compliance_control_sets/grouping.html.slim
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 7d695a197..65bb3b22e 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -18,7 +18,9 @@ class ComplianceControlSetsController < InheritedResources::Base
show! do |format|
format.html {
@compliance_control_set = @compliance_control_set.decorate
- @compliance_controls_without_block = decorate_compliance_controls(@compliance_control_set.compliance_controls.where(compliance_control_block_id: nil))
+ @compliance_controls =
+ decorate_compliance_controls(@compliance_control_set.compliance_controls)
+ .group_by(&:compliance_control_block)
}
end
end
@@ -29,13 +31,6 @@ class ComplianceControlSetsController < InheritedResources::Base
redirect_to(compliance_control_sets_path)
end
- def grouping
- show! do | format |
- format.html do
- @controls = @compliance_control_set.compliance_controls.to_a
- end
- end
- end
protected
def begin_of_association_chain
diff --git a/app/views/compliance_control_sets/grouping.html.slim b/app/views/compliance_control_sets/grouping.html.slim
deleted file mode 100644
index d527601b2..000000000
--- a/app/views/compliance_control_sets/grouping.html.slim
+++ /dev/null
@@ -1,39 +0,0 @@
-/ PageContent
-.page_content
- .container-fluid
- .row
- .col-lg-6.col-md-6.col-sm-12.col-xs-12
- = definition_list t('metadatas'),
- ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
- .row
- .col-lg-12
- h2
- = transport_mode("", "")
- .row
- .col-lg-12
- .select_table
- = table_builder_2 @coontrols, \
- [ \
- 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'
-
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index cf236feb8..28d602eb5 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -31,7 +31,7 @@
.row
.col-lg-12
.select_table
- = table_builder_2 @compliance_controls_without_block,
+ = table_builder_2 @compliance_controls.delete(nil),
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -54,9 +54,10 @@
), \
],
sortable: true,
- cls: 'table has-filter has-search'
+ cls: 'table has-filter has-search',
+ model: ComplianceControl
- - @compliance_control_set.compliance_control_blocks.each do |block|
+ - @compliance_controls.each do |block, compliance_controls|
.row
.col-lg-12
h2
@@ -71,7 +72,7 @@
.row
.col-lg-12
.select_table
- = table_builder_2 ModelDecorator.decorate(block.compliance_controls, with: ComplianceControlDecorator),
+ = table_builder_2 compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -94,7 +95,8 @@
), \
],
sortable: true,
- cls: 'table has-filter has-search'
+ cls: 'table has-filter has-search',
+ model: ComplianceControl
.select_toolbox
ul
li.st_action.with_text
diff --git a/config/routes.rb b/config/routes.rb
index 41897e159..b105e77d6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -75,7 +75,6 @@ ChouetteIhm::Application.routes.draw do
resources :compliance_control_sets do
get :clone, on: :member
- get :grouping, on: :member
resources :compliance_controls, except: :index do
get :select_type, on: :collection
end
--
cgit v1.2.3
From 1b2176d73336fce7baa57d2b6a017f0e2653cd43 Mon Sep 17 00:00:00 2001
From: Robert
Date: Thu, 26 Oct 2017 09:47:03 +0200
Subject: Refs: #4774@1h; Structure of filter views scaffolded
---
app/controllers/stop_areas_controller.rb | 1 -
app/views/compliance_control_sets/show.html.slim | 89 ++++++++++++++----------
app/views/compliance_controls/_filters.html.slim | 24 +++++++
3 files changed, 75 insertions(+), 39 deletions(-)
create mode 100644 app/views/compliance_controls/_filters.html.slim
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| ("#{w.name}").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'
--
cgit v1.2.3
From ac2676bf1b7364e63cd4820e253d40ba5325be73 Mon Sep 17 00:00:00 2001
From: Robert
Date: Thu, 26 Oct 2017 11:25:31 +0200
Subject: Refs: #4774@0.5h; Exploring the alternate possibility of only one
ransack filter for the controls on the page [skip-ci]
---
app/views/compliance_controls/_filters.html.slim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index 1a54a4ccc..6e9505fea 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -1,4 +1,4 @@
-= search_form_for q_for_form, url: compliance_control_set_compliance_controls_path, builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
+= search_form_for @q_controls_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
--
cgit v1.2.3
From 2f518afba3392d102afdc4dfa5da1c93acba6fec Mon Sep 17 00:00:00 2001
From: Robert
Date: Thu, 26 Oct 2017 12:00:12 +0200
Subject: Refs: #4774@0.5h
Ransack setup need to adapt `/compliance_controls/_filters.html.slim`
---
.../compliance_control_sets_controller.rb | 6 +-
app/views/compliance_control_sets/show.html.slim | 73 +++++++++++-----------
app/views/compliance_controls/_filters.html.slim | 5 +-
3 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 65bb3b22e..f576a55c5 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -18,9 +18,11 @@ class ComplianceControlSetsController < InheritedResources::Base
show! do |format|
format.html {
@compliance_control_set = @compliance_control_set.decorate
+ @compliance_controls = @compliance_control_set.compliance_controls
+ @q_controls_form = @compliance_controls.ransack(params[:q])
@compliance_controls =
- decorate_compliance_controls(@compliance_control_set.compliance_controls)
- .group_by(&:compliance_control_block)
+ decorate_compliance_controls( @compliance_controls)
+ .group_by(&:compliance_control_block)
}
end
end
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index 621c188e4..d0cbb0ca4 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -24,51 +24,48 @@
.col-lg-6.col-md-6.col-sm-12.col-xs-12
= definition_list t('metadatas'),
ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
+ - if params[:q].present? or @compliance_controls.any?
+ .row
+ .col-lg-12
+ = render '/compliance_controls/filters'
+
.row
.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 direct_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
+ - direct_controls = @compliance_controls.delete nil
- - @compliance_controls.each do |block, compliance_controls|
- - if params[:q].present? or compliance_controls.any?
+ - if direct_controls.any?
.row
.col-lg-12
- = render '/compliance_controls/filter', controls: compliance_controls
+ .select_table
+ = table_builder_2 direct_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
+
+ - @compliance_controls.each do |block, compliance_controls|
- if compliance_controls.any?
.row
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index 6e9505fea..b9cb69a2a 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -1,4 +1,7 @@
-= search_form_for @q_controls_form, url: compliance_control_set_compliance_controls_path, builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
+= search_form_for @q_controls_form,
+ url: compliance_control_set_compliance_controls_path(@compliance_control_set),
+ builder: SimpleForm::FormBuilder,
+ class: 'form form-filter' do |f|
// Rewriting the ransack filter copied from cc_stes/_filter
.ffg-row
--
cgit v1.2.3
From c29671392e88d6e4a29e6eaea3a1d7b9cfd21529 Mon Sep 17 00:00:00 2001
From: Robert
Date: Fri, 27 Oct 2017 08:31:36 +0200
Subject: Refs: #4774@3h;
Ransack filter view implemented
---
.../compliance_control_sets_controller.rb | 14 ++++++-
app/models/compliance_control.rb | 43 ++++++++++++----------
app/views/compliance_control_sets/simple.html.slim | 34 +++++++++++++++++
app/views/compliance_controls/_filters.html.slim | 42 ++++++++++++++-------
.../compliance_controls/_simple_filters.html.slim | 38 +++++++++++++++++++
config/locales/compliance_controls.en.yml | 6 ++-
config/locales/compliance_controls.fr.yml | 10 +++--
config/routes.rb | 1 +
8 files changed, 149 insertions(+), 39 deletions(-)
create mode 100644 app/views/compliance_control_sets/simple.html.slim
create mode 100644 app/views/compliance_controls/_simple_filters.html.slim
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index f576a55c5..ac07c5495 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -21,12 +21,22 @@ class ComplianceControlSetsController < InheritedResources::Base
@compliance_controls = @compliance_control_set.compliance_controls
@q_controls_form = @compliance_controls.ransack(params[:q])
@compliance_controls =
- decorate_compliance_controls( @compliance_controls)
- .group_by(&:compliance_control_block)
+ decorate_compliance_controls( @compliance_controls)
+ .group_by(&:compliance_control_block)
}
end
end
+ def simple
+ show! do | format |
+ format.html do
+ @compliance_controls = @compliance_control_set.compliance_controls
+ @q_controls_form = @compliance_controls.ransack(params[:q])
+ @compliance_control_set = @compliance_control_set.decorate
+ end
+ end
+ end
+
def clone
ComplianceControlSetCloner.new.copy(params[:id], current_organisation.id)
flash[:notice] = I18n.t("compliance_control_sets.errors.operation_in_progress")
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 08efa7e9a..e00a2c109 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -1,9 +1,31 @@
class ComplianceControl < ActiveRecord::Base
+
+ class << self
+ def criticities; %i(warning error) end
+ def default_code; "" end
+ def dynamic_attributes
+ hstore_metadata_for_control_attributes.keys
+ end
+
+ def policy_class
+ ComplianceControlPolicy
+ end
+
+ def inherited(child)
+ child.instance_eval do
+ def model_name
+ ComplianceControl.model_name
+ end
+ end
+ super
+ end
+ end
+
extend Enumerize
belongs_to :compliance_control_set
belongs_to :compliance_control_block
- enumerize :criticity, in: %i(warning error), scope: true, default: :warning
+ enumerize :criticity, in: criticities, scope: true, default: :warning
hstore_accessor :control_attributes, {}
validates :criticity, presence: true
@@ -23,25 +45,6 @@ class ComplianceControl < ActiveRecord::Base
direct_set_name: names.last))
end
- class << self
- def default_code; "" end
- def dynamic_attributes
- hstore_metadata_for_control_attributes.keys
- end
-
- def policy_class
- ComplianceControlPolicy
- end
-
- def inherited(child)
- child.instance_eval do
- def model_name
- ComplianceControl.model_name
- end
- end
- super
- end
- end
def initialize(attributes = {})
super
diff --git a/app/views/compliance_control_sets/simple.html.slim b/app/views/compliance_control_sets/simple.html.slim
new file mode 100644
index 000000000..73f127646
--- /dev/null
+++ b/app/views/compliance_control_sets/simple.html.slim
@@ -0,0 +1,34 @@
+/ PageHeader
+= pageheader 'Simple',
+ t('compliance_control_sets.show.title', name: @compliance_control_set.name),
+ 'Lorem ipsum dolor sit amet'
+
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = definition_list t('metadatas'),
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
+ - if params[:q].present? or @compliance_controls.any?
+ .row
+ .col-lg-12
+ = render '/compliance_controls/simple_filters'
+
+ - if @compliance_controls.any?
+ .row
+ .col-lg-12
+ .select_table
+ table
+ thead
+ th id
+ th name
+ tbody
+ - @compliance_controls.each do | cc |
+ tr
+ td
+ = cc.id
+ td
+ = cc.name
+
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index b9cb69a2a..55490e01b 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -1,27 +1,43 @@
= search_form_for @q_controls_form,
- url: compliance_control_set_compliance_controls_path(@compliance_control_set),
- builder: SimpleForm::FormBuilder,
+ url: compliance_control_set_path(@compliance_control_set),
+ 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')
+ = f.search_field :name_cont,
+ class: 'form-control',
+ placeholder: t('compliance_controls.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| ("#{w.name}").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'}
-
+ = f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label'
+ = f.input :compliance_control_block_name_eq_any,
+ collection: @compliance_control_set.compliance_control_blocks,
+ as: :check_boxes,
+ label: true,
+ label_method: lambda {|w| ("#{w.name}").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable
+ = f.label t('compliance_controls.filters.comment'), required: false, class: 'control-label'
+ = f.collection_check_boxes :comment_eq_any,
+ @compliance_control_set.compliance_controls,
+ :id, :comment,
+ label: true,
+ 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
+ = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
+ = f.input :criticity_eq,
+ collection: ComplianceControl.criticities,
+ as: :check_boxes,
+ label: true,
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
.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'
+ = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_control_set_compliance_controls_filter_btn'
diff --git a/app/views/compliance_controls/_simple_filters.html.slim b/app/views/compliance_controls/_simple_filters.html.slim
new file mode 100644
index 000000000..da037c051
--- /dev/null
+++ b/app/views/compliance_controls/_simple_filters.html.slim
@@ -0,0 +1,38 @@
+= search_form_for @q_controls_form,
+ url: simple_compliance_control_set_path(@compliance_control_set),
+ 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('compliance_controls.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.compliance_control_block.one'), required: false, class: 'control-label'
+ = f.input :compliance_control_block_id_eq_any,
+ collection: @compliance_control_set.compliance_control_blocks,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("#{w.name}").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+
+ .form-group.togglable
+ = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
+ = f.input :criticity_eq,
+ collection: ComplianceControl.criticities,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("#{w}").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+
+ .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_compliance_controls_filter_btn'
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index 887bc2009..f39f54e5b 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -2,6 +2,10 @@ en:
compliance_controls:
clone:
prefix: 'Copy of'
+ filters:
+ comment: Object
+ criticity: Severity
+ name: "Search by a control's name or code"
min_max_values: "the minimum (%{min}) is not supposed to be greater than the maximum (%{max})"
errors:
incoherent_control_sets: "Impossible to assign a control to a set (id: %{direct_set_name}) differing from the one of its group (id: %{indirect_set_name})"
@@ -179,4 +183,4 @@ en:
compliance_control_block: "Control Block"
minimum: "Minimum"
maximum: "Maximum"
- target: "Target"
\ No newline at end of file
+ target: "Target"
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index 2feb201bf..312638379 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -2,6 +2,10 @@ fr:
compliance_controls:
clone:
prefix: 'Copie de'
+ filters:
+ comment: Objet
+ criticity: Criticité
+ name: "Chercher le nom ou code d'un contrôl"
min_max_values: "la valeur de minimum (%{min}) ne doit pas être superieur à la valuer du maximum (%{max})"
errors:
incoherent_control_sets: "Le contrôle ne peut pas être associé à un jeu de contrôle (id: %{direct_set_name}) différent de celui de son groupe (id: %{indirect_set_name})"
@@ -119,7 +123,7 @@ fr:
activerecord:
models:
compliance_control:
- one: "controle"
+ one: "contrôle"
other: "contrôles"
route_control/zdl_stop_area:
one: "Deux arrêts d’une même ZDL ne peuvent pas se succéder dans un itinéraire"
@@ -130,7 +134,7 @@ fr:
route_control/duplicates:
one: "Détection de double définition d'itinéraire"
route_control/opposite_route_terminus:
- one: "Vérification des terminus de l'itinéraire inverse"
+ one: "Vérification des terminus de l'itinéraire inverse"
route_control/minimum_length:
one: "Un itinéraire doit contenir au moins 2 arrêts"
route_control/omnibus_journey_pattern:
@@ -179,4 +183,4 @@ fr:
compliance_control_block: "Groupe de contrôle"
minimum: "Minimum"
maximum: "Maximum"
- target: "Cible"
\ No newline at end of file
+ target: "Cible"
diff --git a/config/routes.rb b/config/routes.rb
index b105e77d6..27c3c3044 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -74,6 +74,7 @@ ChouetteIhm::Application.routes.draw do
resources :api_keys, :only => [:edit, :update, :new, :create, :destroy]
resources :compliance_control_sets do
+ get :simple, on: :member
get :clone, on: :member
resources :compliance_controls, except: :index do
get :select_type, on: :collection
--
cgit v1.2.3
From a08084af35f1fba1421cc5205280b38c36ff5fd4 Mon Sep 17 00:00:00 2001
From: Robert
Date: Sun, 29 Oct 2017 05:28:11 +0100
Subject: Refs: #4774@4h; Ransack debugged succesfully
---
.../compliance_control_sets_controller.rb | 15 ++-------
app/views/compliance_control_sets/show.html.slim | 5 +--
app/views/compliance_control_sets/simple.html.slim | 34 -------------------
app/views/compliance_controls/_filters.html.slim | 18 ++++------
.../compliance_controls/_simple_filters.html.slim | 38 ----------------------
5 files changed, 11 insertions(+), 99 deletions(-)
delete mode 100644 app/views/compliance_control_sets/simple.html.slim
delete mode 100644 app/views/compliance_controls/_simple_filters.html.slim
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index ac07c5495..b8514e348 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -17,26 +17,15 @@ class ComplianceControlSetsController < InheritedResources::Base
def show
show! do |format|
format.html {
+ @q_controls_form = @compliance_control_set.compliance_controls.ransack(params[:q])
@compliance_control_set = @compliance_control_set.decorate
- @compliance_controls = @compliance_control_set.compliance_controls
- @q_controls_form = @compliance_controls.ransack(params[:q])
@compliance_controls =
- decorate_compliance_controls( @compliance_controls)
+ decorate_compliance_controls( @q_controls_form.result)
.group_by(&:compliance_control_block)
}
end
end
- def simple
- show! do | format |
- format.html do
- @compliance_controls = @compliance_control_set.compliance_controls
- @q_controls_form = @compliance_controls.ransack(params[:q])
- @compliance_control_set = @compliance_control_set.decorate
- end
- end
- end
-
def clone
ComplianceControlSetCloner.new.copy(params[:id], current_organisation.id)
flash[:notice] = I18n.t("compliance_control_sets.errors.operation_in_progress")
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index d0cbb0ca4..db0ed64ea 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -35,7 +35,7 @@
= transport_mode("", "")
- direct_controls = @compliance_controls.delete nil
- - if direct_controls.any?
+ - if direct_controls.try(:any?)
.row
.col-lg-12
.select_table
@@ -67,7 +67,7 @@
- @compliance_controls.each do |block, compliance_controls|
- - if compliance_controls.any?
+ - if compliance_controls.try(:any?)
.row
.col-lg-12
h2
@@ -107,6 +107,7 @@
sortable: true,
cls: 'table has-filter has-search',
model: ComplianceControl
+
.select_toolbox
ul
li.st_action.with_text
diff --git a/app/views/compliance_control_sets/simple.html.slim b/app/views/compliance_control_sets/simple.html.slim
deleted file mode 100644
index 73f127646..000000000
--- a/app/views/compliance_control_sets/simple.html.slim
+++ /dev/null
@@ -1,34 +0,0 @@
-/ PageHeader
-= pageheader 'Simple',
- t('compliance_control_sets.show.title', name: @compliance_control_set.name),
- 'Lorem ipsum dolor sit amet'
-
-
-/ PageContent
-.page_content
- .container-fluid
- .row
- .col-lg-6.col-md-6.col-sm-12.col-xs-12
- = definition_list t('metadatas'),
- ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name
- - if params[:q].present? or @compliance_controls.any?
- .row
- .col-lg-12
- = render '/compliance_controls/simple_filters'
-
- - if @compliance_controls.any?
- .row
- .col-lg-12
- .select_table
- table
- thead
- th id
- th name
- tbody
- - @compliance_controls.each do | cc |
- tr
- td
- = cc.id
- td
- = cc.name
-
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index 55490e01b..75cb4b7f4 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -15,26 +15,20 @@
.ffg-row
.form-group.togglable
= f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label'
- = f.input :compliance_control_block_name_eq_any,
+ = f.input :compliance_control_block_id_eq_any,
collection: @compliance_control_set.compliance_control_blocks,
as: :check_boxes,
- label: true,
- label_method: lambda {|w| ("#{w.name}").html_safe},
+ label: false,
+ label_method: lambda {|w| ("#{transport_mode(w.transport_mode, w.transport_submode)}").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
- .form-group.togglable
- = f.label t('compliance_controls.filters.comment'), required: false, class: 'control-label'
- = f.collection_check_boxes :comment_eq_any,
- @compliance_control_set.compliance_controls,
- :id, :comment,
- label: true,
- wrapper_html: {class: 'checkbox_list'}
.form-group.togglable
= f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
- = f.input :criticity_eq,
+ = f.input :criticity_eq_any,
collection: ComplianceControl.criticities,
as: :check_boxes,
- label: true,
+ label: false,
+ label_method: lambda {|w| ("#{w}").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
diff --git a/app/views/compliance_controls/_simple_filters.html.slim b/app/views/compliance_controls/_simple_filters.html.slim
deleted file mode 100644
index da037c051..000000000
--- a/app/views/compliance_controls/_simple_filters.html.slim
+++ /dev/null
@@ -1,38 +0,0 @@
-= search_form_for @q_controls_form,
- url: simple_compliance_control_set_path(@compliance_control_set),
- 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('compliance_controls.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.compliance_control_block.one'), required: false, class: 'control-label'
- = f.input :compliance_control_block_id_eq_any,
- collection: @compliance_control_set.compliance_control_blocks,
- as: :check_boxes,
- label: false,
- label_method: lambda {|w| ("#{w.name}").html_safe},
- required: false,
- wrapper_html: {class: 'checkbox_list'}
-
- .form-group.togglable
- = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
- = f.input :criticity_eq,
- collection: ComplianceControl.criticities,
- as: :check_boxes,
- label: false,
- label_method: lambda {|w| ("#{w}").html_safe},
- required: false,
- wrapper_html: {class: 'checkbox_list'}
-
- .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_compliance_controls_filter_btn'
--
cgit v1.2.3
From 68d0ed6e6d3d9bb681fd197d1553abd568a0e1dd Mon Sep 17 00:00:00 2001
From: Robert
Date: Sun, 29 Oct 2017 21:27:46 +0100
Subject: Refs: #4774@3h;
Speced feature compliance_control_set/show and filtering on Severity
MISSING: Object Filter needs 2B specified
---
app/helpers/compliance_control_blocks_helper.rb | 2 +-
app/views/compliance_controls/_filters.html.slim | 4 +-
spec/features/compliance_control_sets_spec.rb | 67 ++++++++++++++++++++++++
spec/features/complience_control_sets_spec.rb | 36 -------------
4 files changed, 70 insertions(+), 39 deletions(-)
create mode 100644 spec/features/compliance_control_sets_spec.rb
delete mode 100644 spec/features/complience_control_sets_spec.rb
diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb
index 5c279b33a..311e6fb46 100644
--- a/app/helpers/compliance_control_blocks_helper.rb
+++ b/app/helpers/compliance_control_blocks_helper.rb
@@ -7,4 +7,4 @@ module ComplianceControlBlocksHelper
"[" + t("enumerize.transport_mode.#{transport_mode}") + "]" + "[" + t("enumerize.transport_submode.#{transport_submode}") + "]"
end
end
-end
\ No newline at end of file
+end
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index 75cb4b7f4..200aede7e 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -13,7 +13,7 @@
span.fa.fa-search
.ffg-row
- .form-group.togglable
+ .form-group.togglable#compliance_control_block-filter
= f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label'
= f.input :compliance_control_block_id_eq_any,
collection: @compliance_control_set.compliance_control_blocks,
@@ -22,7 +22,7 @@
label_method: lambda {|w| ("#{transport_mode(w.transport_mode, w.transport_submode)}").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
- .form-group.togglable
+ .form-group.togglable#severity-filter
= f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
= f.input :criticity_eq_any,
collection: ComplianceControl.criticities,
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
new file mode 100644
index 000000000..f52e2737e
--- /dev/null
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -0,0 +1,67 @@
+RSpec.describe "ComplianceControlSets", type: :feature do
+
+ login_user
+
+ # We setup a control_set with two blocks and one direct control (meaning that it is not attached to a block)
+ # Then we add one control to the first block and two controls to the second block
+ let( :control_set ){ create :compliance_control_set, organisation: organisation }
+ let( :controls ){ control_set.compliance_controls }
+
+ let(:blox){
+ 2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set }
+ }
+ let( :controls_hash ){ Hash.new{ |h, k| h[k] = [] } }
+
+
+ before do
+ blox.first.update transport_mode: 'bus', transport_submode: 'bus'
+ blox.second.update transport_mode: 'train', transport_submode: 'train'
+
+ make_control
+ make_control blox.first, severity: :error
+ make_control blox.second, times: 2
+ end
+
+ describe 'show' do
+ before do
+ visit compliance_control_set_path( control_set )
+ end
+
+ it 'we can see the controls inside their blocks' do
+ controls.each do | control |
+ expect( page ).to have_content(control.code)
+ end
+ end
+
+ it 'we can apply a filter' do
+ within('#severity-filter') do
+ find('input[value="error"]').click
+ end
+ click_on('Filtrer')
+ controls_hash['error'].each do
+ expect( page ).to have_content(control.code)
+ end
+ controls_hash['warning'].each do
+ expect( page ).not_to have_content(control.code)
+ end
+ end
+
+ end
+
+ def make_control ccblock=nil, times: 1, severity: :warning
+ times.times do
+ make_one_control ccblock, severity
+ end
+ end
+
+ def make_one_control ccblock, severity
+ create( :generic_attribute_control_min_max,
+ code: random_string,
+ compliance_control_block: ccblock,
+ compliance_control_set: control_set,
+ criticity: severity ).tap do | ctrl |
+ controls_hash[severity] << ctrl
+ end
+ end
+
+end
diff --git a/spec/features/complience_control_sets_spec.rb b/spec/features/complience_control_sets_spec.rb
deleted file mode 100644
index 0acf42d7f..000000000
--- a/spec/features/complience_control_sets_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-RSpec.describe "ComplianceControlSets", type: :feature do
-
- login_user
-
- let( :control_set ){ create :compliance_control_set }
- let( :min_max_class ){ GenericAttributeControl::MinMax }
- let( :pattern_class ){ GenericAttributeControl::Pattern }
-
- let( :common_atts ){{
- compliance_control_set: control_set,
- }}
-
-
- let(:blox){
- 3.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set }
- }
-
- before do
- blox.each do | block |
- create( :generic_attribute_control_min_max, code: random_string, compliance_control_block: block, **common_atts )
- create( :generic_attribute_control_pattern, code: random_string, compliance_control_block: block, **common_atts )
- end
- end
-
- describe 'show' do
- it 'check setup' do
- each_kind_count = 3
- expect( min_max_class.count ).to eq(each_kind_count)
- expect( pattern_class.count ).to eq(each_kind_count)
- query = ComplianceControl.group(:compliance_control_block)
- require 'pry'; binding.pry
- end
-
- end
-
-end
--
cgit v1.2.3
From f95e4360bc559cec31a5e83de4dda8119a74c23d Mon Sep 17 00:00:00 2001
From: Robert
Date: Mon, 30 Oct 2017 17:15:16 +0100
Subject: Refs: #4774@2h; Debugging feature specs, added
ComplianceControl.subclass_patterns [amend me] [skip-ci]
---
app/helpers/compliance_controls_helper.rb | 2 ++
app/models/compliance_control.rb | 41 ++++++++++++++--------
spec/features/compliance_control_sets_spec.rb | 33 ++++++++++++-----
.../compliance_control_subclass_pattern_spec.rb | 17 +++++++++
4 files changed, 69 insertions(+), 24 deletions(-)
create mode 100644 app/helpers/compliance_controls_helper.rb
create mode 100644 spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb
diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb
new file mode 100644
index 000000000..ee7e56514
--- /dev/null
+++ b/app/helpers/compliance_controls_helper.rb
@@ -0,0 +1,2 @@
+module ComplianceControlsHelper
+end
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index e00a2c109..49fb6513f 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -11,6 +11,17 @@ class ComplianceControl < ActiveRecord::Base
ComplianceControlPolicy
end
+ def subclass_patterns
+ {
+ generic: 'Generic',
+ journey_pattern: 'JourneyPattern',
+ line: 'Line',
+ route: 'Route',
+ routing_constraint_zone: 'RoutingConstraint',
+ vehicle_journey: 'VehicleJourney'
+ }
+ end
+
def inherited(child)
child.instance_eval do
def model_name
@@ -35,23 +46,23 @@ class ComplianceControl < ActiveRecord::Base
validates :compliance_control_set, presence: true
validate def coherent_control_set
- return true if compliance_control_block_id.nil?
- ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
- return true if ids.first == ids.last
- names = ids.map{|id| ComplianceControlSet.find(id).name}
- errors.add(:coherent_control_set,
- I18n.t('compliance_controls.errors.incoherent_control_sets',
- indirect_set_name: names.first,
- direct_set_name: names.last))
- end
+ return true if compliance_control_block_id.nil?
+ ids = [compliance_control_block.compliance_control_set_id, compliance_control_set_id]
+ return true if ids.first == ids.last
+ names = ids.map{|id| ComplianceControlSet.find(id).name}
+ errors.add(:coherent_control_set,
+ I18n.t('compliance_controls.errors.incoherent_control_sets',
+ indirect_set_name: names.first,
+ direct_set_name: names.last))
+end
- def initialize(attributes = {})
- super
- self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
- self.code ||= self.class.default_code
- self.origin_code ||= self.class.default_code
- end
+def initialize(attributes = {})
+ super
+ self.name ||= I18n.t("activerecord.models.#{self.class.name.underscore}.one")
+ self.code ||= self.class.default_code
+ self.origin_code ||= self.class.default_code
+end
end
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index f52e2737e..cbe73f866 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -10,8 +10,6 @@ RSpec.describe "ComplianceControlSets", type: :feature do
let(:blox){
2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set }
}
- let( :controls_hash ){ Hash.new{ |h, k| h[k] = [] } }
-
before do
blox.first.update transport_mode: 'bus', transport_submode: 'bus'
@@ -33,19 +31,39 @@ RSpec.describe "ComplianceControlSets", type: :feature do
end
end
- it 'we can apply a filter' do
+ it 'we can apply a severity filter' do
+ controls.take(2).each do | control |
+ control.update criticity: 'error'
+ end
within('#severity-filter') do
find('input[value="error"]').click
end
click_on('Filtrer')
- controls_hash['error'].each do
+ controls.take(2).each do | control |
expect( page ).to have_content(control.code)
end
- controls_hash['warning'].each do
+ controls.drop(2).each do | control |
expect( page ).not_to have_content(control.code)
end
end
+ # it 'we can apply a subclass filter' do
+ # controls.first.update(origin_code: 'x-Route-y')
+ # controls.second.update(origin_code: 'x-Line-y')
+
+ # within('#subclass-filter') do
+ # find('input[value="Itinéraire"]').click
+ # find('input[value="Ligne"]').click
+ # end
+ # click_on('Filtrer')
+ # controls.take(2).each do | control |
+ # expect( page ).to have_content(control.code)
+ # end
+ # controls.drop(2).each do | control |
+ # expect( page ).not_to have_content(control.code)
+ # end
+ # end
+
end
def make_control ccblock=nil, times: 1, severity: :warning
@@ -58,10 +76,7 @@ RSpec.describe "ComplianceControlSets", type: :feature do
create( :generic_attribute_control_min_max,
code: random_string,
compliance_control_block: ccblock,
- compliance_control_set: control_set,
- criticity: severity ).tap do | ctrl |
- controls_hash[severity] << ctrl
- end
+ compliance_control_set: control_set)
end
end
diff --git a/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb
new file mode 100644
index 000000000..868eca984
--- /dev/null
+++ b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb
@@ -0,0 +1,17 @@
+RSpec.describe ComplianceControl do
+ let( :subject ){ described_class.subclass_patterns }
+
+ context 'subclass_patterns' do
+ it 'are correctly defined' do
+ expect_it.to eq(
+ generic: 'Generic',
+ journey_pattern: 'JourneyPattern',
+ line: 'Line',
+ route: 'Route',
+ routing_constraint_zone: 'RoutingConstraint',
+ vehicle_journey: 'VehicleJourney'
+ )
+ end
+ end
+
+end
--
cgit v1.2.3
From d6213f724633abfa2f899715b6f686d8972fe7e1 Mon Sep 17 00:00:00 2001
From: Robert
Date: Mon, 30 Oct 2017 17:59:26 +0100
Subject: Refs: #4774@2h;
View correctly implemented, but spex on filters do not work yet.
---
app/helpers/compliance_controls_helper.rb | 9 +++++++++
app/views/compliance_controls/_filters.html.slim | 9 +++++++++
config/locales/compliance_controls.en.yml | 9 ++++++++-
config/locales/compliance_controls.fr.yml | 9 ++++++++-
4 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb
index ee7e56514..ba0c538c9 100644
--- a/app/helpers/compliance_controls_helper.rb
+++ b/app/helpers/compliance_controls_helper.rb
@@ -1,2 +1,11 @@
module ComplianceControlsHelper
+ def subclass_selection_list
+ ComplianceControl.subclass_patterns.map(&method(:make_subclass_selection_item))
+ end
+
+
+ def make_subclass_selection_item(key_pattern)
+ key, pattern = key_pattern
+ [t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"]
+ end
end
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index 200aede7e..c729190a0 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -22,6 +22,15 @@
label_method: lambda {|w| ("#{transport_mode(w.transport_mode, w.transport_submode)}").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#subclass-filter
+ = f.label t('compliance_controls.filters.subclass'), required: false, class: 'control-label'
+ = f.input :origin_code_cont_any,
+ collection: subclass_selection_list,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("#{w.first}").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
.form-group.togglable#severity-filter
= f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label'
= f.input :criticity_eq_any,
diff --git a/config/locales/compliance_controls.en.yml b/config/locales/compliance_controls.en.yml
index f39f54e5b..41971d9e9 100644
--- a/config/locales/compliance_controls.en.yml
+++ b/config/locales/compliance_controls.en.yml
@@ -3,9 +3,16 @@ en:
clone:
prefix: 'Copy of'
filters:
- comment: Object
criticity: Severity
name: "Search by a control's name or code"
+ subclass: Object
+ subclasses:
+ generic: 'Generic'
+ journey_pattern: 'JourneyPattern'
+ line: 'Line'
+ route: 'Route'
+ routing_constraint_zone: 'RoutingConstraint'
+ vehicle_journey: 'VehicleJourney'
min_max_values: "the minimum (%{min}) is not supposed to be greater than the maximum (%{max})"
errors:
incoherent_control_sets: "Impossible to assign a control to a set (id: %{direct_set_name}) differing from the one of its group (id: %{indirect_set_name})"
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index 312638379..f6207187a 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -3,9 +3,16 @@ fr:
clone:
prefix: 'Copie de'
filters:
- comment: Objet
criticity: Criticité
name: "Chercher le nom ou code d'un contrôl"
+ subclass: Objet
+ subclasses:
+ generic: 'Généric'
+ journey_pattern: 'JourneyPattern'
+ line: 'Ligne'
+ route: 'Route'
+ routing_constraint_zone: 'ITL'
+ vehicle_journey: 'Course'
min_max_values: "la valeur de minimum (%{min}) ne doit pas être superieur à la valuer du maximum (%{max})"
errors:
incoherent_control_sets: "Le contrôle ne peut pas être associé à un jeu de contrôle (id: %{direct_set_name}) différent de celui de son groupe (id: %{indirect_set_name})"
--
cgit v1.2.3
From 64a1495e8368c3a7f406a2afc531fceea299c537 Mon Sep 17 00:00:00 2001
From: Robert
Date: Tue, 31 Oct 2017 08:28:08 +0100
Subject: Fixes: #4774@1h;
Filter Feature Spex of ComplianceControlSet#show implemented
---
config/locales/compliance_controls.fr.yml | 2 +-
spec/features/compliance_control_sets_spec.rb | 46 +++++++++++++--------------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/config/locales/compliance_controls.fr.yml b/config/locales/compliance_controls.fr.yml
index f6207187a..3fa83a147 100644
--- a/config/locales/compliance_controls.fr.yml
+++ b/config/locales/compliance_controls.fr.yml
@@ -10,7 +10,7 @@ fr:
generic: 'Généric'
journey_pattern: 'JourneyPattern'
line: 'Ligne'
- route: 'Route'
+ route: 'Itinéraire'
routing_constraint_zone: 'ITL'
vehicle_journey: 'Course'
min_max_values: "la valeur de minimum (%{min}) ne doit pas être superieur à la valuer du maximum (%{max})"
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index cbe73f866..500d4ce6f 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -35,34 +35,34 @@ RSpec.describe "ComplianceControlSets", type: :feature do
controls.take(2).each do | control |
control.update criticity: 'error'
end
- within('#severity-filter') do
- find('input[value="error"]').click
- end
+ check('error')
click_on('Filtrer')
- controls.take(2).each do | control |
- expect( page ).to have_content(control.code)
- end
- controls.drop(2).each do | control |
- expect( page ).not_to have_content(control.code)
+ controls.each do | control |
+ if control.criticity == 'error'
+ expect( page ).to have_content(control.code)
+ else
+ expect( page ).not_to have_content(control.code)
+ end
end
end
- # it 'we can apply a subclass filter' do
- # controls.first.update(origin_code: 'x-Route-y')
- # controls.second.update(origin_code: 'x-Line-y')
+ it 'we can apply a subclass filter' do
+ controls.first.update(origin_code: 'x-Route-y')
+ controls.second.update(origin_code: 'x-Line-y')
- # within('#subclass-filter') do
- # find('input[value="Itinéraire"]').click
- # find('input[value="Ligne"]').click
- # end
- # click_on('Filtrer')
- # controls.take(2).each do | control |
- # expect( page ).to have_content(control.code)
- # end
- # controls.drop(2).each do | control |
- # expect( page ).not_to have_content(control.code)
- # end
- # end
+ within('#subclass-filter') do
+ check('Itinéraire')
+ check('Ligne')
+ end
+ click_on('Filtrer')
+ controls.each do | control |
+ if control.origin_code[/-Generic-/]
+ expect( page ).not_to have_content(control.code)
+ else
+ expect( page ).to have_content(control.code)
+ end
+ end
+ end
end
--
cgit v1.2.3
From fb968eb1a31dab07b8b3263cf15d65c1a5c83298 Mon Sep 17 00:00:00 2001
From: Robert
Date: Tue, 31 Oct 2017 18:29:12 +0100
Subject: Refs: #4774@0.1h; CodeReview putting Business Logic of
@indirect_compliance_controls into controller
---
app/controllers/compliance_control_sets_controller.rb | 1 +
app/views/compliance_control_sets/show.html.slim | 5 ++---
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index b8514e348..b45e85d49 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -22,6 +22,7 @@ class ComplianceControlSetsController < InheritedResources::Base
@compliance_controls =
decorate_compliance_controls( @q_controls_form.result)
.group_by(&:compliance_control_block)
+ @indirect_compliance_controls = @compliance_controls.delete nil
}
end
end
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index db0ed64ea..294df6a53 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -33,13 +33,12 @@
.col-lg-12
h2
= transport_mode("", "")
- - direct_controls = @compliance_controls.delete nil
- - if direct_controls.try(:any?)
+ - if @indirect_compliance_controls.try(:any?)
.row
.col-lg-12
.select_table
- = table_builder_2 direct_controls,
+ = table_builder_2 @indirect_compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
--
cgit v1.2.3
From 35f62ffb9e4192ae007ec133637d18bc28a134ff Mon Sep 17 00:00:00 2001
From: Xinhui
Date: Fri, 3 Nov 2017 11:19:19 +0100
Subject: Showing root breadcrumb on root_path
Refs #4820
---
app/views/dashboards/show.html.slim | 1 +
app/views/layouts/navigation/_breadcrumb.html.slim | 2 +-
app/views/shared/_breadcrumb.html.slim | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/views/dashboards/show.html.slim b/app/views/dashboards/show.html.slim
index 66154712d..e86af55a6 100644
--- a/app/views/dashboards/show.html.slim
+++ b/app/views/dashboards/show.html.slim
@@ -1,3 +1,4 @@
+- breadcrumb :root
/ PageHeader
= pageheader 'tableau-de-bord',
t('.title', organisation: current_organisation.name)
diff --git a/app/views/layouts/navigation/_breadcrumb.html.slim b/app/views/layouts/navigation/_breadcrumb.html.slim
index 403ed6702..5cb6fe5c9 100644
--- a/app/views/layouts/navigation/_breadcrumb.html.slim
+++ b/app/views/layouts/navigation/_breadcrumb.html.slim
@@ -1 +1 @@
-== breadcrumbs
+== breadcrumbs display_single_fragment: true
diff --git a/app/views/shared/_breadcrumb.html.slim b/app/views/shared/_breadcrumb.html.slim
index 403ed6702..5cb6fe5c9 100644
--- a/app/views/shared/_breadcrumb.html.slim
+++ b/app/views/shared/_breadcrumb.html.slim
@@ -1 +1 @@
-== breadcrumbs
+== breadcrumbs display_single_fragment: true
--
cgit v1.2.3
From 27b40099c0b9498710882d44db80df04037a6f84 Mon Sep 17 00:00:00 2001
From: Xinhui
Date: Fri, 3 Nov 2017 12:07:04 +0100
Subject: Helper limit breadcrumb size
Refs #4820
---
app/helpers/breadcrumb_helper.rb | 5 +++++
config/breadcrumbs.rb | 46 ++++++++++++++++++++--------------------
2 files changed, 28 insertions(+), 23 deletions(-)
create mode 100644 app/helpers/breadcrumb_helper.rb
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
new file mode 100644
index 000000000..3da119247
--- /dev/null
+++ b/app/helpers/breadcrumb_helper.rb
@@ -0,0 +1,5 @@
+module BreadcrumbHelper
+ def breadcrumb_name(object, prop='name')
+ "#{object.class.model_name.human} #{object.public_send(prop)}".truncate(50)
+ end
+end
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index a9652fc89..4883ec7a2 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -3,11 +3,11 @@ crumb :root do
end
crumb :workbench do |workbench|
- link workbench.name, workbench_path(workbench)
+ link breadcrumb_name(workbench), workbench_path(workbench)
end
crumb :referential do |referential|
- link referential.name, referential_path(referential)
+ link breadcrumb_name(referential), referential_path(referential)
parent :workbench, current_offer_workbench
end
@@ -17,7 +17,7 @@ crumb :referential_companies do |referential|
end
crumb :referential_company do |referential, company|
- link company.name, referential_company_path(referential, company)
+ link breadcrumb_name(company), referential_company_path(referential, company)
parent :referential_companies, referential
end
@@ -27,7 +27,7 @@ crumb :referential_networks do |referential|
end
crumb :referential_network do |referential, network|
- link network.name, referential_network_path(referential, network)
+ link breadcrumb_name(network), referential_network_path(referential, network)
parent :referential_networks, referential
end
@@ -37,7 +37,7 @@ crumb :referential_group_of_lines do |referential|
end
crumb :referential_group_of_line do |referential, group_of_line|
- link group_of_line.name, referential_group_of_line_path(referential, group_of_line)
+ link breadcrumb_name(group_of_line), referential_group_of_line_path(referential, group_of_line)
parent :referential_group_of_lines, referential
end
@@ -47,7 +47,7 @@ crumb :referential_route_sections do |referential|
end
crumb :referential_route_section do |referential, route_section|
- link route_section.departure.name, referential_route_section_path(referential, route_section)
+ link breadcrumb_name(route_section.departure), referential_route_section_path(referential, route_section)
parent :referential_route_sections, referential
end
@@ -58,7 +58,7 @@ crumb :time_tables do |referential|
end
crumb :time_table do |referential, time_table|
- link time_table.comment, referential_time_table_path(referential, time_table)
+ link breadcrumb_name(time_table, 'comment'), referential_time_table_path(referential, time_table)
parent :time_tables, referential
end
@@ -68,7 +68,7 @@ crumb :timebands do |referential|
end
crumb :timeband do |referential, timeband|
- link timeband.name, referential_timeband_path(referential, timeband)
+ link breadcrumb_name(timeband), referential_timeband_path(referential, timeband)
parent :timebands, referential
end
@@ -78,7 +78,7 @@ crumb :compliance_check_sets do |workbench|
end
crumb :compliance_check_set do |workbench, compliance_check_set|
- link compliance_check_set.name, workbench_compliance_check_set_path(workbench, compliance_check_set)
+ link breadcrumb_name(compliance_check_set), workbench_compliance_check_set_path(workbench, compliance_check_set)
parent :compliance_check_sets, workbench
end
@@ -88,12 +88,12 @@ crumb :imports do |workbench|
end
crumb :import do |workbench, import|
- link import.name, workbench_import_path(workbench, import)
+ link breadcrumb_name(import), workbench_import_path(workbench, import)
parent :imports, workbench
end
crumb :organisation do |organisation|
- link organisation.name, organisation_path(organisation)
+ link breadcrumb_name(organisation), organisation_path(organisation)
end
crumb :compliance_control_sets do
@@ -101,12 +101,12 @@ crumb :compliance_control_sets do
end
crumb :compliance_control_set do |compliance_control_set|
- link compliance_control_set.name, compliance_control_set_path(compliance_control_set)
+ link breadcrumb_name(compliance_control_set), compliance_control_set_path(compliance_control_set)
parent :compliance_control_sets
end
crumb :compliance_control do |compliance_control|
- link compliance_control.name, compliance_control_set_compliance_control_path(compliance_control.compliance_control_set, compliance_control)
+ link breadcrumb_name(compliance_control), compliance_control_set_compliance_control_path(compliance_control.compliance_control_set, compliance_control)
parent :compliance_control_set, compliance_control.compliance_control_set
end
@@ -120,7 +120,7 @@ crumb :stop_areas do |stop_area_referential|
end
crumb :stop_area do |stop_area_referential, stop_area|
- link stop_area.name, stop_area_referential_stop_area_path(stop_area_referential, stop_area)
+ link breadcrumb_name(stop_area), stop_area_referential_stop_area_path(stop_area_referential, stop_area)
parent :stop_areas, stop_area_referential
end
@@ -134,7 +134,7 @@ crumb :companies do |line_referential|
end
crumb :company do |company|
- link company.name, line_referential_company_path(company.line_referential, company)
+ link breadcrumb_name(company), line_referential_company_path(company.line_referential, company)
parent :companies, company.line_referential
end
@@ -144,7 +144,7 @@ crumb :networks do |line_referential|
end
crumb :network do |network|
- link network.name, line_referential_network_path(network.line_referential, network)
+ link breadcrumb_name(network), line_referential_network_path(network.line_referential, network)
parent :networks, network.line_referential
end
@@ -154,7 +154,7 @@ crumb :group_of_lines do |line_referential|
end
crumb :group_of_line do |group_of_line|
- link group_of_line.name, line_referential_group_of_line_path(group_of_line.line_referential, group_of_line)
+ link breadcrumb_name(group_of_line), line_referential_group_of_line_path(group_of_line.line_referential, group_of_line)
parent :group_of_lines, group_of_line.line_referential
end
@@ -164,7 +164,7 @@ crumb :lines do |line_referential|
end
crumb :line do |line|
- link line.name, line_referential_line_path(line.line_referential, line)
+ link breadcrumb_name(line), line_referential_line_path(line.line_referential, line)
parent :lines, line.line_referential
end
@@ -173,17 +173,17 @@ crumb :calendars do
end
crumb :calendar do |calendar|
- link calendar.name, calendar_path(calendar)
+ link breadcrumb_name(calendar), calendar_path(calendar)
parent :calendars
end
crumb :referential_line do |referential, line|
- link line.name, referential_line_path(referential, line)
+ link breadcrumb_name(line), referential_line_path(referential, line)
parent :referential, referential
end
crumb :line_footnotes do |referential, line|
- link line.name, referential_line_footnotes_path(referential, line)
+ link breadcrumb_name(line), referential_line_footnotes_path(referential, line)
parent :referential_line, referential, line
end
@@ -193,7 +193,7 @@ crumb :routing_constraint_zones do |referential, line|
end
crumb :routing_constraint_zone do |referential, line, routing_constraint_zone|
- link routing_constraint_zone.name, referential_line_routing_constraint_zone_path(referential, line, routing_constraint_zone)
+ link breadcrumb_name(routing_constraint_zone), referential_line_routing_constraint_zone_path(referential, line, routing_constraint_zone)
parent :routing_constraint_zones, referential, line
end
@@ -213,7 +213,7 @@ crumb :referential_stop_areas do |referential|
end
crumb :referential_stop_area do |referential, stop_area|
- link stop_area.name, referential_stop_area_path(referential, stop_area)
+ link breadcrumb_name(stop_area), referential_stop_area_path(referential, stop_area)
parent :referential_stop_areas, referential
end
--
cgit v1.2.3
From 1f68a5401ff63d568ba8fbecd3c3ab06335f91e7 Mon Sep 17 00:00:00 2001
From: Xinhui
Date: Tue, 7 Nov 2017 15:57:15 +0100
Subject: Add missing breadcrumb on edit page
---
app/views/companies/edit.html.slim | 4 +++-
app/views/compliance_controls/edit.html.slim | 2 ++
app/views/lines/edit.html.slim | 4 +++-
app/views/referential_companies/edit.html.slim | 4 +++-
app/views/referential_group_of_lines/edit.html.slim | 4 +++-
app/views/route_sections/edit.html.slim | 4 +++-
6 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/app/views/companies/edit.html.slim b/app/views/companies/edit.html.slim
index 6c415edfb..2f4c559b9 100644
--- a/app/views/companies/edit.html.slim
+++ b/app/views/companies/edit.html.slim
@@ -1,2 +1,4 @@
+- breadcrumb :company, @company
+
= title_tag t('companies.edit.title', company: @company.name)
-= render 'form'
\ No newline at end of file
+= render 'form'
diff --git a/app/views/compliance_controls/edit.html.slim b/app/views/compliance_controls/edit.html.slim
index 1d478e845..192e3521f 100644
--- a/app/views/compliance_controls/edit.html.slim
+++ b/app/views/compliance_controls/edit.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :compliance_control, @compliance_control
+
= pageheader 'jeux-de-controle',
t('compliance_controls.edit.title')
diff --git a/app/views/lines/edit.html.slim b/app/views/lines/edit.html.slim
index 0036d023b..3c2eee03f 100644
--- a/app/views/lines/edit.html.slim
+++ b/app/views/lines/edit.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :line, @line
+
= title_tag t('lines.edit.title', line: @line.name)
-= render 'form'
\ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_companies/edit.html.slim b/app/views/referential_companies/edit.html.slim
index 6c415edfb..d191d2a37 100644
--- a/app/views/referential_companies/edit.html.slim
+++ b/app/views/referential_companies/edit.html.slim
@@ -1,2 +1,4 @@
+- breadcrumb :referential_company, @referential, @company
+
= title_tag t('companies.edit.title', company: @company.name)
-= render 'form'
\ No newline at end of file
+= render 'form'
diff --git a/app/views/referential_group_of_lines/edit.html.slim b/app/views/referential_group_of_lines/edit.html.slim
index 75d530b08..34383de39 100644
--- a/app/views/referential_group_of_lines/edit.html.slim
+++ b/app/views/referential_group_of_lines/edit.html.slim
@@ -1,3 +1,5 @@
+- breadcrumb :referential_group_of_line, @referential, @group_of_line
+
= title_tag t('group_of_lines.edit.title', :group_of_line => @group_of_line.name)
-= render 'form'
\ No newline at end of file
+= render 'form'
diff --git a/app/views/route_sections/edit.html.slim b/app/views/route_sections/edit.html.slim
index 15944fd75..7c95def73 100644
--- a/app/views/route_sections/edit.html.slim
+++ b/app/views/route_sections/edit.html.slim
@@ -1,4 +1,6 @@
+- breadcrumb :referential_route_section, @referential, @route_section
+
= title_tag t('route_sections.edit.title')
= @map.to_html if @map
-== render 'form'
\ No newline at end of file
+== render 'form'
--
cgit v1.2.3