Merge pull request #7985 from demarches-simplifiees/feat/7955
ETQ Super Admin, je veux ajouter / Supprimer des tags à une démarche
This commit is contained in:
commit
a1247ce6e0
9 changed files with 87 additions and 18 deletions
|
@ -3,3 +3,4 @@
|
|||
//= link_tree ../fonts
|
||||
//= link administrate/application.css
|
||||
//= link administrate/application.js
|
||||
//= link manager.css
|
||||
|
|
39
app/assets/stylesheets/manager.css
Normal file
39
app/assets/stylesheets/manager.css
Normal file
|
@ -0,0 +1,39 @@
|
|||
[data-reach-combobox-token-label] {
|
||||
border: 1px solid #CCCCCC;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.form [data-reach-combobox-token-list] {
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.form [data-reach-combobox-input]:not([class^='width-']) {
|
||||
width: 100%;
|
||||
min-width: 50%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.form [data-reach-combobox-token] button {
|
||||
border: solid 1px #CCCCCC;
|
||||
background-color: transparent;
|
||||
color: #333333;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mt-1 {
|
||||
margin-top: 1rem;
|
||||
}
|
|
@ -93,6 +93,16 @@ module Manager
|
|||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
def add_tags
|
||||
tags_h = { tags: JSON.parse(tags_params[:tags]) }
|
||||
if procedure.update(tags_h)
|
||||
flash.notice = "Le modèle est mis à jour."
|
||||
else
|
||||
flash.alert = procedure.errors.full_messages.join(', ')
|
||||
end
|
||||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def procedure
|
||||
|
@ -107,6 +117,10 @@ module Manager
|
|||
params.require(:type_de_champ).permit(:piece_justificative_template)
|
||||
end
|
||||
|
||||
def tags_params
|
||||
params.require(:procedure).permit(:tags)
|
||||
end
|
||||
|
||||
def unfiltered_list?
|
||||
action_name == "index" && !params[:search]
|
||||
end
|
||||
|
|
|
@ -37,7 +37,8 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
attestation_template: AttestationTemplateField,
|
||||
procedure_expires_when_termine_enabled: Field::Boolean,
|
||||
duree_conservation_dossiers_dans_ds: Field::Number,
|
||||
max_duree_conservation_dossiers_dans_ds: Field::Number
|
||||
max_duree_conservation_dossiers_dans_ds: Field::Number,
|
||||
tags: Field::Text
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
@ -64,6 +65,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
:administrateurs,
|
||||
:libelle,
|
||||
:description,
|
||||
:tags,
|
||||
:lien_site_web,
|
||||
:organisation,
|
||||
:zone,
|
||||
|
|
|
@ -11,15 +11,12 @@
|
|||
# ask_birthday :boolean default(FALSE), not null
|
||||
# auto_archive_on :date
|
||||
# cadre_juridique :string
|
||||
# cerfa_flag :boolean default(FALSE)
|
||||
# cloned_from_library :boolean default(FALSE)
|
||||
# closed_at :datetime
|
||||
# declarative_with_state :string
|
||||
# description :string
|
||||
# direction :string
|
||||
# duree_conservation_dossiers_dans_ds :integer
|
||||
# duree_conservation_etendue_par_ds :boolean default(FALSE)
|
||||
# durees_conservation_required :boolean default(TRUE)
|
||||
# encrypted_api_particulier_token :string
|
||||
# euro_flag :boolean default(FALSE)
|
||||
# experts_require_administrateur_invitation :boolean default(FALSE)
|
||||
|
@ -42,7 +39,6 @@
|
|||
# routing_criteria_name :text default("Votre ville")
|
||||
# routing_enabled :boolean
|
||||
# tags :text default([]), is an Array
|
||||
# test_started_at :datetime
|
||||
# unpublished_at :datetime
|
||||
# web_hook_url :string
|
||||
# whitelisted_at :datetime
|
||||
|
|
|
@ -99,18 +99,19 @@
|
|||
|
||||
%p.explication
|
||||
Si votre démarche s’adresse indifféremment à une personne morale ou un particulier, choisissez l'option « Particuliers ». Vous pourrez ajouter un champ SIRET directement dans le formulaire.
|
||||
|
||||
%h3.header-subsection Ajouter des tags
|
||||
%p.explication Les tags sont des mots ou des expressions que vous attribuez aux démarches pour décrire leur contenu et pour les retrouver. Les tags sont partagés avec la communauté, ce qui vous permet de voir les tags attribués aux démarches créées par les autres administrateurs.
|
||||
= hidden_field_tag 'procedure[tags]', nil
|
||||
= react_component("ComboMultiple",
|
||||
options: @existing_tags,
|
||||
selected: [], disabled: [],
|
||||
label: 'Tags',
|
||||
group: '.procedure-form__column--form',
|
||||
name: 'tags',
|
||||
describedby: 'procedure-tags',
|
||||
acceptNewValues: true)
|
||||
- if feature_enabled?(:administrateur_add_tags)
|
||||
%h3.header-subsection Ajouter des tags
|
||||
%p.explication Les tags sont des mots ou des expressions que vous attribuez aux démarches pour décrire leur contenu et pour les retrouver. Les tags sont partagés avec la communauté, ce qui vous permet de voir les tags attribués aux démarches créées par les autres administrateurs.
|
||||
= hidden_field_tag 'procedure[tags]', nil
|
||||
= react_component("ComboMultiple",
|
||||
options: @existing_tags,
|
||||
selected: @procedure.tags,
|
||||
disabled: [],
|
||||
label: 'Tags',
|
||||
group: '.procedure-form__column--form',
|
||||
name: 'tags',
|
||||
describedby: 'procedure-tags',
|
||||
acceptNewValues: true)
|
||||
|
||||
%details.procedure-form__options-details
|
||||
%summary.procedure-form__options-summary
|
||||
|
|
|
@ -15,7 +15,6 @@ as well as a link to its edit page.
|
|||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { t("administrate.actions.show_resource", name: page.page_title) } %>
|
||||
<% procedure = page.resource %>
|
||||
|
||||
|
@ -80,6 +79,21 @@ as well as a link to its edit page.
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if attribute.name == 'tags' %>
|
||||
<%= form_for procedure, url: add_tags_manager_procedure_path(procedure), html: { class: 'form procedure-form__column--form mt-1' } do %>
|
||||
<%= hidden_field_tag 'procedure[tags]', nil %>
|
||||
<%= react_component("ComboMultiple",
|
||||
options: Procedure.tags,
|
||||
selected: procedure.tags,
|
||||
disabled: [],
|
||||
label: 'Tags',
|
||||
group: '.procedure-form__column--form',
|
||||
name: 'tags',
|
||||
describedby: 'procedure-tags',
|
||||
acceptNewValues: true) %>
|
||||
<button class="mt-1">Ajouter des tags</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</dd>
|
||||
<% end %>
|
||||
<dd class="attribute-data">
|
||||
|
|
1
config/initializers/administrate.rb
Normal file
1
config/initializers/administrate.rb
Normal file
|
@ -0,0 +1 @@
|
|||
Administrate::Engine.add_stylesheet('manager.css')
|
|
@ -19,6 +19,7 @@ Rails.application.routes.draw do
|
|||
post 'add_administrateur_and_instructeur', on: :member
|
||||
post 'add_administrateur_with_confirmation', on: :member
|
||||
post 'change_piece_justificative_template', on: :member
|
||||
patch 'add_tags', on: :member
|
||||
get 'export_mail_brouillons', on: :member
|
||||
resources :confirmation_urls, only: :new
|
||||
resources :administrateur_confirmations, only: [:new, :create]
|
||||
|
|
Loading…
Reference in a new issue