From e49ea2d0e0465d62186c693e8fa65b0c91bed30b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 29 Mar 2017 14:38:54 +0200 Subject: [PATCH] PiecesJustificative: add field to set it mandatory small css to align the fields --- .../pieces_justificatives_fields.scss | 3 + .../admin/pieces_justificatives_controller.rb | 2 +- .../pieces_justificatives/_fields.html.haml | 61 ++++++++++--------- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 app/assets/stylesheets/pieces_justificatives_fields.scss diff --git a/app/assets/stylesheets/pieces_justificatives_fields.scss b/app/assets/stylesheets/pieces_justificatives_fields.scss new file mode 100644 index 000000000..12a88199c --- /dev/null +++ b/app/assets/stylesheets/pieces_justificatives_fields.scss @@ -0,0 +1,3 @@ +.pieces_justificatives_fields { + .form-inline > .form-group { vertical-align: top; } +} diff --git a/app/controllers/admin/pieces_justificatives_controller.rb b/app/controllers/admin/pieces_justificatives_controller.rb index c899e3486..0f6d14987 100644 --- a/app/controllers/admin/pieces_justificatives_controller.rb +++ b/app/controllers/admin/pieces_justificatives_controller.rb @@ -25,7 +25,7 @@ class Admin::PiecesJustificativesController < AdminController def update_params params .require(:procedure) - .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :lien_demarche]) + .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :mandatory, :lien_demarche]) end def move_up diff --git a/app/views/admin/pieces_justificatives/_fields.html.haml b/app/views/admin/pieces_justificatives/_fields.html.haml index 7cbdf5a99..82ec1d409 100644 --- a/app/views/admin/pieces_justificatives/_fields.html.haml +++ b/app/views/admin/pieces_justificatives/_fields.html.haml @@ -1,31 +1,36 @@ -= f.fields_for :types_de_piece_justificative, types_de_piece_justificative, remote: true do |ff| - .form-inline - .form-group - %h4 Libellé - = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' - .form-group - %h4 Description - = ff.text_area :description, class: 'form-control description', placeholder: 'Description' - .form-group - %h4 - Lien du formulaire vierge - %small - (optionel) - = ff.url_field :lien_demarche, class: 'form-control', placeholder: 'Lien du document vierge' +.pieces_justificatives_fields + = f.fields_for :types_de_piece_justificative, types_de_piece_justificative, remote: true do |ff| + .form-inline + .form-group + %h4 Libellé + = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' + .form-group + %h4 Description + = ff.text_area :description, class: 'form-control description', placeholder: 'Description' + .form-group + %h4 + Lien du formulaire vierge + %small + (optionel) + = ff.url_field :lien_demarche, class: 'form-control', placeholder: 'Lien du document vierge' + + .form-group + = ff.hidden_field :order_place, value: ff.index + = ff.hidden_field :id + - unless ff.object.id.nil? + .form-group + %br   + = ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) + = ff.object.button_down(index: ff.index, url: move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) + + .form-group + %h4 Obligatoire ? + .center + = ff.check_box :mandatory - .form-group - = ff.hidden_field :order_place, value: ff.index - = ff.hidden_field :id - - unless ff.object.id.nil? .form-group %br   - = ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) - = ff.object.button_down(index: ff.index, url: move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index)) - - - .form-group - %br   - - if ff.object.id.nil? - = f.submit('Ajouter la pièce', class: 'btn btn-success', id: 'add_piece_justificative') - - else - = link_to("", admin_procedure_piece_justificative_path(@procedure, ff.object.id), method: :delete, remote: true, id: "delete_type_de_piece_justificative_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) ) + - if ff.object.id.nil? + = f.submit('Ajouter la pièce', class: 'btn btn-success', id: 'add_piece_justificative') + - else + = link_to("", admin_procedure_piece_justificative_path(@procedure, ff.object.id), method: :delete, remote: true, id: "delete_type_de_piece_justificative_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) )