From a62e9fe6d2f8e34054006bcf75fa39f1430361f5 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 7 Feb 2020 15:33:47 +0100 Subject: [PATCH] Extract type de champ line --- .../_show.html.haml | 26 +++---------------- .../_type_champ_line.html.haml | 22 ++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 app/views/fields/types_de_champ_collection_field/_type_champ_line.html.haml diff --git a/app/views/fields/types_de_champ_collection_field/_show.html.haml b/app/views/fields/types_de_champ_collection_field/_show.html.haml index f70d88c66..b0eda814f 100644 --- a/app/views/fields/types_de_champ_collection_field/_show.html.haml +++ b/app/views/fields/types_de_champ_collection_field/_show.html.haml @@ -7,28 +7,8 @@ %td.cell-label Rempli %td.cell-label Modifier le modèle %tbody - - field.data.order(:order_place).each do |f| - %tr - %td.cell-data - = f.libelle - - if f.mandatory? - %span.mandatory{ style: 'color: #A10005;' } * - %td.cell-data - = I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}") - - %td.cell-data - - if f.blank? - vide - - else - rempli - - %td.cell-data - - if f.type_champ == 'piece_justificative' - = form_for f, - url: change_piece_justificative_template_manager_procedure_path, - method: :post do |form| - = form.hidden_field :id - = form.file_field :piece_justificative_template - = form.submit 'modifier' + - field.data.order(:order_place).each do |type_de_champ| + = render partial: 'fields/types_de_champ_collection_field/type_champ_line', + locals: { type_de_champ: type_de_champ } - else Aucun diff --git a/app/views/fields/types_de_champ_collection_field/_type_champ_line.html.haml b/app/views/fields/types_de_champ_collection_field/_type_champ_line.html.haml new file mode 100644 index 000000000..d7421695c --- /dev/null +++ b/app/views/fields/types_de_champ_collection_field/_type_champ_line.html.haml @@ -0,0 +1,22 @@ +%tr + %td.cell-data + = type_de_champ.libelle + - if type_de_champ.mandatory? + %span.mandatory{ style: 'color: #A10005;' } * + %td.cell-data + = I18n.t("activerecord.attributes.type_de_champ.type_champs.#{type_de_champ.type_champ}") + + %td.cell-data + - if type_de_champ.blank? + vide + - else + rempli + + %td.cell-data + - if type_de_champ.type_champ == 'piece_justificative' + = form_for type_de_champ, + url: change_piece_justificative_template_manager_procedure_path, + method: :post do |form| + = form.hidden_field :id + = form.file_field :piece_justificative_template + = form.submit 'modifier'