Merge branch 'develop' into staging

This commit is contained in:
Mathieu Magnin 2017-03-20 15:56:55 +01:00
commit 05bab5c402
34 changed files with 237 additions and 144 deletions

View file

@ -102,6 +102,8 @@ gem 'simple_form'
gem 'newrelic_rpm' gem 'newrelic_rpm'
gem 'select2-rails'
group :test do group :test do
gem 'capybara' gem 'capybara'
gem 'launchy' gem 'launchy'

View file

@ -543,6 +543,8 @@ GEM
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0) rdoc (~> 4.0)
securecompare (1.0.0) securecompare (1.0.0)
select2-rails (4.0.3)
thor (~> 0.14)
selenium-webdriver (3.0.3) selenium-webdriver (3.0.3)
childprocess (~> 0.5) childprocess (~> 0.5)
rubyzip (~> 1.0) rubyzip (~> 1.0)
@ -709,6 +711,7 @@ DEPENDENCIES
sass-rails (~> 5.0) sass-rails (~> 5.0)
scenic scenic
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
select2-rails
selenium-webdriver selenium-webdriver
sentry-raven sentry-raven
shoulda-matchers shoulda-matchers

View file

@ -23,22 +23,25 @@ function destroy_action(){
} }
function on_change_type_de_champ_select (){ function on_change_type_de_champ_select (){
$("select.form-control.type_champ").on('change', function(e){ $("select.form-control.type_champ").on('change', function(e){
parent = $(this).parent().parent(); parent = $(this).parent().parent();
parent.removeClass('header_section'); parent.removeClass('header_section');
parent.children(".drop_down_list").removeClass('show_inline'); parent.children(".drop_down_list").removeClass('show_inline');
$('.mandatory', parent).show();
switch(this.value){ switch(this.value){
case 'header_section': case 'header_section':
parent.addClass('header_section'); parent.addClass('header_section');
break; break;
case 'drop_down_list': case 'drop_down_list':
case 'multiple_drop_down_list':
parent.children(".drop_down_list").addClass('show_inline'); parent.children(".drop_down_list").addClass('show_inline');
break; break;
case 'explication':
$('.mandatory', parent).hide();
break;
} }
}) });
} }

View file

@ -31,6 +31,7 @@
//= require bootstrap-wysihtml5/locales/fr-FR //= require bootstrap-wysihtml5/locales/fr-FR
//= require handlebars //= require handlebars
//= require typeahead.bundle //= require typeahead.bundle
//= require select2
$(document).on('page:load', application_init); $(document).on('page:load', application_init);
$(document).ready(application_init); $(document).ready(application_init);

View file

@ -0,0 +1,6 @@
$(document).on('page:load', activeSelect2);
$(document).ready(activeSelect2);
function activeSelect2() {
$('select.select2').select2({ theme: "bootstrap", width: '100%' });
}

View file

@ -23,6 +23,10 @@
} }
#liste_champ{ #liste_champ{
.form-inline {
margin-bottom: 30px;
}
.show_inline { .show_inline {
display: inline-block !important; display: inline-block !important;
} }
@ -30,4 +34,16 @@
.form-group.drop_down_list{ .form-group.drop_down_list{
display: none; display: none;
} }
}
.form-group {
vertical-align: top;
margin-right: 15px;
}
.description {
padding: 0;
textarea {
padding: 6px 12px;
}
}
}

View file

@ -19,6 +19,8 @@
*= require font-awesome *= require font-awesome
*= require franceconnect *= require franceconnect
*= require bootstrap-wysihtml5 *= require bootstrap-wysihtml5
*= require select2
*= require select2-bootstrap
*/ */
@import "variables"; @import "variables";
@import "bootstrap-sprockets"; @import "bootstrap-sprockets";

View file

@ -2,9 +2,8 @@ class ChampDecorator < Draper::Decorator
delegate_all delegate_all
def value def value
if type_champ == 'checkbox' return object.value == 'on' ? 'Oui' : 'Non' if type_champ == 'checkbox'
return object.value == 'on' ? 'Oui' : 'Non' return JSON.parse(object.value).join(', ') if type_champ == 'multiple_drop_down_list' && object.value.present?
end
object.value object.value
end end

View file

@ -3,11 +3,19 @@ class TypeDeChampDecorator < Draper::Decorator
delegate_all delegate_all
def button_up params 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 end
def button_down params 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 end
private private

View file

@ -2,6 +2,19 @@ class DropDownList < ActiveRecord::Base
belongs_to :type_de_champ belongs_to :type_de_champ
def options 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.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value]
end
def multiple
type_de_champ.type_champ == 'multiple_drop_down_list'
end end
end end

View file

@ -12,11 +12,13 @@ class TypeDeChamp < ActiveRecord::Base
address: 'address', address: 'address',
yes_no: 'yes_no', yes_no: 'yes_no',
drop_down_list: 'drop_down_list', drop_down_list: 'drop_down_list',
multiple_drop_down_list: 'multiple_drop_down_list',
pays: 'pays', pays: 'pays',
regions: 'regions', regions: 'regions',
departements: 'departements', departements: 'departements',
engagement: 'engagement', engagement: 'engagement',
header_section: 'header_section' header_section: 'header_section',
explication: 'explication'
} }
belongs_to :procedure belongs_to :procedure
@ -29,7 +31,7 @@ class TypeDeChamp < ActiveRecord::Base
validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :type_champ, 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 def self.type_de_champs_list_fr
type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] } type_champs.map { |champ| [I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first] }
@ -39,8 +41,8 @@ class TypeDeChamp < ActiveRecord::Base
!(type_champ == 'textarea' || type_champ == 'header_section') !(type_champ == 'textarea' || type_champ == 'header_section')
end end
def change_header_section_mandatory def check_mandatory
self.mandatory = false if self.type_champ == 'header_section' self.mandatory = false if %w(header_section explication).include?(self.type_champ)
true true
end end
end end

View file

@ -12,8 +12,18 @@ class TypesDeChampService
if param_second[:libelle].empty? if param_second[:libelle].empty?
parameters[attributes].delete(param_first.to_s) parameters[attributes].delete(param_first.to_s)
end 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 end
parameters parameters
end end
end
private
def self.clean_value value
value.split("\r\n").map{ |v| v.strip }.join("\r\n")
end
end

View file

@ -82,7 +82,7 @@
.pieces_justificatives.col-xs-6.col-md-3 .pieces_justificatives.col-xs-6.col-md-3
%h4.text-info %h4.text-info
Pièces justificatives Pièces jointes
.badge.progress-bar-info .badge.progress-bar-info
= @facade.procedure.types_de_piece_justificative.size = @facade.procedure.types_de_piece_justificative.size
- @facade.procedure.types_de_piece_justificative.each do |piece_justificative| - @facade.procedure.types_de_piece_justificative.each do |piece_justificative|

View file

@ -1,5 +1,5 @@
#profile_page #profile_page
%h2 Profile %h2 Profil
%hr %hr
%p %p
API TOKEN : API TOKEN :

View file

@ -1,27 +1,31 @@
= f.fields_for @types_de_champ_facade.fields_for_var, types_de_champ, remote: true do |ff| = 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 .form-group.libelle
%h4 Libellé %h4 Libellé
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
.form-group.type .form-group.type
%h4 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 .form-group.description
%h4 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: (%w(drop_down_list multiple_drop_down_list).include?(type_champ) ? 'show_inline' : nil), style: 'margin-right: 5px' }
%h4 Liste déroulante %h4 Liste déroulante
= ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff| = 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 = fff.hidden_field :id
- unless ff.object.object.class == TypeDeChampPrivate
.form-group.mandatory
%h4 Obligatoire ? - hide_mandatory = (ff.object.object.class == TypeDeChampPrivate || type_champ == 'explication')
.center .form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
= ff.check_box :mandatory, placeholder: 'Obligatoire ?' %h4 Obligatoire ?
.center
= ff.check_box :mandatory, placeholder: 'Obligatoire ?'
.form-group .form-group
= ff.hidden_field :order_place, value: ff.index = ff.hidden_field :order_place, value: ff.index
@ -41,4 +45,6 @@
- else - 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) ) = 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;' }

View file

@ -1,5 +1,5 @@
%div.row %div.row
.col-lg-12.col-md-12.col-sm-12.col-xs-12 .col-xs-12
- if @facade.procedure.for_individual? - if @facade.procedure.for_individual?
.row.title-row .row.title-row
%div.col-xs-4.split-hr %div.col-xs-4.split-hr
@ -7,24 +7,25 @@
%div.col-xs-4.split-hr %div.col-xs-4.split-hr
.row .row
%div.col-xs-6.depositaire-label Civilité %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 %div.col-xs-5.depositaire-info= @facade.individual.gender
.row .row
%div.col-xs-6.depositaire-label Nom %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 %div.col-xs-5.depositaire-info= @facade.individual.nom
.row .row
%div.col-xs-6.depositaire-label Prénom %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 %div.col-xs-5.despositaire-info= @facade.individual.prenom
.row .row
%div.col-xs-6.depositaire-label Date de naissance %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 %div.col-xs-5.depositaire-info= @facade.individual.birthdate
.row.margin-top-20 .row.margin-top-20
- unless @facade.champs.nil? - unless @facade.champs.nil?
- @facade.champs.each do |champ| - @facade.champs.each do |champ|
- next if champ.type_champ == 'explication'
- if champ.type_champ == 'header_section' - if champ.type_champ == 'header_section'
.row.title-row.margin-top-40 .row.title-row.margin-top-40
%div.col-xs-3.split-hr %div.col-xs-3.split-hr
@ -48,19 +49,19 @@
=")" =")"
%div.row %div.row
- if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0 - 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 .row.title-row
%div.col-xs-4.split-hr %div.col-xs-4.split-hr
%div.col-xs-4.dossier-title= t('utils.pieces').upcase %div.col-xs-4.dossier-title= t('utils.pieces').upcase
%div.col-xs-4.split-hr %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 .row
- if @facade.procedure.cerfa_flag? - if @facade.procedure.cerfa_flag?
.col-xs-12#piece_justificative_0 .col-xs-12#piece_justificative_0
.row.piece-row .row.piece-row
.col-xs-6.depositaire-label= 'Formulaire' .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 .col-xs-5.despositaire-info
- if @facade.dossier.cerfa_available? - if @facade.dossier.cerfa_available?
%a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter %a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter
@ -77,7 +78,7 @@
.col-xs-12{ id: "piece_justificative_#{type_de_piece_justificative.id}" } .col-xs-12{ id: "piece_justificative_#{type_de_piece_justificative.id}" }
.row .row
%div.col-xs-6.depositaire-label= type_de_piece_justificative.libelle %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 %div.col-xs-5.despositaire-info
- if type_de_piece_justificative.api_entreprise - if type_de_piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous. %span.text-success Nous l'avons récupéré pour vous.
@ -95,13 +96,13 @@
- if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email)) - 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 - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0
.row .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"} %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 Modifier les documents
%br %br
= render partial: 'users/recapitulatif/modal_upload_pj' = 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? - if gestionnaire_signed_in?
#PJmodal.modal.fade{"aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"} #PJmodal.modal.fade{"aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"}

View file

@ -31,7 +31,7 @@
- unless @procedure.locked? - unless @procedure.locked?
%a{:href => "#{url_for admin_procedure_pieces_justificatives_path(@procedure)}", id: 'onglet-pieces'} %a{:href => "#{url_for admin_procedure_pieces_justificatives_path(@procedure)}", id: 'onglet-pieces'}
%div.procedure_list_element{class: ('active' if active == 'Pieces')} %div.procedure_list_element{class: ('active' if active == 'Pieces')}
Pièces justificatives Pièces jointes
- unless @procedure.locked? - unless @procedure.locked?
%a{:href => "#{url_for admin_procedure_types_de_champ_private_path(@procedure)}", id: 'onglet-private-champs'} %a{:href => "#{url_for admin_procedure_types_de_champ_private_path(@procedure)}", id: 'onglet-private-champs'}

View file

@ -54,9 +54,9 @@
.type= "Un attribut à été changé: #{notification.liste.last}" .type= "Un attribut à été changé: #{notification.liste.last}"
- elsif ['piece_justificative'].include?(notification.type_notif) - elsif ['piece_justificative'].include?(notification.type_notif)
- if notification.liste.size > 1 - 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 - else
.type= "Une pièce justificative à été changée: #{notification.liste.last}" .type= "Une pièce jointe à été changée: #{notification.liste.last}"
- else - else
.type= notification.liste.last .type= notification.liste.last
.split-hr .split-hr

View file

@ -23,4 +23,4 @@
%li %li
= link_to(admin_profile_path, id: :profile) do = link_to(admin_profile_path, id: :profile) do
%i.fa.fa-user %i.fa.fa-user
&nbsp;Profile &nbsp;Profil

View file

@ -4,7 +4,7 @@
.panel.panel-info{style:'margin-bottom:0'} .panel.panel-info{style:'margin-bottom:0'}
.panel-body.center .panel-body.center
.row .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%'} .fa.fa-info-circle.text-info{style:'font-size: 2em; margin-top: 20%'}
.col-xs-10{style:'padding-right: 0px'} .col-xs-10{style:'padding-right: 0px'}
%b %b
@ -22,7 +22,7 @@
-if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0 -if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
%br %br
%h3 Documents administratifs %h3 Pièces jointes
//TODO a refactorer //TODO a refactorer
@ -30,17 +30,6 @@
.col-lg-8 .col-lg-8
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier } = 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 ? -route = Rails.application.routes.recognize_path(request.referrer) # WTF ?
- unless route[:controller].match('admin') - unless route[:controller].match('admin')
%div{style: 'text-align:right'} %div{style: 'text-align:right'}

View file

@ -1,2 +1,2 @@
- unless champ.drop_down_list.nil? - 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 }

View file

@ -1,18 +1,6 @@
%select{ name:"champs['#{champ.id}']", - unless drop_down_list.options.blank?
id: "champs_#{champ.id}" } = select_tag("champs['#{champ.id}']",
options_for_select(drop_down_list.options, selected: drop_down_list.selected_options(champ),
- unless values.blank? disabled: drop_down_list.disabled_options),
%option multiple: drop_down_list.multiple,
= '' class: drop_down_list.multiple ? 'select2' : nil)
- values.each do |option|
- if (option=~ /^--.*--$/).nil?
- if champ.value == option
%option{selected:''}
= option
- else
%option
= option
-else
%option{disabled:''}
= option

View file

@ -1,9 +1,9 @@
.default_data_block.default_visible .default_data_block.default_visible
%div.row.show-block.infos .row.show-block.infos
%div.header .header
%div.col-lg-12.col-md-12.col-sm-12.col-xs-12.title .col-xs-12.title
%div.carret-right .carret-right
%div.carret-down .carret-down
=libelle =libelle
%div.body .body
= render partial: 'users/description/champs/render_list_champs', locals: {champs: champs, order_place: order_place} = render partial: 'users/description/champs/render_list_champs', locals: {champs: champs, order_place: order_place}

View file

@ -26,7 +26,7 @@
- elsif champ.type_champ == 'yes_no' - elsif champ.type_champ == 'yes_no'
= render partial: 'users/description/champs/yes_no', locals: { champ: champ } = 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 } = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ }
- elsif champ.type_champ == 'pays' - elsif champ.type_champ == 'pays'
@ -41,6 +41,8 @@
- elsif champ.type_champ == 'departements' - elsif champ.type_champ == 'departements'
= render partial: 'users/description/champs/departements', locals: { champ: champ } = render partial: 'users/description/champs/departements', locals: { champ: champ }
- elsif champ.type_champ == 'explication'
- else - else
%input.form-control{name:"champs['#{ champ.id }']", %input.form-control{name:"champs['#{ champ.id }']",
placeholder: champ.libelle, placeholder: champ.libelle,

View file

@ -47,7 +47,7 @@
= f.email_field :email, class: 'form-control', placeholder: 'Email', value: params[:user_email] = f.email_field :email, class: 'form-control', placeholder: 'Email', value: params[:user_email]
%br %br
%h4 %h4
= f.label :password = f.label :password, 'Mot de passe'
.input-group .input-group
.input-group-addon .input-group-addon
%span.fa.fa-asterisk %span.fa.fa-asterisk

View file

@ -21,4 +21,6 @@ fr:
regions: 'Régions' regions: 'Régions'
departements: 'Départements' departements: 'Départements'
engagement: 'Engagement' engagement: 'Engagement'
header_section: 'Titre de section' header_section: 'Titre de section'
explication: 'Explication'
multiple_drop_down_list: 'Menu déroulant à choix multiples'

View file

@ -1,19 +1,18 @@
require 'spec_helper' require 'spec_helper'
describe ChampDecorator do 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 } let(:decorator) { champ.decorate }
describe 'value' do describe 'value' do
subject { decorator.value } 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 context 'when value is on' do
before do before { champ.update value: 'on' }
champ.update value: 'on'
end
it { is_expected.to eq 'Oui' } it { is_expected.to eq 'Oui' }
end end
@ -21,5 +20,19 @@ describe ChampDecorator do
it { is_expected.to eq 'Non' } it { is_expected.to eq 'Non' }
end end
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
end end

View file

@ -16,8 +16,8 @@ describe TypeDeChampDecorator do
subject { type_de_champ_0.decorate } subject { type_de_champ_0.decorate }
let(:button_up) { type_de_champ_.decorate } let(:button_up) { type_de_champ_.decorate }
it 'returns a button up' do it 'hide a button up' do
expect(subject.button_up(params)).to be(nil) expect(subject.button_up(params)).to include('visibility: hidden')
end end
it 'returns a button down' do it 'returns a button down' do
expect(subject.button_down(params)).to match(/fa-chevron-down/) expect(subject.button_down(params)).to match(/fa-chevron-down/)
@ -45,11 +45,12 @@ describe TypeDeChampDecorator do
it 'returns a button up' do it 'returns a button up' do
expect(subject.button_up(params)).to match(/fa-chevron-up/) expect(subject.button_up(params)).to match(/fa-chevron-up/)
end 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
end end
end end

View file

@ -9,15 +9,16 @@ describe DropDownList do
it { is_expected.to belong_to(:type_de_champ) } it { is_expected.to belong_to(:type_de_champ) }
end end
let(:dropdownlist) { create :drop_down_list, value: value }
describe '#options' do describe '#options' do
let(:value) { "Cohésion sociale let(:value) { "Cohésion sociale
Dév.Eco / Emploi Dév.Eco / Emploi
Cadre de vie / Urb. Cadre de vie / Urb.
Pilotage / Ingénierie 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 context 'when one value is empty' do
let(:value) { "Cohésion sociale let(:value) { "Cohésion sociale
@ -26,7 +27,36 @@ Cadre de vie / Urb.
Pilotage / Ingénierie 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"]').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').decorate }
it { expect(dropdownlist.selected_options(champ)).to match(['1']) }
end end
end end
end end

View file

@ -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

View file

@ -129,22 +129,5 @@ describe 'admin/previsualisations/show.html.haml', type: :view do
it { expect(rendered).not_to have_content 'Documents administratifs' } it { expect(rendered).not_to have_content 'Documents administratifs' }
end 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
end end

View file

@ -33,8 +33,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end end
context 'when there is only one field in database' do 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) } 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).to have_css('#btn_down_0[style*="visibility: hidden"]') }
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).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') } it { expect(subject).not_to have_css('#btn_down_1') }
end 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_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) } 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).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).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
end end

View file

@ -30,7 +30,7 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
describe 'mandatory checkbox' do describe 'mandatory checkbox' do
it 'no mandatory checkbox are present' 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
end end
@ -41,8 +41,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end end
context 'when there is only one field in database' do 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) } 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).to have_css('#btn_down_0[style*="visibility: hidden"]') }
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).not_to have_css('#btn_up_1') } it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') } it { expect(subject).not_to have_css('#btn_down_1') }
end 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_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) } 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).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).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
end end
end end

View file

@ -125,22 +125,5 @@ describe 'users/description/show.html.haml', type: :view do
it { expect(rendered).not_to have_content 'Documents administratifs' } it { expect(rendered).not_to have_content 'Documents administratifs' }
end 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
end end