From ec0092fb3c39334a56ed96f50e79304aab3b01e7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 13 Mar 2017 15:01:41 +0100 Subject: [PATCH 01/17] Cleaning --- .../description/champs/_header_section.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/users/description/champs/_header_section.html.haml b/app/views/users/description/champs/_header_section.html.haml index b2d4662d0..cc2c1099f 100644 --- a/app/views/users/description/champs/_header_section.html.haml +++ b/app/views/users/description/champs/_header_section.html.haml @@ -1,9 +1,9 @@ .default_data_block.default_visible - %div.row.show-block.infos - %div.header - %div.col-lg-12.col-md-12.col-sm-12.col-xs-12.title - %div.carret-right - %div.carret-down + .row.show-block.infos + .header + .col-xs-12.title + .carret-right + .carret-down =libelle - %div.body - = render partial: 'users/description/champs/render_list_champs', locals: {champs: champs, order_place: order_place} \ No newline at end of file + .body + = render partial: 'users/description/champs/render_list_champs', locals: {champs: champs, order_place: order_place} From 176092c256c3f4bf9373ff90c93ba227a97de9ce Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 13 Mar 2017 15:02:05 +0100 Subject: [PATCH 02/17] Explication: add field and template --- app/models/type_de_champ.rb | 3 ++- .../users/description/champs/_render_list_champs.html.haml | 2 ++ config/locales/models/type_de_champ/fr.yml | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 9d1b2e693..19f263860 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -16,7 +16,8 @@ class TypeDeChamp < ActiveRecord::Base regions: 'regions', departements: 'departements', engagement: 'engagement', - header_section: 'header_section' + header_section: 'header_section', + explication: 'explication' } belongs_to :procedure diff --git a/app/views/users/description/champs/_render_list_champs.html.haml b/app/views/users/description/champs/_render_list_champs.html.haml index 261ef88e1..d219efa78 100644 --- a/app/views/users/description/champs/_render_list_champs.html.haml +++ b/app/views/users/description/champs/_render_list_champs.html.haml @@ -41,6 +41,8 @@ - elsif champ.type_champ == 'departements' = render partial: 'users/description/champs/departements', locals: { champ: champ } + - elsif champ.type_champ == 'explication' + - else %input.form-control{name:"champs['#{ champ.id }']", placeholder: champ.libelle, diff --git a/config/locales/models/type_de_champ/fr.yml b/config/locales/models/type_de_champ/fr.yml index 83d87828b..0e42fa98f 100644 --- a/config/locales/models/type_de_champ/fr.yml +++ b/config/locales/models/type_de_champ/fr.yml @@ -21,4 +21,5 @@ fr: regions: 'Régions' departements: 'Départements' engagement: 'Engagement' - header_section: 'Titre de section' \ No newline at end of file + header_section: 'Titre de section' + explication: 'Explication' From fcca0bb247347e88ca9c986e66fae93637956f63 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 14 Mar 2017 13:54:31 +0100 Subject: [PATCH 03/17] Cleaning --- app/views/dossiers/_infos_dossier.html.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index afe71a442..085d0b991 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -1,5 +1,5 @@ %div.row - .col-lg-12.col-md-12.col-sm-12.col-xs-12 + .col-xs-12 - if @facade.procedure.for_individual? .row.title-row %div.col-xs-4.split-hr @@ -7,19 +7,19 @@ %div.col-xs-4.split-hr .row %div.col-xs-6.depositaire-label Civilité - %div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + %div.col-xs-1.comments-off= "-" %div.col-xs-5.depositaire-info= @facade.individual.gender .row %div.col-xs-6.depositaire-label Nom - %div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + %div.col-xs-1.comments-off= "-" %div.col-xs-5.depositaire-info= @facade.individual.nom .row %div.col-xs-6.depositaire-label Prénom - %div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + %div.col-xs-1.comments-off= "-" %div.col-xs-5.despositaire-info= @facade.individual.prenom .row %div.col-xs-6.depositaire-label Date de naissance - %div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + %div.col-xs-1.comments-off= "-" %div.col-xs-5.depositaire-info= @facade.individual.birthdate .row.margin-top-20 From d250cafccc7ed53c9243ced2a911d6fa60e74158 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 14 Mar 2017 13:58:21 +0100 Subject: [PATCH 04/17] Explication: add champ in edit formulaire --- app/assets/javascripts/admin.js | 8 +++++--- app/models/type_de_champ.rb | 6 +++--- .../admin/types_de_champ/_fields.html.haml | 20 ++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 6c2e63536..4b381dbe7 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -23,13 +23,13 @@ function destroy_action(){ } function on_change_type_de_champ_select (){ - $("select.form-control.type_champ").on('change', function(e){ parent = $(this).parent().parent(); parent.removeClass('header_section'); parent.children(".drop_down_list").removeClass('show_inline'); + $('.mandatory', parent).show(); switch(this.value){ case 'header_section': @@ -38,7 +38,9 @@ function on_change_type_de_champ_select (){ case 'drop_down_list': parent.children(".drop_down_list").addClass('show_inline'); break; - + case 'explication': + $('.mandatory', parent).hide(); + break; } - }) + }); } diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 19f263860..64277d606 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -30,7 +30,7 @@ class TypeDeChamp < ActiveRecord::Base validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :type_champ, presence: true, allow_blank: false, allow_nil: false - before_validation :change_header_section_mandatory + before_validation :check_mandatory def self.type_de_champs_list_fr type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] } @@ -40,8 +40,8 @@ class TypeDeChamp < ActiveRecord::Base !(type_champ == 'textarea' || type_champ == 'header_section') end - def change_header_section_mandatory - self.mandatory = false if self.type_champ == 'header_section' + def check_mandatory + self.mandatory = false if %w(header_section explication).include?(self.type_champ) true end end diff --git a/app/views/admin/types_de_champ/_fields.html.haml b/app/views/admin/types_de_champ/_fields.html.haml index 649be960e..37da7585b 100644 --- a/app/views/admin/types_de_champ/_fields.html.haml +++ b/app/views/admin/types_de_champ/_fields.html.haml @@ -1,27 +1,29 @@ = f.fields_for @types_de_champ_facade.fields_for_var, types_de_champ, remote: true do |ff| - .form-inline{class:"#{ff.object.object.type_champ == 'header_section' ? 'header_section' : ''}"} + .form-inline{ class: (ff.object.object.type_champ == 'header_section' ? 'header_section' : '') } .form-group.libelle %h4 Libellé = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' .form-group.type %h4 Type - = ff.select :type_champ, TypeDeChamp.type_de_champs_list_fr, {}, {class: 'form-control type_champ'} + = ff.select :type_champ, TypeDeChamp.type_de_champs_list_fr, {}, { class: 'form-control type_champ' } .form-group.description %h4 Description - = ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 2 + = ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 3 - .form-group.drop_down_list{class:"#{ff.object.object.type_champ == 'drop_down_list' ? 'show_inline' : ''}",style:'margin-right: 5px'} + .form-group.drop_down_list{ class: (ff.object.object.type_champ == 'drop_down_list' ? 'show_inline' : ''), style: 'margin-right: 5px' } %h4 Liste déroulante = ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff| = fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne.\nEcrire --valeur-- pour un séparateur.", rows: 3, cols: 30 = fff.hidden_field :id - - unless ff.object.object.class == TypeDeChampPrivate - .form-group.mandatory - %h4 Obligatoire ? - .center - = ff.check_box :mandatory, placeholder: 'Obligatoire ?' + + + - hide_mandatory = (ff.object.object.class == TypeDeChampPrivate || ff.object.object.type_champ == 'explication') + .form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : '' } + %h4 Obligatoire ? + .center + = ff.check_box :mandatory, placeholder: 'Obligatoire ?' .form-group = ff.hidden_field :order_place, value: ff.index From fb2aef1810135f56f774d69df714ff0bf6189ef9 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 14 Mar 2017 13:58:59 +0100 Subject: [PATCH 05/17] Explication: style in edit page --- .../stylesheets/admin_type_de_champ.scss | 18 +++++++++++++++++- app/decorators/type_de_champ_decorator.rb | 12 ++++++++++-- .../decorators/type_de_champ_decorator_spec.rb | 11 ++++++----- .../types_de_champ/show.html.haml_spec.rb | 10 +++++----- .../show.html.haml_spec.rb | 12 ++++++------ 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/admin_type_de_champ.scss b/app/assets/stylesheets/admin_type_de_champ.scss index e4a9b92e9..bc2613075 100644 --- a/app/assets/stylesheets/admin_type_de_champ.scss +++ b/app/assets/stylesheets/admin_type_de_champ.scss @@ -23,6 +23,10 @@ } #liste_champ{ + .form-inline { + margin-bottom: 30px; + } + .show_inline { display: inline-block !important; } @@ -30,4 +34,16 @@ .form-group.drop_down_list{ display: none; } -} \ No newline at end of file + + .form-group { + vertical-align: top; + margin-right: 15px; + } + + .description { + padding: 0; + textarea { + padding: 6px 12px; + } + } +} diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb index ffe824855..d54293195 100644 --- a/app/decorators/type_de_champ_decorator.rb +++ b/app/decorators/type_de_champ_decorator.rb @@ -3,11 +3,19 @@ class TypeDeChampDecorator < Draper::Decorator delegate_all def button_up params - h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post if display_up_button?(params[:index], params[:private]) + h.link_to '', params[:url], class: up_classes, + id: "btn_up_#{params[:index]}", + remote: true, + method: :post, + style: display_up_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;' end def button_down params - h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post if display_down_button?(params[:index], params[:private]) + h.link_to '', params[:url], class: down_classes, + id: "btn_down_#{params[:index]}", + remote: true, + method: :post, + style: display_down_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;' end private diff --git a/spec/decorators/type_de_champ_decorator_spec.rb b/spec/decorators/type_de_champ_decorator_spec.rb index 7ab455e00..dd5d75307 100644 --- a/spec/decorators/type_de_champ_decorator_spec.rb +++ b/spec/decorators/type_de_champ_decorator_spec.rb @@ -16,8 +16,8 @@ describe TypeDeChampDecorator do subject { type_de_champ_0.decorate } let(:button_up) { type_de_champ_.decorate } - it 'returns a button up' do - expect(subject.button_up(params)).to be(nil) + it 'hide a button up' do + expect(subject.button_up(params)).to include('visibility: hidden') end it 'returns a button down' do expect(subject.button_down(params)).to match(/fa-chevron-down/) @@ -45,11 +45,12 @@ describe TypeDeChampDecorator do it 'returns a button up' do expect(subject.button_up(params)).to match(/fa-chevron-up/) end - it 'returns a button down' do - expect(subject.button_down(params)).to be(nil) + + it 'hide a button down' do + expect(subject.button_down(params)).to include('visibility: hidden') end end end -end \ No newline at end of file +end diff --git a/spec/views/admin/types_de_champ/show.html.haml_spec.rb b/spec/views/admin/types_de_champ/show.html.haml_spec.rb index bed11f3d4..acac3297a 100644 --- a/spec/views/admin/types_de_champ/show.html.haml_spec.rb +++ b/spec/views/admin/types_de_champ/show.html.haml_spec.rb @@ -33,8 +33,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do end context 'when there is only one field in database' do let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } - it { expect(subject).not_to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_down_1') } end @@ -42,9 +42,9 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do let!(:type_de_champ_0) { create(:type_de_champ_public, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ_public, procedure: procedure, order_place: 1) } it { expect(subject).to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).to have_css('#btn_up_1') } - it { expect(subject).not_to have_css('#btn_down_1') } + it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') } end end -end \ No newline at end of file +end diff --git a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb index 829050748..510224e9c 100644 --- a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb +++ b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb @@ -30,7 +30,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do describe 'mandatory checkbox' do it 'no mandatory checkbox are present' do - expect(subject).not_to have_css('.form-group.mandatory') + expect(subject).to have_css('.form-group.mandatory[style*="visibility: hidden"]') end end @@ -41,8 +41,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do end context 'when there is only one field in database' do let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) } - it { expect(subject).not_to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_down_1') } end @@ -50,10 +50,10 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do let!(:type_de_champ_0) { create(:type_de_champ_private, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ_private, procedure: procedure, order_place: 1) } it { expect(subject).to have_css('#btn_down_0') } - it { expect(subject).not_to have_css('#btn_up_0') } + it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') } it { expect(subject).to have_css('#btn_up_1') } - it { expect(subject).not_to have_css('#btn_down_1') } + it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') } end end end -end \ No newline at end of file +end From 7596c2424e639f906fad6ef9d3e839fe318a8ec3 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 14 Mar 2017 13:59:37 +0100 Subject: [PATCH 06/17] Explication: do not show explication in _infos_dossier --- app/views/dossiers/_infos_dossier.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index 085d0b991..4c381e2ee 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -25,6 +25,7 @@ - unless @facade.champs.nil? - @facade.champs.each do |champ| + - next if champ.type_champ == 'explication' - if champ.type_champ == 'header_section' .row.title-row.margin-top-40 %div.col-xs-3.split-hr From 657ce53a604da4e0304ac6771d09a837f4d6eb6a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 17:47:26 +0100 Subject: [PATCH 07/17] select_multiple: add multiple_drop_down_list type --- app/assets/javascripts/admin.js | 1 + app/models/drop_down_list.rb | 15 +++++++- app/models/type_de_champ.rb | 1 + .../admin/types_de_champ/_fields.html.haml | 12 +++--- .../champs/_drop_down_list.html.haml | 2 +- .../champs/_drop_down_template.html.haml | 24 +++--------- .../champs/_render_list_champs.html.haml | 2 +- config/locales/models/type_de_champ/fr.yml | 1 + spec/models/drop_down_list_spec.rb | 37 +++++++++++++++++-- 9 files changed, 66 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 4b381dbe7..967633a7b 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -36,6 +36,7 @@ function on_change_type_de_champ_select (){ parent.addClass('header_section'); break; case 'drop_down_list': + case 'multiple_drop_down_list': parent.children(".drop_down_list").addClass('show_inline'); break; case 'explication': diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index d6e2d3d02..3d82184d1 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -2,6 +2,19 @@ class DropDownList < ActiveRecord::Base belongs_to :type_de_champ def options - value.split(/[\r\n]|[\r]|[\n]|[\n\r]/).reject(&:empty?) + result = value.split(/[\r\n]|[\r]|[\n]|[\n\r]/).reject(&:empty?) + result.blank? ? [] : [''] + result + end + + def disabled_options + options.select{ |v| !(v =~ /^--.*--$/).nil? } + end + + def selected_options(champ) + champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value] + end + + def multiple + type_de_champ.type_champ == 'multiple_drop_down_list' end end diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 64277d606..2dbfb2d90 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -12,6 +12,7 @@ class TypeDeChamp < ActiveRecord::Base address: 'address', yes_no: 'yes_no', drop_down_list: 'drop_down_list', + multiple_drop_down_list: 'multiple_drop_down_list', pays: 'pays', regions: 'regions', departements: 'departements', diff --git a/app/views/admin/types_de_champ/_fields.html.haml b/app/views/admin/types_de_champ/_fields.html.haml index 37da7585b..929f573f6 100644 --- a/app/views/admin/types_de_champ/_fields.html.haml +++ b/app/views/admin/types_de_champ/_fields.html.haml @@ -1,5 +1,7 @@ = f.fields_for @types_de_champ_facade.fields_for_var, types_de_champ, remote: true do |ff| - .form-inline{ class: (ff.object.object.type_champ == 'header_section' ? 'header_section' : '') } + - type_champ = ff.object.object.type_champ + + .form-inline{ class: (type_champ == 'header_section' ? 'header_section' : nil) } .form-group.libelle %h4 Libellé = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' @@ -12,15 +14,15 @@ %h4 Description = ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 3 - .form-group.drop_down_list{ class: (ff.object.object.type_champ == 'drop_down_list' ? 'show_inline' : ''), style: 'margin-right: 5px' } + .form-group.drop_down_list{ class: (%w(drop_down_list multiple_drop_down_list).include?(type_champ) ? 'show_inline' : nil), style: 'margin-right: 5px' } %h4 Liste déroulante = ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff| - = fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne.\nEcrire --valeur-- pour un séparateur.", rows: 3, cols: 30 + ~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne.\nEcrire --valeur-- pour un séparateur.", rows: 3, cols: 30 = fff.hidden_field :id - - hide_mandatory = (ff.object.object.class == TypeDeChampPrivate || ff.object.object.type_champ == 'explication') - .form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : '' } + - hide_mandatory = (ff.object.object.class == TypeDeChampPrivate || type_champ == 'explication') + .form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil } %h4 Obligatoire ? .center = ff.check_box :mandatory, placeholder: 'Obligatoire ?' diff --git a/app/views/users/description/champs/_drop_down_list.html.haml b/app/views/users/description/champs/_drop_down_list.html.haml index e398f6519..1480aff23 100644 --- a/app/views/users/description/champs/_drop_down_list.html.haml +++ b/app/views/users/description/champs/_drop_down_list.html.haml @@ -1,2 +1,2 @@ - unless champ.drop_down_list.nil? - = render partial: 'users/description/champs/drop_down_template', locals: {values: champ.drop_down_list.options, champ: champ} + = render partial: 'users/description/champs/drop_down_template', locals: { drop_down_list: champ.drop_down_list, champ: champ } diff --git a/app/views/users/description/champs/_drop_down_template.html.haml b/app/views/users/description/champs/_drop_down_template.html.haml index e3956e3c1..5ec502745 100644 --- a/app/views/users/description/champs/_drop_down_template.html.haml +++ b/app/views/users/description/champs/_drop_down_template.html.haml @@ -1,18 +1,6 @@ -%select{ name:"champs['#{champ.id}']", - id: "champs_#{champ.id}" } - - - unless values.blank? - %option - = '' - - - values.each do |option| - - if (option=~ /^--.*--$/).nil? - - if champ.value == option - %option{selected:''} - = option - - else - %option - = option - -else - %option{disabled:''} - = option +- unless drop_down_list.options.blank? + = select_tag("champs['#{champ.id}']", + options_for_select(drop_down_list.options, selected: drop_down_list.selected_options(champ), + disabled: drop_down_list.disabled_options), + multiple: drop_down_list.multiple, + class: drop_down_list.multiple ? 'select2' : nil) diff --git a/app/views/users/description/champs/_render_list_champs.html.haml b/app/views/users/description/champs/_render_list_champs.html.haml index d219efa78..1c131361e 100644 --- a/app/views/users/description/champs/_render_list_champs.html.haml +++ b/app/views/users/description/champs/_render_list_champs.html.haml @@ -26,7 +26,7 @@ - elsif champ.type_champ == 'yes_no' = render partial: 'users/description/champs/yes_no', locals: { champ: champ } - - elsif champ.type_champ == 'drop_down_list' + - elsif %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ) = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ } - elsif champ.type_champ == 'pays' diff --git a/config/locales/models/type_de_champ/fr.yml b/config/locales/models/type_de_champ/fr.yml index 0e42fa98f..06206a682 100644 --- a/config/locales/models/type_de_champ/fr.yml +++ b/config/locales/models/type_de_champ/fr.yml @@ -23,3 +23,4 @@ fr: engagement: 'Engagement' header_section: 'Titre de section' explication: 'Explication' + multiple_drop_down_list: 'Menu déroulant à choix multiples' diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index 523ab2ae1..9410e3b7f 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -9,15 +9,16 @@ describe DropDownList do it { is_expected.to belong_to(:type_de_champ) } end + let(:dropdownlist) { create :drop_down_list, value: value } + describe '#options' do let(:value) { "Cohésion sociale Dév.Eco / Emploi Cadre de vie / Urb. Pilotage / Ingénierie " } - let(:dropdownlist) { create :drop_down_list, value: value } - it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Dév.Eco / Emploi", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] } + it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Dév.Eco / Emploi', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] } context 'when one value is empty' do let(:value) { "Cohésion sociale @@ -26,7 +27,37 @@ Cadre de vie / Urb. Pilotage / Ingénierie " } - it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] } + it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] } + end + end + + describe 'disabled_options' do + let(:value) { "tip +--top-- +--troupt-- +ouaich" } + + it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) } + end + + describe 'selected_options' do + + let(:dropdownlist) do + create(:drop_down_list, type_de_champ: type_de_champ) + end + + context 'when multiple' do + let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') } + + let(:champ) { Champ.new(value: '["1","2"]') } + it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) } + end + + context 'when simple' do + let(:type_de_champ) { TypeDeChamp.new(type_champ: 'drop_down_list') } + + let(:champ) { Champ.new(value: '1') } + it { expect(dropdownlist.selected_options(champ)).to match(['1']) } end end end From 3ed14bf1a4e44b6ab3cfdd4fbfa77149bc407c2b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 17:48:35 +0100 Subject: [PATCH 08/17] Cleaning --- app/views/dossiers/_infos_dossier.html.haml | 14 +++++++------- app/views/users/description/_show.html.haml | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index 4c381e2ee..91d85a427 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -49,19 +49,19 @@ =")" %div.row - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0 - .col-lg-12.col-md-12.col-sm-12.col-xs-12 + .col-xs-12 .row.title-row %div.col-xs-4.split-hr %div.col-xs-4.dossier-title= t('utils.pieces').upcase %div.col-xs-4.split-hr - .col-lg-12.col-md-12.col-sm-12.col-xs-12#pieces_justificatives.margin-bot-40 + .col-xs-12#pieces_justificatives.margin-bot-40 .row - if @facade.procedure.cerfa_flag? .col-xs-12#piece_justificative_0 .row.piece-row .col-xs-6.depositaire-label= 'Formulaire' - .col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + .col-xs-1.comments-off= "-" .col-xs-5.despositaire-info - if @facade.dossier.cerfa_available? %a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter @@ -78,7 +78,7 @@ .col-xs-12{ id: "piece_justificative_#{type_de_piece_justificative.id}" } .row %div.col-xs-6.depositaire-label= type_de_piece_justificative.libelle - %div.col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" + %div.col-xs-1.comments-off= "-" %div.col-xs-5.despositaire-info - if type_de_piece_justificative.api_entreprise %span.text-success Nous l'avons récupéré pour vous. @@ -96,13 +96,13 @@ - if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email)) - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0 .row - .col-lg-4.col-md-4.col-sm-4.col-xs-4 + .col-xs-4 %a#maj_pj.action{"data-target" => "#UploadPJmodal", "data-toggle" => "modal", :type => "button"} - .col-lg-4.col-md-4.col-sm-4.col-xs-4.action + .col-xs-4.action Modifier les documents %br = render partial: 'users/recapitulatif/modal_upload_pj' - .col-lg-4.col-md-4.col-sm-4.col-xs-4 + .col-xs-4 - if gestionnaire_signed_in? #PJmodal.modal.fade{"aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"} diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index 14b17b160..e0049ce71 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -4,7 +4,7 @@ .panel.panel-info{style:'margin-bottom:0'} .panel-body.center .row - .col-md-1.col-lg-1.col-sm-1.col-xs-1 + .col-xs-1 .fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'} .col-xs-10{style:'padding-right: 0px'} %b @@ -34,7 +34,7 @@ .panel.panel-info .panel-body.center .row - .col-md-1.col-lg-1.col-sm-1.col-xs-1 + .col-xs-1 .fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'} .col-xs-11 Les documents administratifs ne sont pas indispensables afin d'initier votre dossier. From 1fa1e9e8e82286341b59432a1c167831e0baac8f Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 17:49:48 +0100 Subject: [PATCH 09/17] select_multiple: add select2 --- Gemfile | 2 ++ Gemfile.lock | 3 +++ app/assets/javascripts/application.js | 1 + app/assets/javascripts/user/description.js | 6 ++++++ app/assets/stylesheets/application.scss | 2 ++ 5 files changed, 14 insertions(+) create mode 100644 app/assets/javascripts/user/description.js diff --git a/Gemfile b/Gemfile index 3b1aa7926..20bc62a0a 100644 --- a/Gemfile +++ b/Gemfile @@ -102,6 +102,8 @@ gem 'simple_form' gem 'newrelic_rpm' +gem 'select2-rails' + group :test do gem 'capybara' gem 'launchy' diff --git a/Gemfile.lock b/Gemfile.lock index f0e40cf8e..353b2160a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -543,6 +543,8 @@ GEM json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) securecompare (1.0.0) + select2-rails (4.0.3) + thor (~> 0.14) selenium-webdriver (3.0.3) childprocess (~> 0.5) rubyzip (~> 1.0) @@ -709,6 +711,7 @@ DEPENDENCIES sass-rails (~> 5.0) scenic sdoc (~> 0.4.0) + select2-rails selenium-webdriver sentry-raven shoulda-matchers diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 567658f93..a7827dfc8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -31,6 +31,7 @@ //= require bootstrap-wysihtml5/locales/fr-FR //= require handlebars //= require typeahead.bundle +//= require select2 $(document).on('page:load', application_init); $(document).ready(application_init); diff --git a/app/assets/javascripts/user/description.js b/app/assets/javascripts/user/description.js new file mode 100644 index 000000000..cdae9a4c1 --- /dev/null +++ b/app/assets/javascripts/user/description.js @@ -0,0 +1,6 @@ +$(document).on('page:load', activeSelect2); +$(document).ready(activeSelect2); + +function activeSelect2() { + $('select.select2').select2({ theme: "bootstrap", width: '100%' }); +} diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 5e30ef194..6d4168935 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -19,6 +19,8 @@ *= require font-awesome *= require franceconnect *= require bootstrap-wysihtml5 + *= require select2 + *= require select2-bootstrap */ @import "variables"; @import "bootstrap-sprockets"; From 2f561a9cd0bc9947bd8dbacb509d74b23ed8c3ed Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 17:50:10 +0100 Subject: [PATCH 10/17] select_multiple: clean user input --- app/services/types_de_champ_service.rb | 12 ++++++++- spec/services/type_de_champ_service_spec.rb | 30 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 spec/services/type_de_champ_service_spec.rb diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb index b8397d3a4..eba9a549a 100644 --- a/app/services/types_de_champ_service.rb +++ b/app/services/types_de_champ_service.rb @@ -12,8 +12,18 @@ class TypesDeChampService if param_second[:libelle].empty? parameters[attributes].delete(param_first.to_s) end + + if param_second['drop_down_list_attributes'] && param_second['drop_down_list_attributes']['value'] + param_second['drop_down_list_attributes']['value'] = self.clean_value (param_second['drop_down_list_attributes']['value']) + end end parameters end -end \ No newline at end of file + + private + + def self.clean_value value + value.split("\r\n").map{ |v| v.strip }.join("\r\n") + end +end diff --git a/spec/services/type_de_champ_service_spec.rb b/spec/services/type_de_champ_service_spec.rb new file mode 100644 index 000000000..e1e61ef91 --- /dev/null +++ b/spec/services/type_de_champ_service_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe TypesDeChampService do + let(:params) do + ActionController::Parameters.new({ + procedure: { + types_de_champ_attributes: { + "0" => { + libelle: 'top', + drop_down_list_attributes: { + value: "un\r\n deux\r\n -- commentaire --\r\n trois", + id: '5218' + } + } + } + } + }) + end + + let(:result) { TypesDeChampService.create_update_procedure_params(params) } + + describe 'self.create_update_procedure_params' do + describe 'the drop down list attributes' do + subject { result['types_de_champ_attributes']['0']['drop_down_list_attributes'] } + it 'has its value stripped' do + expect(subject['value']).to eq("un\r\ndeux\r\n-- commentaire --\r\ntrois") + end + end + end +end From b3624256cd10449e9aff571e74073ff6bf6f955b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 17:51:12 +0100 Subject: [PATCH 11/17] select_multiple: add decoration for view of multiple_select --- app/decorators/champ_decorator.rb | 5 ++--- spec/decorators/champ_decorator_spec.rb | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index 42c9639e4..f3d6ac07c 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -2,9 +2,8 @@ class ChampDecorator < Draper::Decorator delegate_all def value - if type_champ == 'checkbox' - return object.value == 'on' ? 'Oui' : 'Non' - end + return object.value == 'on' ? 'Oui' : 'Non' if type_champ == 'checkbox' + return JSON.parse(object.value).join(', ') if type_champ == 'multiple_drop_down_list' && !object.value.blank? object.value end diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb index 5d25679ca..c8b15056c 100644 --- a/spec/decorators/champ_decorator_spec.rb +++ b/spec/decorators/champ_decorator_spec.rb @@ -1,19 +1,18 @@ require 'spec_helper' describe ChampDecorator do - let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: :checkbox)} + let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: type_champ)} let(:decorator) { champ.decorate } + describe 'value' do subject { decorator.value } - context 'when type_champ is checkbox' do + describe 'for a checkbox' do + let(:type_champ) { :checkbox } context 'when value is on' do - before do - champ.update value: 'on' - end - + before { champ.update value: 'on' } it { is_expected.to eq 'Oui' } end @@ -21,5 +20,19 @@ describe ChampDecorator do it { is_expected.to eq 'Non' } end end + + describe 'for a multiple_drop_down_list' do + let(:type_champ) { :multiple_drop_down_list } + + context 'when value is an array' do + before { champ.update value: '["1", "2"]' } + it { is_expected.to eq '1, 2' } + end + + context 'when value is empty' do + before { champ.update value: '' } + it { is_expected.to eq '' } + end + end end end From ebd2051337adea3b280b0a9add7e2e330932f6f9 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 15 Mar 2017 18:32:20 +0100 Subject: [PATCH 12/17] multiple_select: fix decorateur interference --- app/models/drop_down_list.rb | 2 +- spec/models/drop_down_list_spec.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index 3d82184d1..979112f4c 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -11,7 +11,7 @@ class DropDownList < ActiveRecord::Base end def selected_options(champ) - champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value] + champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value] end def multiple diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index 9410e3b7f..be53e9dea 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -41,7 +41,6 @@ ouaich" } end describe 'selected_options' do - let(:dropdownlist) do create(:drop_down_list, type_de_champ: type_de_champ) end @@ -49,14 +48,14 @@ ouaich" } context 'when multiple' do let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') } - let(:champ) { Champ.new(value: '["1","2"]') } + let(:champ) { Champ.new(value: '["1","2"]').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) } end context 'when simple' do let(:type_de_champ) { TypeDeChamp.new(type_champ: 'drop_down_list') } - let(:champ) { Champ.new(value: '1') } + let(:champ) { Champ.new(value: '1').decorate } it { expect(dropdownlist.selected_options(champ)).to match(['1']) } end end From ce343aac965566537e3f5da6b585d3522fb5ab22 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 20 Mar 2017 11:36:06 +0100 Subject: [PATCH 13/17] Select Multiple: text in placeholder and add separator --- app/views/admin/types_de_champ/_fields.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/admin/types_de_champ/_fields.html.haml b/app/views/admin/types_de_champ/_fields.html.haml index 929f573f6..01c60cdd9 100644 --- a/app/views/admin/types_de_champ/_fields.html.haml +++ b/app/views/admin/types_de_champ/_fields.html.haml @@ -17,7 +17,7 @@ .form-group.drop_down_list{ class: (%w(drop_down_list multiple_drop_down_list).include?(type_champ) ? 'show_inline' : nil), style: 'margin-right: 5px' } %h4 Liste déroulante = ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff| - ~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne.\nEcrire --valeur-- pour un séparateur.", rows: 3, cols: 30 + ~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne et --valeur-- pour un séparateur.", rows: 3, cols: 30 = fff.hidden_field :id @@ -45,4 +45,6 @@ - else = link_to("", @types_de_champ_facade.delete_url(ff), method: :delete, remote: true, id: "delete_type_de_champ_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) ) + %div{ style: 'background-color: rgb(204, 204, 204); height: 1px; margin: 30px auto;' } + From a076dc298749751624f6aa7621d68fffcbeaabf0 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 20 Mar 2017 12:03:27 +0100 Subject: [PATCH 14/17] Wording --- app/views/admin/procedures/show.html.haml | 2 +- app/views/admin/profile/show.html.haml | 2 +- ...anel_admin_procedurescontroller_navbar.html.haml | 2 +- ...nel_backoffice_dossierscontroller_show.html.haml | 4 ++-- ...avbar_admin_procedurescontroller_index.html.haml | 2 +- app/views/users/description/_show.html.haml | 13 +------------ app/views/users/registrations/new.html.haml | 2 +- 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index e0c945cff..7249a0ed6 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -82,7 +82,7 @@ .pieces_justificatives.col-xs-6.col-md-3 %h4.text-info - Pièces justificatives + Pièces jointes .badge.progress-bar-info = @facade.procedure.types_de_piece_justificative.size - @facade.procedure.types_de_piece_justificative.each do |piece_justificative| diff --git a/app/views/admin/profile/show.html.haml b/app/views/admin/profile/show.html.haml index 5349fd071..615d5331e 100644 --- a/app/views/admin/profile/show.html.haml +++ b/app/views/admin/profile/show.html.haml @@ -1,5 +1,5 @@ #profile_page -%h2 Profile +%h2 Profil %hr %p API TOKEN : diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml index a78879adc..8a05145b8 100644 --- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml +++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml @@ -31,7 +31,7 @@ - unless @procedure.locked? %a{:href => "#{url_for admin_procedure_pieces_justificatives_path(@procedure)}", id: 'onglet-pieces'} %div.procedure_list_element{class: ('active' if active == 'Pieces')} - Pièces justificatives + Pièces jointes - unless @procedure.locked? %a{:href => "#{url_for admin_procedure_types_de_champ_private_path(@procedure)}", id: 'onglet-private-champs'} diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml index 9c8748b5b..12f7b4e7c 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml @@ -54,9 +54,9 @@ .type= "Un attribut à été changé: #{notification.liste.last}" - elsif ['piece_justificative'].include?(notification.type_notif) - if notification.liste.size > 1 - .type= "Plusieurs pièces justificatives ont été changés, dont: #{notification.liste.join(" ")}" + .type= "Plusieurs pièces jointes ont été changés, dont: #{notification.liste.join(" ")}" - else - .type= "Une pièce justificative à été changée: #{notification.liste.last}" + .type= "Une pièce jointe à été changée: #{notification.liste.last}" - else .type= notification.liste.last .split-hr diff --git a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml index 8adfbc93d..13fdaf3c7 100644 --- a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml +++ b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml @@ -23,4 +23,4 @@ %li = link_to(admin_profile_path, id: :profile) do %i.fa.fa-user -  Profile +  Profil diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index 14b17b160..6fc76dc8a 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -22,7 +22,7 @@ -if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0 %br - %h3 Documents administratifs + %h3 Pièces jointes //TODO a refactorer @@ -30,17 +30,6 @@ .col-lg-8 = render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier } - #state_description.row{style:'width: 50%; margin-left:20px'} - .panel.panel-info - .panel-body.center - .row - .col-md-1.col-lg-1.col-sm-1.col-xs-1 - .fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'} - .col-xs-11 - Les documents administratifs ne sont pas indispensables afin d'initier votre dossier. - Vous pourrez dans tous les cas les compléter plus tard si vous ne les possédez pas de suite. - - -route = Rails.application.routes.recognize_path(request.referrer) # WTF ? - unless route[:controller].match('admin') %div{style: 'text-align:right'} diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index 12e3165cc..d8270c4a9 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -47,7 +47,7 @@ = f.email_field :email, class: 'form-control', placeholder: 'Email', value: params[:user_email] %br %h4 - = f.label :password + = f.label :password, 'Mot de passe' .input-group .input-group-addon %span.fa.fa-asterisk From 75007825f8247cc62e580fee51ed0f3aad53980a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 20 Mar 2017 12:14:16 +0100 Subject: [PATCH 15/17] Update champ_decorator.rb --- app/decorators/champ_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index f3d6ac07c..8c95b8183 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -3,7 +3,7 @@ class ChampDecorator < Draper::Decorator def value return object.value == 'on' ? 'Oui' : 'Non' if type_champ == 'checkbox' - return JSON.parse(object.value).join(', ') if type_champ == 'multiple_drop_down_list' && !object.value.blank? + return JSON.parse(object.value).join(', ') if type_champ == 'multiple_drop_down_list' && object.value.present? object.value end From c795a7d7e2f3e39fcd299989f36ac67e310020ae Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 20 Mar 2017 12:37:43 +0100 Subject: [PATCH 16/17] Fix tests --- .../users/description/show.html.haml_spec.rb | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb index 8d4434af2..c278c09f1 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -125,22 +125,5 @@ describe 'users/description/show.html.haml', type: :view do it { expect(rendered).not_to have_content 'Documents administratifs' } end - context 'when dossier have pj' do - let(:dossier) { create(:dossier) } - - it { expect(rendered).to have_content 'Documents administratifs' } - end - - context 'when procedure have demarche link' do - let(:procedure) { create :procedure } - - it { expect(rendered).to have_content 'Documents administratifs' } - end - - context 'when procedure have cerfa flag true' do - let(:procedure) { create(:procedure, cerfa_flag: true) } - - it { expect(rendered).to have_content 'Documents administratifs' } - end end end From 4112af6c9357a1527acafbc8c7d787ba10485d59 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 20 Mar 2017 13:48:42 +0100 Subject: [PATCH 17/17] Fix tests --- .../previsualisations/show.html.haml_spec.rb | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/spec/views/admin/previsualisations/show.html.haml_spec.rb b/spec/views/admin/previsualisations/show.html.haml_spec.rb index f0983b660..cfed1dd02 100644 --- a/spec/views/admin/previsualisations/show.html.haml_spec.rb +++ b/spec/views/admin/previsualisations/show.html.haml_spec.rb @@ -129,22 +129,5 @@ describe 'admin/previsualisations/show.html.haml', type: :view do it { expect(rendered).not_to have_content 'Documents administratifs' } end - context 'when dossier have pj' do - let(:dossier) { create(:dossier) } - - it { expect(rendered).to have_content 'Documents administratifs' } - end - - context 'when procedure have demarche link' do - let(:procedure) { create :procedure } - - it { expect(rendered).to have_content 'Documents administratifs' } - end - - context 'when procedure have cerfa flag true' do - let(:procedure) {create(:procedure, cerfa_flag: true)} - - it { expect(rendered).to have_content 'Documents administratifs' } - end end end