commit
fd7d884d7f
41 changed files with 188 additions and 416 deletions
3
Gemfile
3
Gemfile
|
@ -35,9 +35,6 @@ gem 'active_link_to'
|
||||||
# Pagination
|
# Pagination
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|
||||||
# Decorators
|
|
||||||
gem 'draper'
|
|
||||||
|
|
||||||
# Gestion des comptes utilisateurs
|
# Gestion des comptes utilisateurs
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'devise-async'
|
gem 'devise-async'
|
||||||
|
|
11
Gemfile.lock
11
Gemfile.lock
|
@ -58,10 +58,6 @@ GEM
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (5.2.2)
|
activemodel (5.2.2)
|
||||||
activesupport (= 5.2.2)
|
activesupport (= 5.2.2)
|
||||||
activemodel-serializers-xml (1.0.2)
|
|
||||||
activemodel (> 5.x)
|
|
||||||
activesupport (> 5.x)
|
|
||||||
builder (~> 3.1)
|
|
||||||
activerecord (5.2.2)
|
activerecord (5.2.2)
|
||||||
activemodel (= 5.2.2)
|
activemodel (= 5.2.2)
|
||||||
activesupport (= 5.2.2)
|
activesupport (= 5.2.2)
|
||||||
|
@ -194,12 +190,6 @@ GEM
|
||||||
dotenv-rails (2.5.0)
|
dotenv-rails (2.5.0)
|
||||||
dotenv (= 2.5.0)
|
dotenv (= 2.5.0)
|
||||||
railties (>= 3.2, < 6.0)
|
railties (>= 3.2, < 6.0)
|
||||||
draper (3.0.1)
|
|
||||||
actionpack (~> 5.0)
|
|
||||||
activemodel (~> 5.0)
|
|
||||||
activemodel-serializers-xml (~> 1.0)
|
|
||||||
activesupport (~> 5.0)
|
|
||||||
request_store (~> 1.0)
|
|
||||||
em-websocket (0.5.1)
|
em-websocket (0.5.1)
|
||||||
eventmachine (>= 0.12.9)
|
eventmachine (>= 0.12.9)
|
||||||
http_parser.rb (~> 0.6.0)
|
http_parser.rb (~> 0.6.0)
|
||||||
|
@ -696,7 +686,6 @@ DEPENDENCIES
|
||||||
devise
|
devise
|
||||||
devise-async
|
devise-async
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
draper
|
|
||||||
factory_bot
|
factory_bot
|
||||||
flipflop
|
flipflop
|
||||||
fog-openstack
|
fog-openstack
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
class ChampDecorator < Draper::Decorator
|
|
||||||
delegate_all
|
|
||||||
|
|
||||||
def value
|
|
||||||
if type_champ == TypeDeChamp.type_champs.fetch(:date) && object.value.present?
|
|
||||||
Date.parse(object.value).strftime("%d/%m/%Y")
|
|
||||||
elsif type_champ.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
|
|
||||||
object.value == 'on' ? 'Oui' : 'Non'
|
|
||||||
elsif type_champ == TypeDeChamp.type_champs.fetch(:yes_no)
|
|
||||||
if object.value == 'true'
|
|
||||||
'Oui'
|
|
||||||
elsif object.value == 'false'
|
|
||||||
'Non'
|
|
||||||
end
|
|
||||||
elsif type_champ == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && object.value.present?
|
|
||||||
JSON.parse(object.value).join(', ')
|
|
||||||
else
|
|
||||||
object.value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
class DossierDecorator < Draper::Decorator
|
|
||||||
delegate :current_page, :limit_value, :total_pages
|
|
||||||
delegate_all
|
|
||||||
|
|
||||||
def first_creation
|
|
||||||
created_at.strftime('%d/%m/%Y %H:%M')
|
|
||||||
end
|
|
||||||
|
|
||||||
def last_update
|
|
||||||
updated_at.strftime('%d/%m/%Y %H:%M')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
class DossiersDecorator < Draper::CollectionDecorator
|
|
||||||
delegate :current_page, :limit_value, :total_pages
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
class FranceConnectInformationDecorator < Draper::Decorator
|
|
||||||
delegate_all
|
|
||||||
|
|
||||||
def gender_fr
|
|
||||||
gender == 'female' ? 'Mme' : 'M.'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
class ProcedureDecorator < Draper::Decorator
|
|
||||||
delegate_all
|
|
||||||
|
|
||||||
def created_at_fr
|
|
||||||
created_at.strftime('%d/%m/%Y %H:%M')
|
|
||||||
end
|
|
||||||
|
|
||||||
def published_at_fr
|
|
||||||
if published_at.present?
|
|
||||||
published_at.strftime('%d/%m/%Y %H:%M')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def logo_img
|
|
||||||
if logo.blank?
|
|
||||||
h.image_url("marianne.svg")
|
|
||||||
else
|
|
||||||
if Flipflop.remote_storage?
|
|
||||||
(RemoteDownloader.new logo.filename).url
|
|
||||||
else
|
|
||||||
(LocalDownloader.new logo.path, 'logo').url
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
class ProceduresDecorator < Draper::CollectionDecorator
|
|
||||||
delegate :current_page, :limit_value, :total_pages
|
|
||||||
end
|
|
|
@ -1,49 +0,0 @@
|
||||||
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,
|
|
||||||
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,
|
|
||||||
style: display_down_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;'
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def up_classes
|
|
||||||
base_classes << 'fa-chevron-up'
|
|
||||||
end
|
|
||||||
|
|
||||||
def down_classes
|
|
||||||
base_classes << 'fa-chevron-down'
|
|
||||||
end
|
|
||||||
|
|
||||||
def base_classes
|
|
||||||
['btn', 'btn-default', 'form-control', 'fa']
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_up_button?(index, private)
|
|
||||||
!(index == 0 || count_type_de_champ(private) < 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_down_button?(index, private)
|
|
||||||
(index + 1) < count_type_de_champ(private)
|
|
||||||
end
|
|
||||||
|
|
||||||
def count_type_de_champ(private)
|
|
||||||
if private
|
|
||||||
@count_type_de_champ ||= procedure.types_de_champ_private.count
|
|
||||||
else
|
|
||||||
@count_type_de_champ ||= procedure.types_de_champ.count
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,40 +0,0 @@
|
||||||
class TypeDePieceJustificativeDecorator < Draper::Decorator
|
|
||||||
delegate_all
|
|
||||||
def button_up(params)
|
|
||||||
if display_up_button?(params[:index])
|
|
||||||
h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def button_down(params)
|
|
||||||
if display_down_button?(params[:index])
|
|
||||||
h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def up_classes
|
|
||||||
base_classes << 'fa-chevron-up'
|
|
||||||
end
|
|
||||||
|
|
||||||
def down_classes
|
|
||||||
base_classes << 'fa-chevron-down'
|
|
||||||
end
|
|
||||||
|
|
||||||
def base_classes
|
|
||||||
['btn', 'btn-default', 'form-control', 'fa']
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_up_button?(index)
|
|
||||||
!(index == 0 || count_type_de_piece_justificative < 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_down_button?(index)
|
|
||||||
(index + 1) < count_type_de_piece_justificative
|
|
||||||
end
|
|
||||||
|
|
||||||
def count_type_de_piece_justificative
|
|
||||||
@count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
class UserDecorator < Draper::Decorator
|
|
||||||
delegate_all
|
|
||||||
|
|
||||||
def gender_fr
|
|
||||||
case gender
|
|
||||||
when 'male'
|
|
||||||
'M.'
|
|
||||||
when 'female'
|
|
||||||
'Mme'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
55
app/helpers/admin_formulaire_helper.rb
Normal file
55
app/helpers/admin_formulaire_helper.rb
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
module AdminFormulaireHelper
|
||||||
|
BASE_CLASSES = ['btn', 'btn-default', 'form-control', 'fa']
|
||||||
|
|
||||||
|
def button_up(procedure, kind, index, url)
|
||||||
|
if display_up_button?(index, procedure, kind)
|
||||||
|
button(up_classes, "btn_up_#{index}", url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_down(procedure, kind, index, url)
|
||||||
|
if display_down_button?(index, procedure, kind)
|
||||||
|
button(down_classes, "btn_down_#{index}", url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def button(classes, id, url)
|
||||||
|
link_to(
|
||||||
|
'',
|
||||||
|
url,
|
||||||
|
class: classes,
|
||||||
|
id: id,
|
||||||
|
remote: true,
|
||||||
|
method: :post
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def up_classes
|
||||||
|
BASE_CLASSES + ['fa-chevron-up']
|
||||||
|
end
|
||||||
|
|
||||||
|
def down_classes
|
||||||
|
BASE_CLASSES + ['fa-chevron-down']
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_up_button?(index, procedure, kind)
|
||||||
|
index != 0 && count_type_de_champ(procedure, kind) > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_down_button?(index, procedure, kind)
|
||||||
|
(index + 1) < count_type_de_champ(procedure, kind)
|
||||||
|
end
|
||||||
|
|
||||||
|
def count_type_de_champ(procedure, kind)
|
||||||
|
case kind
|
||||||
|
when "public"
|
||||||
|
@count_type_de_champ_public ||= procedure.types_de_champ.count
|
||||||
|
when "private"
|
||||||
|
@count_type_de_champ_private ||= procedure.types_de_champ_private.count
|
||||||
|
when "piece_justificative"
|
||||||
|
@count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,4 +9,25 @@ module ChampHelper
|
||||||
raw(champ.to_render_data.to_json)
|
raw(champ.to_render_data.to_json)
|
||||||
# rubocop:enable Rails/OutputSafety
|
# rubocop:enable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def formatted_value(champ)
|
||||||
|
value = champ.value
|
||||||
|
type = champ.type_champ
|
||||||
|
|
||||||
|
if type == TypeDeChamp.type_champs.fetch(:date) && value.present?
|
||||||
|
Date.parse(value).strftime("%d/%m/%Y")
|
||||||
|
elsif type.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
|
||||||
|
value == 'on' ? 'Oui' : 'Non'
|
||||||
|
elsif type == TypeDeChamp.type_champs.fetch(:yes_no)
|
||||||
|
if value == 'true'
|
||||||
|
'Oui'
|
||||||
|
elsif value == 'false'
|
||||||
|
'Non'
|
||||||
|
end
|
||||||
|
elsif type == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && value.present?
|
||||||
|
JSON.parse(value).join(', ')
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,4 +19,18 @@ module ProcedureHelper
|
||||||
action = procedure.archivee? ? :reopen : :publish
|
action = procedure.archivee? ? :reopen : :publish
|
||||||
t(action, scope: [:modal, :publish, key])
|
t(action, scope: [:modal, :publish, key])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def logo_img(procedure)
|
||||||
|
logo = procedure.logo
|
||||||
|
|
||||||
|
if logo.blank?
|
||||||
|
ActionController::Base.helpers.image_url("marianne.svg")
|
||||||
|
else
|
||||||
|
if Flipflop.remote_storage?
|
||||||
|
RemoteDownloader.new(logo.filename).url
|
||||||
|
else
|
||||||
|
LocalDownloader.new(logo.path, 'logo').url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,10 +10,6 @@ class DropDownList < ApplicationRecord
|
||||||
options.select { |v| (v =~ /^--.*--$/).present? }
|
options.select { |v| (v =~ /^--.*--$/).present? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def selected_options(champ)
|
|
||||||
champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value]
|
|
||||||
end
|
|
||||||
|
|
||||||
def selected_options_without_decorator(champ)
|
def selected_options_without_decorator(champ)
|
||||||
champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value]
|
champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value]
|
||||||
end
|
end
|
||||||
|
|
|
@ -176,6 +176,7 @@ class Procedure < ApplicationRecord
|
||||||
else
|
else
|
||||||
list[index_of_first_element].update(order_place: index_of_first_element + 1)
|
list[index_of_first_element].update(order_place: index_of_first_element + 1)
|
||||||
list[index_of_first_element + 1].update(order_place: index_of_first_element)
|
list[index_of_first_element + 1].update(order_place: index_of_first_element)
|
||||||
|
reload
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,11 +36,11 @@ class TypesDeChampService
|
||||||
end
|
end
|
||||||
|
|
||||||
def types_de_champ
|
def types_de_champ
|
||||||
private? ? @procedure.types_de_champ_private.decorate : @procedure.types_de_champ.decorate
|
private? ? @procedure.types_de_champ_private : @procedure.types_de_champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_type_de_champ
|
def new_type_de_champ
|
||||||
TypeDeChamp.new(private: private?).decorate
|
TypeDeChamp.new(private: private?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fields_for_var
|
def fields_for_var
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
- if ff.object.id.present?
|
- if ff.object.id.present?
|
||||||
.form-group
|
.form-group
|
||||||
%br
|
%br
|
||||||
= ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
|
= button_up(@procedure, "piece_justificative", ff.index, 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))
|
= button_down(@procedure, "piece_justificative", ff.index, move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
%h4 Obligatoire ?
|
%h4 Obligatoire ?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
= form_for [:admin, @procedure], url: admin_procedure_pieces_justificatives_path(@procedure), remote: true do |f|
|
= form_for [:admin, @procedure], url: admin_procedure_pieces_justificatives_path(@procedure), remote: true do |f|
|
||||||
#liste_piece_justificative
|
#liste_piece_justificative
|
||||||
= render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative.decorate, f: f }
|
= render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative, f: f }
|
||||||
= f.submit "Enregistrer", class: 'btn btn-success', id: :save
|
= f.submit "Enregistrer", class: 'btn btn-success', id: :save
|
||||||
%hr
|
%hr
|
||||||
#new_type_de_piece_justificative
|
#new_type_de_piece_justificative
|
||||||
= render partial: 'fields', locals: { types_de_piece_justificative: TypeDePieceJustificative.new.decorate, f: f }
|
= render partial: 'fields', locals: { types_de_piece_justificative: TypeDePieceJustificative.new, f: f }
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
.col-md-6
|
.col-md-6
|
||||||
%h4 Logo de la démarche
|
%h4 Logo de la démarche
|
||||||
- if @procedure.logo.present?
|
- if @procedure.logo.present?
|
||||||
= image_tag @procedure.decorate.logo_img, { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
|
= image_tag logo_img(@procedure), { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
|
||||||
\-
|
\-
|
||||||
|
|
||||||
- if @procedure.persisted?
|
- if @procedure.persisted?
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
%th Actions
|
%th Actions
|
||||||
|
|
||||||
- @procedures.each do |procedure|
|
- @procedures.each do |procedure|
|
||||||
- procedure = procedure.decorate
|
- procedure = procedure
|
||||||
- admin_procedure_href = admin_procedure_path(procedure)
|
- admin_procedure_href = admin_procedure_path(procedure)
|
||||||
%tr{ id: "tr_dossier_#{procedure.id}", data: { href: admin_procedure_href } }
|
%tr{ id: "tr_dossier_#{procedure.id}", data: { href: admin_procedure_href } }
|
||||||
%td= link_to(procedure.id, admin_procedure_href)
|
%td= link_to(procedure.id, admin_procedure_href)
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
- if procedure.publiee?
|
- if procedure.publiee?
|
||||||
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
|
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
|
||||||
- if procedure.publiee_ou_archivee?
|
- if procedure.publiee_ou_archivee?
|
||||||
%td= link_to(procedure.published_at_fr, admin_procedure_href)
|
%td= link_to(procedure.published_at.present? ? procedure.published_at.strftime('%d/%m/%Y %H:%M') : "", admin_procedure_href)
|
||||||
- else
|
- else
|
||||||
%td= link_to(procedure.created_at_fr, admin_procedure_href)
|
%td= link_to(procedure.created_at.strftime('%d/%m/%Y %H:%M'), admin_procedure_href)
|
||||||
%td
|
%td
|
||||||
= link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
|
= link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
|
||||||
- if !procedure.publiee_ou_archivee?
|
- if !procedure.publiee_ou_archivee?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
= f.fields_for type_de_champ_service.fields_for_var, types_de_champ, remote: true do |ff|
|
= f.fields_for type_de_champ_service.fields_for_var, types_de_champ, remote: true do |ff|
|
||||||
- type_champ = ff.object.object.type_champ
|
- type_champ = ff.object.type_champ
|
||||||
|
|
||||||
.form-inline{ class: (type_champ == TypeDeChamp.type_champs.fetch(:header_section) ? 'header-section' : nil) }
|
.form-inline{ class: (type_champ == TypeDeChamp.type_champs.fetch(:header_section) ? 'header-section' : nil) }
|
||||||
.form-group.libelle
|
.form-group.libelle
|
||||||
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
.form-group.drop-down-list{ class: (%w(drop_down_list multiple_drop_down_list linked_drop_down_list).include?(type_champ) ? 'show-inline' : nil), style: 'margin-right: 5px;' }
|
.form-group.drop-down-list{ class: (%w(drop_down_list multiple_drop_down_list linked_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.drop_down_list do |fff|
|
||||||
~ 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.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
|
||||||
|
|
||||||
.form-group.pj-template{ class: (type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)) ? 'show-inline' : nil }
|
.form-group.pj-template{ class: (type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)) ? 'show-inline' : nil }
|
||||||
%h4 Modèle
|
%h4 Modèle
|
||||||
- if type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
|
- if type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
|
||||||
- template = ff.object.object.piece_justificative_template
|
- template = ff.object.piece_justificative_template
|
||||||
|
|
||||||
- if !template.attached?
|
- if !template.attached?
|
||||||
= ff.file_field :piece_justificative_template,
|
= ff.file_field :piece_justificative_template,
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
= ff.check_box :parcelles_agricoles
|
= ff.check_box :parcelles_agricoles
|
||||||
Parcelles Agricoles
|
Parcelles Agricoles
|
||||||
|
|
||||||
- hide_mandatory = (ff.object.object.private? || type_champ == TypeDeChamp.type_champs.fetch(:explication))
|
- hide_mandatory = (ff.object.private? || type_champ == TypeDeChamp.type_champs.fetch(:explication))
|
||||||
.form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
|
.form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
|
||||||
%h4 Obligatoire ?
|
%h4 Obligatoire ?
|
||||||
.center
|
.center
|
||||||
|
@ -65,8 +65,9 @@
|
||||||
- if ff.object.id.present?
|
- if ff.object.id.present?
|
||||||
.form-group
|
.form-group
|
||||||
%br
|
%br
|
||||||
= ff.object.button_up(index: ff.index, url: type_de_champ_service.move_up_url(ff), private: type_de_champ_service.private?)
|
- kind = type_de_champ_service.private? ? "private" : "public"
|
||||||
= ff.object.button_down(index: ff.index, url: type_de_champ_service.move_down_url(ff), private: type_de_champ_service.private?)
|
= button_up(@procedure, kind, ff.index, type_de_champ_service.move_up_url(ff))
|
||||||
|
= button_down(@procedure, kind, ff.index, type_de_champ_service.move_down_url(ff))
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
%h4 position
|
%h4 position
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#first-block
|
#first-block
|
||||||
.en-cours
|
.en-cours
|
||||||
- if @procedure.logo.present?
|
- if @procedure.logo.present?
|
||||||
= image_tag @procedure.decorate.logo_img, style: 'width: 30px;'
|
= image_tag logo_img(@procedure), style: 'width: 30px;'
|
||||||
%b
|
%b
|
||||||
= @procedure.libelle
|
= @procedure.libelle
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
%h2 Formulaire
|
%h2 Formulaire
|
||||||
|
|
||||||
- champs = @dossier.champs.decorate
|
- champs = @dossier.champs
|
||||||
- if champs.any?
|
- if champs.any?
|
||||||
= render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
|
= render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.procedure-logos
|
.procedure-logos
|
||||||
= image_tag procedure.decorate.logo_img
|
= image_tag logo_img(procedure)
|
||||||
- if procedure.euro_flag
|
- if procedure.euro_flag
|
||||||
= image_tag "flag_of_europe.svg"
|
= image_tag "flag_of_europe.svg"
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
%tbody
|
%tbody
|
||||||
- champs.reject(&:exclude_from_view?).each do |c|
|
- champs.reject(&:exclude_from_view?).each do |c|
|
||||||
%tr
|
%tr
|
||||||
|
- value = formatted_value(c)
|
||||||
- case c.type_champ
|
- case c.type_champ
|
||||||
- when TypeDeChamp.type_champs.fetch(:header_section)
|
- when TypeDeChamp.type_champs.fetch(:header_section)
|
||||||
%th.header-section{ colspan: 3 }
|
%th.header-section{ colspan: 3 }
|
||||||
|
@ -10,9 +11,9 @@
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
- if c.value.present?
|
- if value.present?
|
||||||
%ul
|
%ul
|
||||||
- c.value.split(", ").each do |item|
|
- value.split(", ").each do |item|
|
||||||
%li
|
%li
|
||||||
= item
|
= item
|
||||||
- when TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
|
- when TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
- dossier = Dossier.includes(:procedure).find_by(id: c.value)
|
- dossier = Dossier.includes(:procedure).find_by(id: value)
|
||||||
- if dossier
|
- if dossier
|
||||||
- path = dossier_linked_path(current_gestionnaire, dossier)
|
- path = dossier_linked_path(current_gestionnaire, dossier)
|
||||||
- if path.present?
|
- if path.present?
|
||||||
|
@ -48,7 +49,7 @@
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
= simple_format(c.value)
|
= simple_format(value)
|
||||||
- when TypeDeChamp.type_champs.fetch(:siret)
|
- when TypeDeChamp.type_champs.fetch(:siret)
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
|
@ -61,14 +62,14 @@
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
- if c.value.present?
|
- if value.present?
|
||||||
= render partial: "shared/champs/carte/show", locals: { champ: c }
|
= render partial: "shared/champs/carte/show", locals: { champ: c }
|
||||||
- else
|
- else
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
= sanitize(c.value)
|
= sanitize(value)
|
||||||
- if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section)
|
- if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section)
|
||||||
%td.updated-at
|
%td.updated-at
|
||||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
= render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual }
|
= render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual }
|
||||||
|
|
||||||
.tab-title Formulaire
|
.tab-title Formulaire
|
||||||
- champs = dossier.champs.includes(:type_de_champ).decorate
|
- champs = dossier.champs.includes(:type_de_champ)
|
||||||
- if champs.any?
|
- if champs.any?
|
||||||
.card
|
.card
|
||||||
= render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile }
|
= render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile }
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
= image_tag('drapeau_europe.png')
|
= image_tag('drapeau_europe.png')
|
||||||
|
|
||||||
#logo_procedure.flag
|
#logo_procedure.flag
|
||||||
= image_tag( @dossier.procedure.decorate.logo_img )
|
= image_tag(logo_img(dossier.procedure))
|
||||||
|
|
||||||
%h2#titre-procedure.text-info
|
%h2#titre-procedure.text-info
|
||||||
= @dossier.procedure.libelle
|
= @dossier.procedure.libelle
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
.text-right
|
.text-right
|
||||||
= link_to "Fermer", users_no_procedure_url, class: "link close-procedure"
|
= link_to "Fermer", users_no_procedure_url, class: "link close-procedure"
|
||||||
.procedure-logos
|
.procedure-logos
|
||||||
= image_tag @dossier.procedure.decorate.logo_img
|
= image_tag logo_img(@dossier.procedure)
|
||||||
- if @dossier.procedure.euro_flag
|
- if @dossier.procedure.euro_flag
|
||||||
= image_tag "flag_of_europe.svg"
|
= image_tag "flag_of_europe.svg"
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe DossierDecorator do
|
|
||||||
let(:dossier) do
|
|
||||||
dossier = create(:dossier, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
|
||||||
dossier.update_column('updated_at', Time.zone.local(2015, 12, 24, 14, 10))
|
|
||||||
dossier
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { dossier.decorate }
|
|
||||||
|
|
||||||
describe 'first_creation' do
|
|
||||||
subject { super().first_creation }
|
|
||||||
it { is_expected.to eq('24/12/2015 14:10') }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'last_update' do
|
|
||||||
subject { super().last_update }
|
|
||||||
it { is_expected.to eq('24/12/2015 14:10') }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe FranceConnectInformationDecorator do
|
|
||||||
let(:gender) { 'female' }
|
|
||||||
let(:france_connect_information) { create :france_connect_information, gender: gender }
|
|
||||||
|
|
||||||
subject { france_connect_information.decorate.gender_fr }
|
|
||||||
|
|
||||||
context 'when france connect user is a male' do
|
|
||||||
let(:gender) { 'male' }
|
|
||||||
it { is_expected.to eq 'M.' }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when france connect user is a female' do
|
|
||||||
it { is_expected.to eq 'Mme' }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,28 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ProcedureDecorator do
|
|
||||||
let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) }
|
|
||||||
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.zone.local(2015, 12, 24, 14, 10)) }
|
|
||||||
|
|
||||||
subject { procedure.decorate }
|
|
||||||
|
|
||||||
describe 'created_at_fr' do
|
|
||||||
subject { super().created_at_fr }
|
|
||||||
it { is_expected.to eq('24/12/2015 14:10') }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'published_at_fr' do
|
|
||||||
subject { super().published_at_fr }
|
|
||||||
it { is_expected.to eq('24/12/2017 14:12') }
|
|
||||||
|
|
||||||
context 'published_at is nil' do
|
|
||||||
let(:published_at) { nil }
|
|
||||||
it { is_expected.to eq(nil) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'logo_img' do
|
|
||||||
subject { super().logo_img }
|
|
||||||
it { is_expected.to match(/http.*#{ActionController::Base.helpers.image_url("marianne.svg")}/) }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,18 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe ProceduresDecorator do
|
|
||||||
before do
|
|
||||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
|
||||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
|
||||||
create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:procedure) { Procedure.all.page(1) }
|
|
||||||
|
|
||||||
subject { procedure.decorate }
|
|
||||||
|
|
||||||
it { expect(subject.current_page).not_to be_nil }
|
|
||||||
it { expect(subject.limit_value).not_to be_nil }
|
|
||||||
it { expect(subject.count).to eq(3) }
|
|
||||||
it { expect(subject.total_pages).not_to be_nil }
|
|
||||||
end
|
|
|
@ -1,52 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe TypeDeChampDecorator do
|
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:url) { 'http://localhost' }
|
|
||||||
let(:params) { { url: url, index: index } }
|
|
||||||
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
|
||||||
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
|
|
||||||
let!(:type_de_champ_2) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
|
||||||
|
|
||||||
describe '#button_up' do
|
|
||||||
describe 'with first piece justificative' do
|
|
||||||
let(:index) { 0 }
|
|
||||||
subject { type_de_champ_0.decorate }
|
|
||||||
let(:button_up) { type_de_champ_.decorate }
|
|
||||||
|
|
||||||
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/)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with second out of three piece justificative' do
|
|
||||||
let(:index) { 1 }
|
|
||||||
subject { type_de_champ_1.decorate }
|
|
||||||
let(:button_up) { type_de_champ_1.decorate }
|
|
||||||
|
|
||||||
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 match(/fa-chevron-down/)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'with last piece justificative' do
|
|
||||||
let(:index) { 2 }
|
|
||||||
subject { type_de_champ_2.decorate }
|
|
||||||
let(:button_up) { type_de_champ_1.decorate }
|
|
||||||
|
|
||||||
it 'returns a button up' do
|
|
||||||
expect(subject.button_up(params)).to match(/fa-chevron-up/)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'hide a button down' do
|
|
||||||
expect(subject.button_down(params)).to include('visibility: hidden')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +1,9 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe TypeDePieceJustificativeDecorator do
|
RSpec.describe AdminFormulaireHelper, type: :helper do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
let(:kind) { 'piece_justificative' }
|
||||||
let(:url) { 'http://localhost' }
|
let(:url) { 'http://localhost' }
|
||||||
let(:params) { { url: url, index: index } }
|
|
||||||
let!(:type_de_piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
|
let!(:type_de_piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
|
||||||
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
|
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
|
||||||
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
|
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
|
||||||
|
@ -11,40 +11,51 @@ describe TypeDePieceJustificativeDecorator do
|
||||||
describe '#button_up' do
|
describe '#button_up' do
|
||||||
describe 'with first piece justificative' do
|
describe 'with first piece justificative' do
|
||||||
let(:index) { 0 }
|
let(:index) { 0 }
|
||||||
subject { type_de_piece_justificative_0.decorate }
|
|
||||||
let(:button_up) { type_de_piece_justificative_.decorate }
|
|
||||||
|
|
||||||
it 'returns a button up' do
|
it 'returns a button up' do
|
||||||
expect(subject.button_up(params)).to be(nil)
|
expect(button_up(procedure, kind, index, url)).to be(nil)
|
||||||
end
|
|
||||||
it 'returns a button down' do
|
|
||||||
expect(subject.button_down(params)).to match(/fa-chevron-down/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with second out of three piece justificative' do
|
describe 'with second out of three piece justificative' do
|
||||||
let(:index) { 1 }
|
let(:index) { 1 }
|
||||||
subject { type_de_piece_justificative_1.decorate }
|
|
||||||
let(:button_up) { type_de_piece_justificative_1.decorate }
|
|
||||||
|
|
||||||
it 'returns a button up' do
|
it 'returns a button up' do
|
||||||
expect(subject.button_up(params)).to match(/fa-chevron-up/)
|
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
|
||||||
end
|
|
||||||
it 'returns a button down' do
|
|
||||||
expect(subject.button_down(params)).to match(/fa-chevron-down/)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with last piece justificative' do
|
describe 'with last piece justificative' do
|
||||||
let(:index) { 2 }
|
let(:index) { 2 }
|
||||||
subject { type_de_piece_justificative_2.decorate }
|
|
||||||
let(:button_up) { type_de_piece_justificative_1.decorate }
|
|
||||||
|
|
||||||
it 'returns a button up' do
|
it 'returns a button up' do
|
||||||
expect(subject.button_up(params)).to match(/fa-chevron-up/)
|
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#button_down' do
|
||||||
|
describe 'with first piece justificative' do
|
||||||
|
let(:index) { 0 }
|
||||||
|
|
||||||
it 'returns a button down' do
|
it 'returns a button down' do
|
||||||
expect(subject.button_down(params)).to be(nil)
|
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'with second out of three piece justificative' do
|
||||||
|
let(:index) { 1 }
|
||||||
|
|
||||||
|
it 'returns a button down' do
|
||||||
|
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'with last piece justificative' do
|
||||||
|
let(:index) { 2 }
|
||||||
|
|
||||||
|
it 'returns nil' do
|
||||||
|
expect(button_down(procedure, kind, index, url)).to be(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,12 +1,11 @@
|
||||||
require 'spec_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ChampDecorator do
|
RSpec.describe ChampHelper, type: :helper do
|
||||||
let(:type_de_champ) { create(:type_de_champ) }
|
let(:type_de_champ) { create(:type_de_champ) }
|
||||||
let(:champ) { type_de_champ.champ.create }
|
let(:champ) { type_de_champ.champ.create }
|
||||||
let(:decorator) { champ.decorate }
|
|
||||||
|
|
||||||
describe 'value' do
|
describe '.formatted_value' do
|
||||||
subject { decorator.value }
|
subject { formatted_value(champ) }
|
||||||
|
|
||||||
describe 'for a checkbox' do
|
describe 'for a checkbox' do
|
||||||
let(:type_de_champ) { create(:type_de_champ_checkbox) }
|
let(:type_de_champ) { create(:type_de_champ_checkbox) }
|
9
spec/helpers/procedure_helper_spec.rb
Normal file
9
spec/helpers/procedure_helper_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
RSpec.describe ProcedureHelper, type: :helper do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
describe ".logo_img" do
|
||||||
|
subject { logo_img(procedure) }
|
||||||
|
|
||||||
|
it { is_expected.to match(/#{ActionController::Base.helpers.image_url("marianne.svg")}/) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -40,24 +40,4 @@ describe DropDownList do
|
||||||
|
|
||||||
it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) }
|
it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) }
|
||||||
end
|
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) { build(:type_de_champ_multiple_drop_down_list) }
|
|
||||||
let(:champ) { type_de_champ.champ.build(value: '["1","2"]').decorate }
|
|
||||||
|
|
||||||
it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when simple' do
|
|
||||||
let(:type_de_champ) { build(:type_de_champ_drop_down_list) }
|
|
||||||
let(:champ) { type_de_champ.champ.build(value: '1').decorate }
|
|
||||||
|
|
||||||
it { expect(dropdownlist.selected_options(champ)).to match(['1']) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -264,26 +264,32 @@ describe Procedure do
|
||||||
describe '#switch_types_de_champ' do
|
describe '#switch_types_de_champ' do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:index) { 0 }
|
let(:index) { 0 }
|
||||||
subject { procedure.switch_types_de_champ index }
|
subject { procedure.switch_types_de_champ(index) }
|
||||||
|
|
||||||
context 'when procedure have no types_de_champ' do
|
context 'when procedure has no types_de_champ' do
|
||||||
it { expect(subject).to eq(false) }
|
it { expect(subject).to eq(false) }
|
||||||
end
|
end
|
||||||
context 'when procedure have 2 types de champ' do
|
context 'when procedure has 3 types de champ' do
|
||||||
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
||||||
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
|
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
|
||||||
|
let!(:type_de_champ_2) { create(:type_de_champ, procedure: procedure, order_place: 2) }
|
||||||
context 'when index is not the last element' do
|
context 'when index is not the last element' do
|
||||||
it { expect(subject).to eq(true) }
|
it { expect(subject).to eq(true) }
|
||||||
it 'switch order place' do
|
it 'switches the position of the champ N and N+1' do
|
||||||
procedure.switch_types_de_champ index
|
subject
|
||||||
type_de_champ_0.reload
|
expect(procedure.types_de_champ[0]).to eq(type_de_champ_1)
|
||||||
type_de_champ_1.reload
|
expect(procedure.types_de_champ[0].order_place).to eq(0)
|
||||||
expect(type_de_champ_0.order_place).to eq(1)
|
expect(procedure.types_de_champ[1]).to eq(type_de_champ_0)
|
||||||
expect(type_de_champ_1.order_place).to eq(0)
|
expect(procedure.types_de_champ[1].order_place).to eq(1)
|
||||||
|
end
|
||||||
|
it 'doesn’t move other types de champ' do
|
||||||
|
subject
|
||||||
|
expect(procedure.types_de_champ[2]).to eq(type_de_champ_2)
|
||||||
|
expect(procedure.types_de_champ[2].order_place).to eq(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context 'when index is the last element' do
|
context 'when index is the last element' do
|
||||||
let(:index) { 1 }
|
let(:index) { 2 }
|
||||||
it { expect(subject).to eq(false) }
|
it { expect(subject).to eq(false) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,18 +36,18 @@ 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, procedure: procedure, order_place: 0) }
|
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
||||||
it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_down_0') }
|
||||||
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_up_0') }
|
||||||
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
|
||||||
context 'when there are 2 fields in database' do
|
context 'when there are 2 fields in database' do
|
||||||
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
|
||||||
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
|
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
|
||||||
|
it { expect(subject).not_to have_css('#btn_up_0') }
|
||||||
it { expect(subject).to have_css('#btn_down_0') }
|
it { expect(subject).to have_css('#btn_down_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).to have_css('#btn_down_1[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_down_1') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,8 +44,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).to have_css('#btn_down_0[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_down_0') }
|
||||||
it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_up_0') }
|
||||||
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
|
||||||
|
@ -53,9 +53,9 @@ 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).to have_css('#btn_up_0[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_up_0') }
|
||||||
it { expect(subject).to have_css('#btn_up_1') }
|
it { expect(subject).to have_css('#btn_up_1') }
|
||||||
it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
|
it { expect(subject).not_to have_css('#btn_down_1') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue