refactor: add draft helper
This commit is contained in:
parent
c80a820054
commit
2da0aa6525
1 changed files with 12 additions and 8 deletions
|
@ -3,10 +3,10 @@ module Administrateurs
|
||||||
before_action :retrieve_procedure, :procedure_revisable?
|
before_action :retrieve_procedure, :procedure_revisable?
|
||||||
|
|
||||||
def create
|
def create
|
||||||
type_de_champ = @procedure.draft_revision.add_type_de_champ(type_de_champ_create_params)
|
type_de_champ = draft.add_type_de_champ(type_de_champ_create_params)
|
||||||
|
|
||||||
if type_de_champ.valid?
|
if type_de_champ.valid?
|
||||||
@coordinate = @procedure.draft_revision.coordinate_for(type_de_champ)
|
@coordinate = draft.coordinate_for(type_de_champ)
|
||||||
reset_procedure
|
reset_procedure
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
else
|
else
|
||||||
|
@ -15,11 +15,11 @@ module Administrateurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
type_de_champ = @procedure.draft_revision.find_and_ensure_exclusive_use(params[:stable_id])
|
type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
|
||||||
|
|
||||||
if type_de_champ.update(type_de_champ_update_params)
|
if type_de_champ.update(type_de_champ_update_params)
|
||||||
if params[:should_render]
|
if params[:should_render]
|
||||||
@coordinate = @procedure.draft_revision.coordinate_for(type_de_champ)
|
@coordinate = draft.coordinate_for(type_de_champ)
|
||||||
end
|
end
|
||||||
reset_procedure
|
reset_procedure
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
|
@ -30,21 +30,21 @@ module Administrateurs
|
||||||
|
|
||||||
def move
|
def move
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
@procedure.draft_revision.move_type_de_champ(params[:stable_id], params[:position].to_i)
|
draft.move_type_de_champ(params[:stable_id], params[:position].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_up
|
def move_up
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
@coordinate = @procedure.draft_revision.move_up_type_de_champ(params[:stable_id])
|
@coordinate = draft.move_up_type_de_champ(params[:stable_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_down
|
def move_down
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
@coordinate = @procedure.draft_revision.move_down_type_de_champ(params[:stable_id])
|
@coordinate = draft.move_down_type_de_champ(params[:stable_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@coordinate = @procedure.draft_revision.remove_type_de_champ(params[:stable_id])
|
@coordinate = draft.remove_type_de_champ(params[:stable_id])
|
||||||
reset_procedure
|
reset_procedure
|
||||||
flash.notice = "Formulaire enregistré"
|
flash.notice = "Formulaire enregistré"
|
||||||
end
|
end
|
||||||
|
@ -81,5 +81,9 @@ module Administrateurs
|
||||||
:znieff
|
:znieff
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draft
|
||||||
|
@procedure.draft_revision
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue