Change updated method for type de champs' procedure
This commit is contained in:
parent
4eecba4ce1
commit
e673fe6ae2
6 changed files with 56 additions and 15 deletions
|
@ -32,6 +32,12 @@ function add_new_type_de_champs() {
|
|||
$("#new_type_de_champs #order_place").attr('name', 'type_de_champs[' + types_de_champs_index + '][order_place]');
|
||||
$("#new_type_de_champs #order_place").val(types_de_champs_index+1);
|
||||
|
||||
$("#new_type_de_champs #id_type_de_champs").attr('name', 'type_de_champs[' + types_de_champs_index + '][id_type_de_champs]');
|
||||
$("#new_type_de_champs #id_type_de_champs").val('')
|
||||
|
||||
$("#new_type_de_champs #delete").attr('name', 'type_de_champs[' + types_de_champs_index + '][delete]');
|
||||
$("#new_type_de_champs #delete").val('false')
|
||||
|
||||
$("#new_type_de_champs #add_type_de_champs_button").remove();
|
||||
$("#new_type_de_champs .form-inline").append($("#add_type_de_champs_button"))
|
||||
}
|
||||
|
|
|
@ -59,11 +59,14 @@ class Admin::ProceduresController < ApplicationController
|
|||
private
|
||||
|
||||
def save_types_de_champs_params
|
||||
TypeDeChamps.destroy_all(procedure: @procedure)
|
||||
|
||||
unless params[:type_de_champs].nil? || params[:type_de_champs].size == 0
|
||||
params[:type_de_champs].each do |index, type_de_champs|
|
||||
type_de_champs_tmp = TypeDeChamps.new
|
||||
|
||||
if type_de_champs[:id_type_de_champs].nil? || type_de_champs[:id_type_de_champs] == ''
|
||||
type_de_champs_tmp = TypeDeChamps.new
|
||||
else
|
||||
type_de_champs_tmp = TypeDeChamps.find(type_de_champs[:id_type_de_champs])
|
||||
end
|
||||
|
||||
type_de_champs_tmp.libelle = type_de_champs[:libelle]
|
||||
type_de_champs_tmp.type_champs = type_de_champs[:type]
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
=("#{ type_de_champs.description }" unless type_de_champs.nil? )
|
||||
|
||||
%input#order_place{type: 'hidden', name: "type_de_champs[#{index}][order_place]", value: (("#{ type_de_champs.order_place}" unless type_de_champs.nil?) || index+1)}
|
||||
%input#id_type_de_champs{type: 'hidden', name: "type_de_champs[#{index}][id_type_de_champs]", value: (("#{ type_de_champs.id}" unless type_de_champs.nil?))}
|
||||
%input#delete{type: 'hidden', name: "type_de_champs[#{index}][delete]", value: 'false'}
|
||||
|
||||
-if type_de_champs.nil?
|
||||
.form-group#add_type_de_champs_button
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue