diff options
| -rw-r--r-- | app/controllers/compliance_control_sets_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 10 | ||||
| -rw-r--r-- | app/decorators/referential_decorator.rb | 6 | ||||
| -rw-r--r-- | app/policies/referential_policy.rb | 6 | ||||
| -rw-r--r-- | app/views/compliance_control_sets/select_compliance_control_set.html.slim | 27 | ||||
| -rw-r--r-- | app/views/referentials/select_compliance_control_set.html.slim | 20 | ||||
| -rw-r--r-- | config/locales/referentials.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/referentials.fr.yml | 3 | ||||
| -rw-r--r-- | config/routes.rb | 3 | 
9 files changed, 42 insertions, 38 deletions
| diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb index cff67d5cb..b45e85d49 100644 --- a/app/controllers/compliance_control_sets_controller.rb +++ b/app/controllers/compliance_control_sets_controller.rb @@ -33,10 +33,6 @@ class ComplianceControlSetsController < InheritedResources::Base      redirect_to(compliance_control_sets_path)    end -  def select_compliance_control_set -    @compliance_control_sets = ComplianceControlSet.all -  end -    protected    def begin_of_association_chain diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 6b479e938..b08f58514 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -54,6 +54,16 @@ class ReferentialsController < InheritedResources::Base      end    end +  def select_compliance_control_set +    @compliance_control_sets = ComplianceControlSet.all +  end + +  def validate +    ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) +    flash[:notice] = I18n.t("referentials.operation_in_progress") +    redirect_to(referential_path) +  end +    def destroy      workbench = referential.workbench_id diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb index 3876d966d..4103790aa 100644 --- a/app/decorators/referential_decorator.rb +++ b/app/decorators/referential_decorator.rb @@ -17,12 +17,12 @@ class ReferentialDecorator < Draper::Decorator        )      end -    # if policy.validate? +    if policy.validate?        links << Link.new(          content: h.t('actions.validate'), -        href: h.compliance_control_set_select_compliance_control_set_path(object.id, referential_id: context[:referential_id]) +        href: h.referential_select_compliance_control_set_path(object.id)        ) -    # end +    end      if policy.archive?        links << Link.new( diff --git a/app/policies/referential_policy.rb b/app/policies/referential_policy.rb index fdc80516c..bc8a3e24b 100644 --- a/app/policies/referential_policy.rb +++ b/app/policies/referential_policy.rb @@ -17,12 +17,14 @@ class ReferentialPolicy < ApplicationPolicy      !archived? && organisation_match? && user.has_permission?('referentials.update')    end - -    def clone?      !archived? && create?    end +  def validate? +    !archived? && create? +  end +    def archive?      record.archived_at.nil? && organisation_match? && user.has_permission?('referentials.update')    end diff --git a/app/views/compliance_control_sets/select_compliance_control_set.html.slim b/app/views/compliance_control_sets/select_compliance_control_set.html.slim deleted file mode 100644 index 4b76fdac2..000000000 --- a/app/views/compliance_control_sets/select_compliance_control_set.html.slim +++ /dev/null @@ -1,27 +0,0 @@ -/ PageHeader -- header_params = ['jeux-de-controle', -        t('referentials.select_jdc.title'), -        ''] -= pageheader(*header_params) do - -/ PageContent -.page_content -  .container-fluid -    .row -      .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 -        = form_tag '#', {class: 'form-horizontal', id: 'select_compliance_control_set', wrapper: :horizontal_form} do -          .row -            .col-lg-12 -              .form-group -                = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label' -                .col-sm-8.col-xs-7 -                  = select_tag :name, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control' -              .separator -        = button_tag t('actions.submit'), class: 'btn btn-default formSubmitr' - - -        /= simple_form_for @compliance_control_sets, html: { class: 'form-horizontal', id: 'select_compliance_control_set' }, wrapper: :horizontal_form do |f| -        /  .row -        /    .col-lg-12 -        /      = f.association :compliance_control_set, collection: @compliance_control_sets, label_method: lambda {@compliance_control_sets.name} -        /= f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'select_compliance_control_set' diff --git a/app/views/referentials/select_compliance_control_set.html.slim b/app/views/referentials/select_compliance_control_set.html.slim new file mode 100644 index 000000000..2d3f2344c --- /dev/null +++ b/app/views/referentials/select_compliance_control_set.html.slim @@ -0,0 +1,20 @@ +/ PageHeader +- header_params = ['jeux-de-controle', +        t('referentials.select_compliance_control_set.title'), +        ''] += pageheader(*header_params) do + +/ PageContent +.page_content +  .container-fluid +    .row +      .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1 +        = form_tag validate_referential_path(params[:referential_id]), {class: 'form-horizontal', id: 'select_compliance_control_set', wrapper: :horizontal_form} do +          .row +            .col-lg-12 +              .form-group +                = label_tag 'name', nil, class: 'string required col-sm-4 col-xs-5 control-label' +                .col-sm-8.col-xs-7 +                  = select_tag :compliance_control_set, options_from_collection_for_select(@compliance_control_sets, "id", "name"), class: 'select optional form-control' +              .separator +        = button_tag t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'select_compliance_control_set'
\ No newline at end of file diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml index 844e4a570..5b9f69072 100644 --- a/config/locales/referentials.en.yml +++ b/config/locales/referentials.en.yml @@ -5,6 +5,7 @@ en:        name: 'Search by name'        line: 'Seach by associated lines'      search_no_results: 'No data space matching your query' +    operation_in_progress: The validation process is in progress      error_period_filter: "The period filter must have valid bounding dates"      index:        title: 'Data spaces' diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml index 285db3d3f..b27bbcbfb 100644 --- a/config/locales/referentials.fr.yml +++ b/config/locales/referentials.fr.yml @@ -5,6 +5,7 @@ fr:        name: 'Indiquez un nom de référentiel...'        line: 'Indiquez une ligne...'      search_no_results: 'Aucun jeu de données ne correspond à votre recherche' +    operation_in_progress: L'opération de validation est en cours      error_period_filter: "Le filtre par période doit contenir une date de début et de fin valides"      index:        title: 'Jeux de données' @@ -31,7 +32,7 @@ fr:        duplicated:          title: 'Dupliquer un jeu de données'        submit: "Valider" -    select_jdc: +    select_compliance_control_set:        title: "Sélection du jeu de contôle"      actions:        new: "Créer un jeu de données" diff --git a/config/routes.rb b/config/routes.rb index 30ba51358..2f332b2c9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,7 +76,6 @@ ChouetteIhm::Application.routes.draw do    resources :compliance_control_sets do      get :simple, on: :member      get :clone, on: :member -    get :select_compliance_control_set      resources :compliance_controls, except: :index do        get :select_type, on: :collection      end @@ -104,6 +103,8 @@ ChouetteIhm::Application.routes.draw do      resources :autocomplete_stop_areas, only: [:show, :index] do        get 'around', on: :member      end +    get :select_compliance_control_set +    post :validate, on: :member      resources :autocomplete_time_tables, only: [:index]      resources :autocomplete_route_sections      resources :autocomplete_timebands | 
