rename type_champs into type_champ and change links/routes for procedure : use show instead of edit

This commit is contained in:
Tanguy PATTE 2015-11-17 10:23:05 +01:00
parent 9942525984
commit 5a422c75ac
21 changed files with 84 additions and 48 deletions

View file

@ -88,8 +88,8 @@ function add_new_type_de_champ_params() {
$("#new_type_de_champ .description").attr('id', 'procedure_new_type_de_champ_'+types_de_champ_index+'__description');
$("#new_type_de_champ .description").val('');
$("#new_type_de_champ .type_champs").attr('name', 'procedure[new_type_de_champ[' + types_de_champ_index + ']][type_champs]');
$("#new_type_de_champ .type_champs").attr('id', 'procedure_new_type_de_champ_'+types_de_champ_index+'__type_champs');
$("#new_type_de_champ .type_champ").attr('name', 'procedure[new_type_de_champ[' + types_de_champ_index + ']][type_champ]');
$("#new_type_de_champ .type_champ").attr('id', 'procedure_new_type_de_champ_'+types_de_champ_index+'__type_champ');
$("#new_type_de_champ .order_place").attr('name', 'procedure[new_type_de_champ[' + types_de_champ_index + ']][order_place]');
$("#new_type_de_champ .order_place").attr('id', 'procedure_new_type_de_champ_'+types_de_champ_index+'__order_place');

View file

@ -7,7 +7,7 @@
}
}
.type_champs-text {
.type_champ-text {
@extend .col-md-6;
@extend .col-lg-6;
@ -16,7 +16,7 @@
}
}
.type_champs-textarea {
.type_champ-textarea {
@extend .col-md-8;
@extend .col-lg-8;
@ -26,7 +26,7 @@
}
}
.type_champs-number {
.type_champ-number {
@extend .col-md-3;
@extend .col-lg-3;
@ -35,7 +35,7 @@
}
}
.type_champs-datetime {
.type_champ-datetime {
@extend .col-md-2;
@extend .col-lg-2;

View file

@ -9,7 +9,7 @@ class Admin::TypesDeChampController < AdminController
render json: { message: 'Champ not found' }, status: 404
end
def edit
def show
end
def update
@ -20,7 +20,7 @@ class Admin::TypesDeChampController < AdminController
end
def update_params
params.require(:procedure).permit(types_de_champ_attributes: [:libelle, :description, :order_place, :type_champs, :id])
params.require(:procedure).permit(types_de_champ_attributes: [:libelle, :description, :order_place, :type_champ, :id])
end
private

View file

@ -1,5 +1,5 @@
class Champ < ActiveRecord::Base
belongs_to :dossier
belongs_to :type_de_champ
delegate :libelle, :type_champs, :order_place, to: :type_de_champ
delegate :libelle, :type_champ, :order_place, to: :type_de_champ
end

View file

@ -9,6 +9,6 @@ class TypeDeChamp < ActiveRecord::Base
has_many :champ
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :type_champs, presence: true, allow_blank: false, allow_nil: false
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
# validates :order_place, presence: true, allow_blank: false, allow_nil: false
end

View file

@ -2,7 +2,7 @@
%li
= link_to('Description', admin_procedure_path(@procedure))
%li
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li.active
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))

View file

@ -2,7 +2,7 @@
%li.active
= link_to('Description', admin_procedure_path(@procedure))
%li
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))

View file

@ -6,7 +6,7 @@
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
.form-group
%h4 Type
= ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
= ff.select :type_champ, TypeDeChamp.type_champ, {}, {class: 'form-control type_champ'}
.form-group
%h4 Description
= ff.text_area :description, class: 'form-control description', placeholder: 'Description'
@ -48,7 +48,7 @@
/ .form-group{ style: 'padding-right: 2%' }
/ %h4 Type
/ =ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
/ =ff.select :type_champ, TypeDeChamp.type_champ, {}, {class: 'form-control type_champ'}
/ .form-group{ style: 'padding-right: 2%' }
/ %h4 Description

View file

@ -5,7 +5,7 @@
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
.form-group
%h4 Type
= ff.select :type_champs, TypeDeChamp.type_champs, {}, {class: 'form-control type_champs'}
= ff.select :type_champ, TypeDeChamp.type_champs, {}, {class: 'form-control type_champ'}
.form-group
%h4 Description
= ff.text_area :description, class: 'form-control description', placeholder: 'Description'

View file

@ -2,4 +2,4 @@
= render partial: 'fields', locals: { types_de_champ: @procedure.types_de_champ, f: f }
#new_type_de_champ
= render partial: 'fields', locals: { types_de_champ: TypeDeChamp.new, f: f }
= f.submit "Ajouter un champ", class: 'btn btn-success'
= f.submit "Ajouter un champ", class: 'btn btn-success', id: :add_type_de_champ

View file

@ -2,7 +2,7 @@
%li
= link_to('Description', admin_procedure_path(@procedure))
%li.active
= link_to('Champs', edit_admin_procedure_types_de_champ_path(@procedure))
= link_to('Champs', admin_procedure_types_de_champ_path(@procedure))
%li
= link_to('Pièces justificatives', edit_admin_procedure_pieces_justificatives_path(@procedure))

View file

@ -19,11 +19,11 @@
-unless @champs.nil?
-@champs.each do |champ|
.row
%div{class: "type_champs-#{champ.type_champs}"}
%div{class: "type_champ-#{champ.type_champ}"}
%h4
= champ.libelle
-if champ.type_champs == 'textarea'
-if champ.type_champ == 'textarea'
%textarea.form-control{name:"champs['#{champ.id}']",
placeholder: champ.libelle,
id: "champs_#{champ.id}"}
@ -33,9 +33,9 @@
placeholder: champ.libelle,
id: "champs_#{champ.id}",
value: champ.value,
type:"#{champ.type_champs}",
'data-provide' => ('datepicker' if champ.type_champs == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champs == 'datetime')}
type:"#{champ.type_champ}",
'data-provide' => ('datepicker' if champ.type_champ == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')}
%br
%h3 Documents administratifs