Use new editor
This commit is contained in:
parent
0d35295d4e
commit
41c9b21509
19 changed files with 186 additions and 30 deletions
|
@ -7,11 +7,20 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def flash_class(level, sticky = false)
|
||||
case level
|
||||
when "notice" then "alert-success#{sticky ? ' sticky' : ''}"
|
||||
when "alert" then "alert-danger#{sticky ? ' sticky' : ''}"
|
||||
def flash_class(level, sticky: false, fixed: false)
|
||||
class_names = case level
|
||||
when 'notice'
|
||||
['alert-success']
|
||||
when 'alert'
|
||||
['alert-danger']
|
||||
end
|
||||
if sticky
|
||||
class_names << 'sticky'
|
||||
end
|
||||
if fixed
|
||||
class_names << 'alert-fixed'
|
||||
end
|
||||
class_names.join(' ')
|
||||
end
|
||||
|
||||
def render_to_element(selector, partial:, outer: false, locals: {})
|
||||
|
@ -22,9 +31,9 @@ module ApplicationHelper
|
|||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def render_flash(timeout: false, sticky: false)
|
||||
def render_flash(timeout: false, sticky: false, fixed: false)
|
||||
if flash.any?
|
||||
html = render_to_element('#flash_messages', partial: 'layouts/flash_messages', locals: { sticky: sticky }, outer: true)
|
||||
html = render_to_element('#flash_messages', partial: 'layouts/flash_messages', locals: { sticky: sticky, fixed: fixed }, outer: true)
|
||||
flash.clear
|
||||
if timeout
|
||||
html += remove_element('#flash_messages', timeout: timeout, inner: true)
|
||||
|
@ -56,6 +65,12 @@ module ApplicationHelper
|
|||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def fire_event(event_name, data)
|
||||
# rubocop:disable Rails/OutputSafety
|
||||
raw("DS.fire('#{event_name}', #{raw(data)});")
|
||||
# rubocop:enable Rails/OutputSafety
|
||||
end
|
||||
|
||||
def current_email
|
||||
current_user&.email ||
|
||||
current_gestionnaire&.email ||
|
||||
|
|
|
@ -33,4 +33,56 @@ module ProcedureHelper
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def types_de_champ_data(procedure)
|
||||
{
|
||||
type: "champ",
|
||||
types_de_champ_options: types_de_champ_options.to_json,
|
||||
types_de_champ: types_de_champ_as_json(procedure.types_de_champ).to_json,
|
||||
direct_uploads_url: rails_direct_uploads_url,
|
||||
drag_icon_url: image_url("icons/drag.svg")
|
||||
}
|
||||
end
|
||||
|
||||
def types_de_champ_private_data(procedure)
|
||||
{
|
||||
type: "annotation",
|
||||
types_de_champ_options: types_de_champ_options.to_json,
|
||||
types_de_champ: types_de_champ_as_json(procedure.types_de_champ_private).to_json,
|
||||
direct_uploads_url: rails_direct_uploads_url,
|
||||
drag_icon_url: image_url("icons/drag.svg")
|
||||
}
|
||||
end
|
||||
|
||||
def procedure_data(procedure)
|
||||
{
|
||||
types_de_champ: types_de_champ_as_json(procedure.types_de_champ),
|
||||
types_de_champ_private: types_de_champ_as_json(procedure.types_de_champ_private)
|
||||
}.to_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
TOGGLES = {
|
||||
TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?,
|
||||
TypeDeChamp.type_champs.fetch(:integer_number) => :champ_integer_number?,
|
||||
TypeDeChamp.type_champs.fetch(:repetition) => :champ_repetition?
|
||||
}
|
||||
|
||||
def types_de_champ_options
|
||||
types_de_champ = TypeDeChamp.type_de_champs_list_fr
|
||||
|
||||
types_de_champ.select! do |tdc|
|
||||
toggle = TOGGLES[tdc.last]
|
||||
toggle.blank? || Flipflop.send(toggle)
|
||||
end
|
||||
|
||||
types_de_champ
|
||||
end
|
||||
|
||||
def types_de_champ_as_json(types_de_champ)
|
||||
types_de_champ.as_json(except: [:created_at, :updated_at],
|
||||
methods: [:piece_justificative_template_filename, :piece_justificative_template_url],
|
||||
include: { drop_down_list: { only: :value } })
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue