aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGuillaume2017-09-18 18:06:59 +0200
committerGuillaume2017-09-18 18:06:59 +0200
commit47bc1f0ef1b4c1ba0db0a9e6e75f765dd2c5d88d (patch)
treee9715d2ab0f4c420d43a230eb66410b36eaab64d /app
parent06ad1bb051cabb4575306f7397287ea77d70e109 (diff)
downloadchouette-core-47bc1f0ef1b4c1ba0db0a9e6e75f765dd2c5d88d.tar.bz2
add create/edit for compliance_control_set, add specs
Diffstat (limited to 'app')
-rw-r--r--app/controllers/compliance_control_sets_controller.rb20
-rw-r--r--app/models/compliance_control_set.rb3
-rw-r--r--app/models/organisation.rb1
-rw-r--r--app/views/compliance_control_sets/_form.html.slim49
-rw-r--r--app/views/compliance_control_sets/edit.html.slim2
-rw-r--r--app/views/compliance_control_sets/new.html.slim2
-rw-r--r--app/views/compliance_control_sets/show.html.slim79
7 files changed, 35 insertions, 121 deletions
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
index b0a719cdc..1b23becaa 100644
--- a/app/controllers/compliance_control_sets_controller.rb
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -1,15 +1,20 @@
class ComplianceControlSetsController < BreadcrumbController
-
defaults resource_class: ComplianceControlSet
respond_to :html
def index
- index! do
- @compliance_control_sets = decorate_compliance_control_sets(@compliance_control_sets)
- build_breadcrumb :show
+ index! do |format|
+ format.html {
+ @compliance_control_sets = decorate_compliance_control_sets(@compliance_control_sets)
+ }
end
end
+ def show
+ show! do
+ @compliance_control_set = @compliance_control_set.decorate
+ end
+ end
def decorate_compliance_control_sets(compliance_control_sets)
ModelDecorator.decorate(
@@ -18,4 +23,11 @@ class ComplianceControlSetsController < BreadcrumbController
)
end
+ protected
+
+ private
+
+ def compliance_control_set_params
+ params.require(:compliance_control_set).permit(:name)
+ end
end
diff --git a/app/models/compliance_control_set.rb b/app/models/compliance_control_set.rb
index ca112531d..cefdfbf1f 100644
--- a/app/models/compliance_control_set.rb
+++ b/app/models/compliance_control_set.rb
@@ -1,4 +1,7 @@
class ComplianceControlSet < ActiveRecord::Base
belongs_to :organisation
has_many :compliance_controls
+
+ validates :name, presence: true
+
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 895ca03d9..ba65ad375 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -4,6 +4,7 @@ class Organisation < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_many :referentials, :dependent => :destroy
has_many :rule_parameter_sets, :dependent => :destroy
+ has_many :compliance_control_sets, :dependent => :destroy
has_many :stop_area_referential_memberships
has_many :stop_area_referentials, through: :stop_area_referential_memberships
diff --git a/app/views/compliance_control_sets/_form.html.slim b/app/views/compliance_control_sets/_form.html.slim
index ba14edf41..cf144bbd9 100644
--- a/app/views/compliance_control_sets/_form.html.slim
+++ b/app/views/compliance_control_sets/_form.html.slim
@@ -1,53 +1,8 @@
-= simple_form_for @compliance_control_sets, html: { class: 'form-horizontal', id: 'calendar_form' }, wrapper: :horizontal_form do |f|
+= simple_form_for @compliance_control_set, html: { class: 'form-horizontal', id: 'compliance_control_set_form' }, wrapper: :horizontal_form do |f|
.row
.col-lg-12
= f.input :name
- = f.input :short_name
-
- - if policy(@compliance_control_sets).share?
- .form-group.has_switch
- = f.label :shared, class: 'col-sm-4 col-xs-5 control-label'
- = f.input :shared, as: :boolean, checked_value: true, unchecked_value: false, label: content_tag(:span, t("#{@calendar.shared}"), class: 'switch-label', data: {checkedValue: t('true'), uncheckedValue: t('false')}), wrapper_html: { class: 'col-sm-8 col-xs-7'}
.separator
-
- .row
- .col-lg-12
- .subform
- .nested-head
- .wrapper
- div
- .form-group
- label.control-label
- = Calendar.human_attribute_name(:date)
- div
-
- = f.simple_fields_for :date_values do |date_value|
- = render 'date_value_fields', f: date_value
-
- .links.nested-linker
- = link_to_add_association t('simple_form.labels.calendar.add_a_date'), f, :date_values, class: 'btn btn-outline-primary'
-
- .separator
-
- .row
- .col-lg-12
- .subform
- .nested-head
- .wrapper
- div
- .form-group
- label.control-label
- = t('simple_form.labels.calendar.ranges.begin')
- div
- .form-group
- label.control-label
- = t('simple_form.labels.calendar.ranges.end')
- div
-
- = f.simple_fields_for :periods do |period|
- = render 'period_fields', f: period
- .links.nested-linker
- = link_to_add_association t('simple_form.labels.calendar.add_a_date_range'), f, :periods, class: 'btn btn-outline-primary'
- = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'calendar_form'
+ = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'compliance_control_set_form'
diff --git a/app/views/compliance_control_sets/edit.html.slim b/app/views/compliance_control_sets/edit.html.slim
index 73381be34..a9b8d7253 100644
--- a/app/views/compliance_control_sets/edit.html.slim
+++ b/app/views/compliance_control_sets/edit.html.slim
@@ -7,4 +7,4 @@
.container-fluid
.row
.col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
- /= render 'form'
+ = render 'form'
diff --git a/app/views/compliance_control_sets/new.html.slim b/app/views/compliance_control_sets/new.html.slim
index 93475974a..d6be41ee8 100644
--- a/app/views/compliance_control_sets/new.html.slim
+++ b/app/views/compliance_control_sets/new.html.slim
@@ -8,4 +8,4 @@
.container-fluid
.row
.col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
- /= render 'form'
+ = render 'form'
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index 12ecc1894..b4a5b2260 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -6,77 +6,20 @@
/ Below is secondary actions & optional contents (filters, ...)
.row.mb-sm
.col-lg-12.text-right
- /- @compliance_control_set.action_links.each do |link|
- / - if link.is_a?(HTMLElement)
- / = link.to_html(class: 'btn btn-primary')
- / - else
- / = link_to link.href,
- / method: link.method,
- / data: link.data,
- / class: 'btn btn-primary' do
- / = link.content
+ - @compliance_control_set.action_links.each do |link|
+ - if link.is_a?(HTMLElement)
+ = link.to_html(class: 'btn btn-primary')
+ - else
+ = link_to link.href,
+ method: link.method,
+ data: link.data,
+ class: 'btn btn-primary' do
+ = link.content
/ PageContent
.page_content
.container-fluid
.row
.col-lg-6.col-md-6.col-sm-12.col-xs-12
- /= definition_list t('metadatas'),
- / { t('activerecord.attributes.referential.status') => @referential.archived? ? "<div class='td-block'><span class='fa fa-archive'></span><span>#{t('activerecord.attributes.referential.archived_at')}</span></div>".html_safe : "<div class='td-block'><span class='sb sb-lg sb-preparing'></span><span>#{t('activerecord.attributes.referential.archived_at_null')}</span></div>".html_safe,
- / @referential.human_attribute_name(:validity_period) => (@referential.validity_period.present? ? t('validity_range', debut: l(@referential.try(:validity_period).try(:begin), format: :short), end: l(@referential.try(:validity_period).try(:end), format: :short)) : '-'),
- / @referential.human_attribute_name(:organisation) => @referential.organisation.name,
- / @referential.human_attribute_name(:published_at) => '-' }
-
- /- if params[:q].present? or @reflines.any?
- .row
- .col-lg-12
- /= render 'filters'
-
- /- if @reflines.any?
- .row
- .col-lg-12
- / ID Codif, nom court, nom de la ligne, réseau, mode, transporteur principal, actions = [show, edit_notes]
- = table_builder_2 @reflines,
- [ \
- TableBuilderHelper::Column.new( \
- name: t('id_codif'), \
- attribute: Proc.new { |n| n.objectid.local_id }, \
- sortable: false \
- ), \
- TableBuilderHelper::Column.new( \
- key: :number, \
- attribute: 'number' \
- ), \
- TableBuilderHelper::Column.new( \
- key: :name, \
- attribute: 'name', \
- link_to: lambda do |line| \
- referential_line_path(@referential, line) \
- end \
- ), \
- TableBuilderHelper::Column.new( \
- key: :deactivated, \
- attribute: Proc.new { |n| n.deactivated? ? t('false') : t('true') } \
- ), \
- TableBuilderHelper::Column.new( \
- key: :transport_mode, \
- attribute: Proc.new { |n| n.transport_mode ? t("enumerize.line.transport_mode.#{n.transport_mode}") : '' }, \
- ), \
- TableBuilderHelper::Column.new( \
- key: 'networks.name', \
- attribute: Proc.new { |n| n.try(:network).try(:name) } \
- ), \
- TableBuilderHelper::Column.new( \
- key: 'companies.name', \
- attribute: Proc.new { |n| n.try(:company).try(:name) } \
- ) \
- ],
- links: [:show],
- cls: 'table has-filter has-search'
-
- = new_pagination @reflines, 'pull-right'
-
- /- unless @reflines.any?
- .row.mt-xs
- .col-lg-12
- = replacement_msg t('referential_lines.search_no_results') \ No newline at end of file
+ = definition_list t('metadatas'),
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name \ No newline at end of file