controller
This commit is contained in:
parent
492c7f377f
commit
cf8e6a9c67
1 changed files with 12 additions and 1 deletions
|
@ -63,6 +63,7 @@ module Administrateurs
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@procedure ||= Procedure.new(for_individual: true)
|
@procedure ||= Procedure.new(for_individual: true)
|
||||||
|
@existing_tags = get_existing_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
SIGNIFICANT_DOSSIERS_THRESHOLD = 30
|
SIGNIFICANT_DOSSIERS_THRESHOLD = 30
|
||||||
|
@ -361,7 +362,8 @@ module Administrateurs
|
||||||
{ zone_ids: [] },
|
{ zone_ids: [] },
|
||||||
:lien_dpo,
|
:lien_dpo,
|
||||||
:opendata,
|
:opendata,
|
||||||
:procedure_expires_when_termine_enabled
|
:procedure_expires_when_termine_enabled,
|
||||||
|
:tags
|
||||||
]
|
]
|
||||||
permited_params = if @procedure&.locked?
|
permited_params = if @procedure&.locked?
|
||||||
params.require(:procedure).permit(*editable_params)
|
params.require(:procedure).permit(*editable_params)
|
||||||
|
@ -371,6 +373,9 @@ module Administrateurs
|
||||||
if permited_params[:auto_archive_on].present?
|
if permited_params[:auto_archive_on].present?
|
||||||
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day
|
permited_params[:auto_archive_on] = Date.parse(permited_params[:auto_archive_on]) + 1.day
|
||||||
end
|
end
|
||||||
|
if permited_params[:tags].present?
|
||||||
|
permited_params[:tags] = JSON.parse(permited_params[:tags])
|
||||||
|
end
|
||||||
permited_params
|
permited_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -385,5 +390,11 @@ module Administrateurs
|
||||||
def cloned_from_library?
|
def cloned_from_library?
|
||||||
params[:from_new_from_existing].present?
|
params[:from_new_from_existing].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_existing_tags
|
||||||
|
unnest = Arel::Nodes::NamedFunction.new('UNNEST', [Procedure.arel_table[:tags]])
|
||||||
|
query = Procedure.select(unnest.as('tags')).distinct.order('tags')
|
||||||
|
Procedure.connection.query(query.to_sql).flatten
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue