From 329869b9297c6dcdde6f2f617b44d53a327d765b Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:30:18 +0100 Subject: [PATCH 1/8] controllers --- app/controllers/manager/procedures_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index bd4601f92..44337ad38 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -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 From 2bb7b6156bd4bc4a2c47f868cbb6b68651a4f4e6 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:30:32 +0100 Subject: [PATCH 2/8] dashboard --- app/dashboards/procedure_dashboard.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index 79a3451d6..1ba286f85 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -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, From 661e5f78ac844b2036e76530278c49ae8789743a Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:30:41 +0100 Subject: [PATCH 3/8] model --- app/models/procedure.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 0cf1ec739..a9e016e5f 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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 From 86afad6250ff61309e540efbe4869d64d099f7cc Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:30:57 +0100 Subject: [PATCH 4/8] layout --- .../procedures/_informations.html.haml | 25 ++++++++++--------- app/views/manager/procedures/show.html.erb | 16 +++++++++++- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index 384234b90..96c5bf4be 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -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 diff --git a/app/views/manager/procedures/show.html.erb b/app/views/manager/procedures/show.html.erb index 2fe9d0247..add6f0449 100644 --- a/app/views/manager/procedures/show.html.erb +++ b/app/views/manager/procedures/show.html.erb @@ -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) %> + + <% end %> + <% end %> <% end %>
From b5b57b066fc1e18be781f72715fee2321fb824f4 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:31:21 +0100 Subject: [PATCH 5/8] config initializers administrate --- config/initializers/administrate.rb | 1 + 1 file changed, 1 insertion(+) create mode 100644 config/initializers/administrate.rb diff --git a/config/initializers/administrate.rb b/config/initializers/administrate.rb new file mode 100644 index 000000000..3cea41da7 --- /dev/null +++ b/config/initializers/administrate.rb @@ -0,0 +1 @@ +Administrate::Engine.add_stylesheet('manager.css') From 583a08cd6ee3d0dd168bffa2c2db52b3be5d2f08 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:31:45 +0100 Subject: [PATCH 6/8] javascript --- app/assets/config/manifest.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 8890f53b3..f9491d53c 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -3,3 +3,4 @@ //= link_tree ../fonts //= link administrate/application.css //= link administrate/application.js +//= link manager.css From 6a6a9dc006c90d3cef3a0c623e4dd4a644355311 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:32:02 +0100 Subject: [PATCH 7/8] style css --- app/assets/stylesheets/manager.css | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/assets/stylesheets/manager.css diff --git a/app/assets/stylesheets/manager.css b/app/assets/stylesheets/manager.css new file mode 100644 index 000000000..b4f6474fe --- /dev/null +++ b/app/assets/stylesheets/manager.css @@ -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; +} From fee675cbaa99e2c0f6c0679996e461fd58498233 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 31 Oct 2022 19:32:10 +0100 Subject: [PATCH 8/8] routes --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index a03dc0dfa..0d3fc9a68 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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]