aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorRobert2017-11-06 19:06:57 +0100
committerRobert2017-11-17 14:56:29 +0100
commit76d11c7f973867e305d6841f69c62c5fd37d65a7 (patch)
tree782bf6b84fae75a0645e2de341d1c6469d0b9f23 /app
parent36fec435004e595e2adbac72c8f634891a531b01 (diff)
downloadchouette-core-76d11c7f973867e305d6841f69c62c5fd37d65a7.tar.bz2
Refs: #4283@16h;
- Implements the view Missing: - Spex failing (xpath navigation inside the display blocks is still faulty) - Links to compliance_checks#show do not work (actually not this page's problem)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/compliance_check_sets_controller.rb30
-rw-r--r--app/controllers/compliance_control_sets_controller.rb25
-rw-r--r--app/decorators/compliance_check_decorator.rb8
-rw-r--r--app/helpers/compliance_check_blocks_helper.rb3
-rw-r--r--app/helpers/compliance_check_sets_helper.rb12
-rw-r--r--app/helpers/compliance_control_blocks_helper.rb2
-rw-r--r--app/helpers/transport_mode_helper.rb16
-rw-r--r--app/models/compliance_check_block.rb8
-rw-r--r--app/models/organisation.rb1
-rw-r--r--app/views/compliance_check_sets/show.html.slim54
-rw-r--r--app/views/compliance_checks/_filters.html.slim47
-rw-r--r--app/views/compliance_control_sets/show.html.slim17
-rw-r--r--app/views/compliance_controls/_filters.html.slim3
13 files changed, 203 insertions, 23 deletions
diff --git a/app/controllers/compliance_check_sets_controller.rb b/app/controllers/compliance_check_sets_controller.rb
index 95dcfbf05..56d1b9f1f 100644
--- a/app/controllers/compliance_check_sets_controller.rb
+++ b/app/controllers/compliance_check_sets_controller.rb
@@ -18,4 +18,34 @@ class ComplianceCheckSetsController < InheritedResources::Base
}
end
end
+
+ def show
+ show!(&method(:implement_show))
+ end
+
+
+ private
+
+ # Action Implementation
+ # ---------------------
+ def implement_show format
+ format.html(&method(:implement_show_for_html))
+ end
+
+ def implement_show_for_html _mime_response
+ @q_checks_form = @compliance_check_set.compliance_checks.ransack(params[:q])
+ @compliance_check_set = @compliance_check_set.decorate
+ @compliance_checks =
+ decorate_compliance_checks( @q_checks_form.result)
+ .group_by(&:compliance_check_block)
+ @direct_compliance_checks = @compliance_checks.delete nil
+ end
+
+ # Decoration
+ # ----------
+ def decorate_compliance_checks(compliance_checks)
+ ModelDecorator.decorate(
+ compliance_checks,
+ with: ComplianceCheckDecorator)
+ end
end
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index 5c78d09e3..65aa1e81f 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -16,18 +16,10 @@ class ComplianceControlSetsController < InheritedResources::Base
end
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 =
- decorate_compliance_controls( @q_controls_form.result)
- .group_by(&:compliance_control_block)
- @indirect_compliance_controls = @compliance_controls.delete nil
- }
- end
+ show!(&method(:implement_show))
end
+
def clone
ComplianceControlSetCloner.new.copy(params[:id], current_organisation.id)
flash[:notice] = I18n.t("compliance_control_sets.errors.operation_in_progress")
@@ -59,4 +51,17 @@ class ComplianceControlSetsController < InheritedResources::Base
def compliance_control_set_params
params.require(:compliance_control_set).permit(:name, :id)
end
+
+ def implement_show format
+ format.html(&method(:implement_show_for_html))
+ end
+
+ def implement_show_for_html _mime_response
+ @q_controls_form = @compliance_control_set.compliance_controls.ransack(params[:q])
+ @compliance_control_set = @compliance_control_set.decorate
+ @compliance_controls =
+ decorate_compliance_controls( @q_controls_form.result)
+ .group_by(&:compliance_control_block)
+ @direct_compliance_controls = @compliance_controls.delete nil
+ end
end
diff --git a/app/decorators/compliance_check_decorator.rb b/app/decorators/compliance_check_decorator.rb
new file mode 100644
index 000000000..09984aa2e
--- /dev/null
+++ b/app/decorators/compliance_check_decorator.rb
@@ -0,0 +1,8 @@
+class ComplianceCheckDecorator < Draper::Decorator
+ delegate_all
+
+ def action_links
+ links = []
+ end
+
+end
diff --git a/app/helpers/compliance_check_blocks_helper.rb b/app/helpers/compliance_check_blocks_helper.rb
new file mode 100644
index 000000000..b4d858b07
--- /dev/null
+++ b/app/helpers/compliance_check_blocks_helper.rb
@@ -0,0 +1,3 @@
+module ComplianceCheckBlocksHelper
+ include TransportModeHelper
+end
diff --git a/app/helpers/compliance_check_sets_helper.rb b/app/helpers/compliance_check_sets_helper.rb
new file mode 100644
index 000000000..349ecae87
--- /dev/null
+++ b/app/helpers/compliance_check_sets_helper.rb
@@ -0,0 +1,12 @@
+module ComplianceCheckSetsHelper
+ def compliance_check_set_path(compliance_check_set)
+ workbench_compliance_check_set_path(compliance_check_set.workbench, compliance_check_set)
+ end
+
+ def compliance_check_path(compliance_check)
+ workbench_compliance_check_set_compliance_check_path(
+ compliance_check.compliance_check_set.workbench,
+ compliance_check.compliance_check_set,
+ compliance_check)
+ end
+end
diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb
index 311e6fb46..b53ac17ae 100644
--- a/app/helpers/compliance_control_blocks_helper.rb
+++ b/app/helpers/compliance_control_blocks_helper.rb
@@ -1,5 +1,5 @@
module ComplianceControlBlocksHelper
- def transport_mode(transport_mode, transport_submode)
+ def compliance_transport_mode(transport_mode, transport_submode)
return "[Tous les modes de transport]" if transport_mode == ""
if transport_submode == ""
"[" + t("enumerize.transport_mode.#{transport_mode}") + "]"
diff --git a/app/helpers/transport_mode_helper.rb b/app/helpers/transport_mode_helper.rb
new file mode 100644
index 000000000..b61057205
--- /dev/null
+++ b/app/helpers/transport_mode_helper.rb
@@ -0,0 +1,16 @@
+module TransportModeHelper
+ def transport_mode_text(transport_modable=nil)
+ mode = transport_modable.try(:transport_mode)
+ return "[Tous les modes de transport]" if mode.blank?
+
+ submode = transport_modable.try(:transport_submode)
+ [translated_mode_name(:mode, mode), translated_mode_name(:submode, submode)].join
+ end
+
+ private
+ def translated_mode_name mode_type, value
+ return "" if value.blank?
+ "[#{t("enumerize.transport_#{mode_type}.#{value}")}]"
+ end
+
+end
diff --git a/app/models/compliance_check_block.rb b/app/models/compliance_check_block.rb
index ee60a8bb1..eb4654756 100644
--- a/app/models/compliance_check_block.rb
+++ b/app/models/compliance_check_block.rb
@@ -1,5 +1,13 @@
class ComplianceCheckBlock < ActiveRecord::Base
+ extend StifTransportModeEnumerations
+ extend StifTransportSubmodeEnumerations
+
belongs_to :compliance_check_set
has_many :compliance_checks
+
+ hstore_accessor :condition_attributes,
+ transport_mode: :string,
+ transport_submode: :string
+
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index b0c0692da..f6fba2d67 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -55,6 +55,7 @@ class Organisation < ActiveRecord::Base
organisation_referential = referentials.find_by id: referential_id
return organisation_referential if organisation_referential
+ # TODO: Replace each with find
workbenches.each do |workbench|
workbench_referential = workbench.all_referentials.find_by id: referential_id
return workbench_referential if workbench_referential
diff --git a/app/views/compliance_check_sets/show.html.slim b/app/views/compliance_check_sets/show.html.slim
index eefa5363f..4052707da 100644
--- a/app/views/compliance_check_sets/show.html.slim
+++ b/app/views/compliance_check_sets/show.html.slim
@@ -1,12 +1,60 @@
- breadcrumb :compliance_check_set, @workbench, @compliance_check_set
/ PageHeader
= pageheader 'jeux-de-donnees',
- @compliance_check_set.referential.name
+ t('compliance_check_sets.show.title', name: @compliance_check_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'),
- ComplianceCheckSet.human_attribute_name(:id) => @compliance_check_set.referential.id,
- ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.referential.name
+ ComplianceCheckSet.human_attribute_name(:name) => @compliance_check_set.name
+
+ - if params[:q].present? || @compliance_checks.any? || @direct_compliance_checks
+ .row
+ .col-lg-12
+ h2
+ = render '/compliance_checks/filters'
+
+ - if @direct_compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text()
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @direct_compliance_checks,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :code, \
+ attribute: 'code' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_check| \
+ compliance_check_path(compliance_check) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :criticity, \
+ attribute: 'criticity' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :comment, \
+ attribute: 'comment' \
+ ), \
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search',
+ model: ComplianceCheck
+
+ - @compliance_checks.each do |block, compliance_checks|
+
+ - if compliance_checks.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text(block)
diff --git a/app/views/compliance_checks/_filters.html.slim b/app/views/compliance_checks/_filters.html.slim
new file mode 100644
index 000000000..189e3d787
--- /dev/null
+++ b/app/views/compliance_checks/_filters.html.slim
@@ -0,0 +1,47 @@
+/ Compliance Check Filter
+= search_form_for @q_checks_form,
+ url: compliance_check_set_path(@compliance_check_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_checks.filters.name')
+ span.input-group-btn
+ button.btn.btn-default type='submit'
+ span.fa.fa-search
+
+ .ffg-row
+ .form-group.togglable#compliance_check_block-filter
+ = f.label t('activerecord.models.compliance_check_block.one'), required: false, class: 'control-label'
+ = f.input :compliance_check_block_id_eq_any,
+ collection: @compliance_check_set.compliance_check_blocks,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{transport_mode_text(w)}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#subclass-filter
+ = f.label t('compliance_checks.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| ("<span>#{w.first}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+ .form-group.togglable#severity-filter
+ = f.label t('compliance_checks.filters.criticity'), required: false, class: 'control-label'
+ = f.input :criticity_eq_any,
+ collection: ComplianceControl.criticities,
+ as: :check_boxes,
+ label: false,
+ label_method: lambda {|w| ("<span>#{w}</span>").html_safe},
+ required: false,
+ wrapper_html: {class: 'checkbox_list'}
+
+ .actions
+ = link_to t('actions.erase'), @compliance_check_set, class: 'btn btn-link'
+ = f.submit t('actions.filter'), class: 'btn btn-default', id: 'compliance_check_set_compliance_checks_filter_btn'
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index 2bd663578..12be42ea6 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -25,21 +25,22 @@
= definition_list t('metadatas'),
ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name,
I18n.t('activerecord.attributes.compliance_control_set.owner_jdc') => @compliance_control_set.organisation.name
- - if params[:q].present? or @compliance_controls.any?
+
+ - if params[:q].present? || @compliance_controls.any? || @direct_compliance_controls
.row
.col-lg-12
= render '/compliance_controls/filters'
- .row
- .col-lg-12
- h2
- = transport_mode("", "")
- - if @indirect_compliance_controls.try(:any?)
+ - if @direct_compliance_controls.try(:any?)
+ .row
+ .col-lg-12
+ h2
+ = transport_mode_text()
.row
.col-lg-12
.select_table
- = table_builder_2 @indirect_compliance_controls,
+ = table_builder_2 @direct_compliance_controls,
[ \
TableBuilderHelper::Column.new( \
key: :code, \
@@ -71,7 +72,7 @@
.row
.col-lg-12
h2
- = transport_mode(block.transport_mode, block.transport_submode)
+ = transport_mode_text(block)
.btn-group
.btn.dropdown-toggle{ data-toggle="dropdown" }
.span.fa.fa-cog
diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim
index c729190a0..d38da5d2d 100644
--- a/app/views/compliance_controls/_filters.html.slim
+++ b/app/views/compliance_controls/_filters.html.slim
@@ -1,3 +1,4 @@
+/ Compliance Control Filter
= search_form_for @q_controls_form,
url: compliance_control_set_path(@compliance_control_set),
builder: SimpleForm::FormBuilder,
@@ -19,7 +20,7 @@
collection: @compliance_control_set.compliance_control_blocks,
as: :check_boxes,
label: false,
- label_method: lambda {|w| ("<span>#{transport_mode(w.transport_mode, w.transport_submode)}</span>").html_safe},
+ label_method: lambda {|w| ("<span>#{transport_mode_text(w)}</span>").html_safe},
required: false,
wrapper_html: {class: 'checkbox_list'}
.form-group.togglable#subclass-filter