add button save for pj and type de champ
This commit is contained in:
parent
5a9a6226c7
commit
52133c0f43
9 changed files with 46 additions and 0 deletions
|
@ -88,3 +88,14 @@ input#nom_projet {
|
||||||
.logo_fc_small {
|
.logo_fc_small {
|
||||||
max-width: 27px;
|
max-width: 27px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.alert.alert-success.move_up {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0;
|
||||||
|
height: 52px;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 0px;
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ class Admin::PiecesJustificativesController < AdminController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@procedure.update_attributes(update_params)
|
@procedure.update_attributes(update_params)
|
||||||
|
flash.now.notice = 'Modifications sauvegardées'
|
||||||
render 'show', format: :js
|
render 'show', format: :js
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class Admin::TypesDeChampController < AdminController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@procedure.update_attributes(update_params)
|
@procedure.update_attributes(update_params)
|
||||||
|
flash.now.notice = 'Modifications sauvegardées'
|
||||||
render 'show', format: :js
|
render 'show', format: :js
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +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, 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
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
#new_type_de_piece_justificative
|
#new_type_de_piece_justificative
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
<% flash.each do |type, message| %>
|
||||||
|
$("#flash_message").html("<div class=\"alert alert-success move_up\" style=\"display: block:\"> <%= message.html_safe %></div>").children().fadeOut(5000)
|
||||||
|
<% end %>
|
||||||
$('#piece_justificative_form').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure } ) %>");
|
$('#piece_justificative_form').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure } ) %>");
|
|
@ -1,5 +1,6 @@
|
||||||
= form_for [:admin, @procedure], url: admin_procedure_types_de_champ_path(@procedure) , remote: true do |f|
|
= form_for [:admin, @procedure], url: admin_procedure_types_de_champ_path(@procedure) , remote: true do |f|
|
||||||
= render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ_ordered.decorate, f: f }
|
= render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ_ordered.decorate, f: f }
|
||||||
|
= f.submit "Enregistrer", class: 'btn btn-success', id: :save
|
||||||
%hr
|
%hr
|
||||||
#new_type_de_champ
|
#new_type_de_champ
|
||||||
= render partial: 'fields', locals: { types_de_champ: TypeDeChamp.new.decorate, f: f }
|
= render partial: 'fields', locals: { types_de_champ: TypeDeChamp.new.decorate, f: f }
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
<% flash.each do |type, message| %>
|
||||||
|
$("#flash_message").html("<div class=\"alert alert-success move_up\" style=\"display: block:\"> <%= message.html_safe %></div>").children().fadeOut(5000)
|
||||||
|
<% end %>
|
||||||
$('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>");
|
$('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>");
|
|
@ -71,6 +71,19 @@ feature 'add a new type de champs', js: true do
|
||||||
expect(procedure.types_de_champ.count).to eq(1)
|
expect(procedure.types_de_champ.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
context 'user modifies the first one' do
|
||||||
|
let(:new_libelle) { 'my new field' }
|
||||||
|
before do
|
||||||
|
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set(new_libelle)
|
||||||
|
page.find_by_id('save').click
|
||||||
|
wait_for_ajax
|
||||||
|
procedure.reload
|
||||||
|
end
|
||||||
|
scenario 'saves changes in database' do
|
||||||
|
type_de_champ = procedure.types_de_champ.first
|
||||||
|
expect(type_de_champ.libelle).to eq(new_libelle)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,6 +57,18 @@ feature 'add a new type de piece justificative', js: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
context 'when user change existing type de pj' do
|
||||||
|
let(:new_libelle) { 'mon nouveau libelle' }
|
||||||
|
before do
|
||||||
|
page.find_by_id('procedure_types_de_piece_justificative_attributes_0_libelle').set(new_libelle)
|
||||||
|
page.find_by_id('save').click
|
||||||
|
wait_for_ajax
|
||||||
|
end
|
||||||
|
scenario 'saves change in database' do
|
||||||
|
pj = procedure.types_de_piece_justificative.first
|
||||||
|
expect(pj.libelle).to eq(new_libelle)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue