From b9a20da33003077d4c30d488c324a1d215cdd1fd Mon Sep 17 00:00:00 2001 From: bach Date: Fri, 17 Mar 2023 14:04:20 +0100 Subject: [PATCH] concernement form concernement improved --- src/composer.json | 1 + src/composer.lock | 50 ++++++++++++++++++- ...field_override.node.concernement.title.yml | 2 +- ...form_display.node.concernement.default.yml | 36 ++++++++++--- ...ntity_form_display.node.entite.default.yml | 4 +- ....paragraph.entite_concernement.default.yml | 16 ++++-- ..._form_display.paragraph.source.default.yml | 31 ++++++------ ....paragraph.entite_concernement.default.yml | 11 ++++ src/config/sync/core.extension.yml | 1 + .../core.menu.static_menu_link_overrides.yml | 14 +++++- ....field.node.concernement.field_caillou.yml | 2 +- ...ld.node.concernement.field_description.yml | 2 +- ...graph.entite_concernement.field_active.yml | 23 +++++++++ ...eld.paragraph.source.field_description.yml | 2 +- .../field.storage.paragraph.field_active.yml | 18 +++++++ ...hs.paragraphs_type.entite_concernement.yml | 2 +- src/config/sync/views.view.admin_nodes.yml | 27 ++++++++-- .../ouatminimal_theme/css/ouatminimal.css | 23 +++++++++ .../ouatminimal_theme/ouatminimal.theme | 40 ++++++++++++++- .../templates/form/input.html.twig | 15 ++++++ 20 files changed, 277 insertions(+), 43 deletions(-) create mode 100644 src/config/sync/field.field.paragraph.entite_concernement.field_active.yml create mode 100644 src/config/sync/field.storage.paragraph.field_active.yml create mode 100644 src/web/themes/custom/ouatminimal_theme/templates/form/input.html.twig diff --git a/src/composer.json b/src/composer.json index c5c264f..354d503 100644 --- a/src/composer.json +++ b/src/composer.json @@ -20,6 +20,7 @@ "drupal/administerusersbyrole": "^3.3", "drupal/amswap": "^3.1", "drupal/audiofield": "1.x-dev@dev", + "drupal/base_field_override_ui": "^1.1", "drupal/core-composer-scaffold": "^9.4", "drupal/core-project-message": "^9.4", "drupal/core-recommended": "^9.4", diff --git a/src/composer.lock b/src/composer.lock index 793813c..5b12704 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4c0284e2283429a9a3564df19923e993", + "content-hash": "0dc54aabca9896a49a4cb27bfda2b2c9", "packages": [ { "name": "alchemy/zippy", @@ -2839,6 +2839,54 @@ "source": "https://git.drupalcode.org/project/autologout" } }, + { + "name": "drupal/base_field_override_ui", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/base_field_override_ui.git", + "reference": "8.x-1.1" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/base_field_override_ui-8.x-1.1.zip", + "reference": "8.x-1.1", + "shasum": "28c7f67ace8a285deb84c373df4589df13b823fb" + }, + "require": { + "drupal/core": "^8.8 || ^9 || ^10" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-1.1", + "datestamp": "1671410225", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "mnico", + "homepage": "https://www.drupal.org/user/1119544" + } + ], + "description": "Enables the possibility to easily override the base fields of any content entity type with an user interface", + "homepage": "https://www.drupal.org/project/base_field_override_ui", + "keywords": [ + "Drupal" + ], + "support": { + "source": "https://git.drupalcode.org/project/base_field_override_ui", + "issues": "https://www.drupal.org/project/issues/base_field_override_ui" + } + }, { "name": "drupal/better_exposed_filters", "version": "5.2.0", diff --git a/src/config/sync/core.base_field_override.node.concernement.title.yml b/src/config/sync/core.base_field_override.node.concernement.title.yml index e799469..e0ffdc9 100644 --- a/src/config/sync/core.base_field_override.node.concernement.title.yml +++ b/src/config/sync/core.base_field_override.node.concernement.title.yml @@ -9,7 +9,7 @@ field_name: title entity_type: node bundle: concernement label: Nom -description: '' +description: 'Quel est l''être / l''élément / l''entité / l''activité indispensable à votre existence dont vous avez appris que son maintien était menacé ?' required: true translatable: true default_value: { } diff --git a/src/config/sync/core.entity_form_display.node.concernement.default.yml b/src/config/sync/core.entity_form_display.node.concernement.default.yml index f912912..cb2cd23 100644 --- a/src/config/sync/core.entity_form_display.node.concernement.default.yml +++ b/src/config/sync/core.entity_form_display.node.concernement.default.yml @@ -9,8 +9,10 @@ dependencies: - field.field.node.concernement.field_recit - node.type.concernement module: + - advanced_text_formatter - field_group - file + - maxlength - paragraphs third_party_settings: field_group: @@ -18,6 +20,7 @@ third_party_settings: children: - group_contenu - group_entites + - group_recit - status - uid - created @@ -35,10 +38,9 @@ third_party_settings: group_contenu: children: - title - - field_caillou - field_description - - field_recit - label: Contenu + - field_caillou + label: Concernement region: content parent_name: group_tabs weight: 12 @@ -65,6 +67,21 @@ third_party_settings: formatter: closed description: '' required_fields: true + group_recit: + children: + - field_recit + label: Récit + region: content + parent_name: group_tabs + weight: 14 + format_type: tab + format_settings: + classes: '' + show_empty_fields: false + id: '' + formatter: closed + description: '' + required_fields: true id: node.concernement.default targetEntityType: node bundle: concernement @@ -78,7 +95,7 @@ content: third_party_settings: { } field_caillou: type: string_textarea - weight: 1 + weight: 2 region: content settings: rows: 5 @@ -86,7 +103,7 @@ content: third_party_settings: { } field_description: type: string_textarea - weight: 2 + weight: 1 region: content settings: rows: 5 @@ -123,9 +140,14 @@ content: weight: 0 region: content settings: - size: 60 + size: 80 placeholder: '' - third_party_settings: { } + third_party_settings: + maxlength: + maxlength_js: null + maxlength_js_label: 'Contenu limité à @limit caractères, restant : @remaining' + advanced_text_formatter: + show_token_tree: 0 uid: type: entity_reference_autocomplete weight: 16 diff --git a/src/config/sync/core.entity_form_display.node.entite.default.yml b/src/config/sync/core.entity_form_display.node.entite.default.yml index c7c62f7..15144e3 100644 --- a/src/config/sync/core.entity_form_display.node.entite.default.yml +++ b/src/config/sync/core.entity_form_display.node.entite.default.yml @@ -101,8 +101,8 @@ content: weight: 0 region: content settings: - size: 60 - placeholder: '' + size: 80 + placeholder: 'Pouvez-vous nommer par qui ou par quoi "CONCERNEMENT" est menacé ou maintenu ? ' third_party_settings: maxlength: maxlength_js: null diff --git a/src/config/sync/core.entity_form_display.paragraph.entite_concernement.default.yml b/src/config/sync/core.entity_form_display.paragraph.entite_concernement.default.yml index 8520312..ce900d2 100644 --- a/src/config/sync/core.entity_form_display.paragraph.entite_concernement.default.yml +++ b/src/config/sync/core.entity_form_display.paragraph.entite_concernement.default.yml @@ -3,6 +3,7 @@ langcode: fr status: true dependencies: config: + - field.field.paragraph.entite_concernement.field_active - field.field.paragraph.entite_concernement.field_actuel_future - field.field.paragraph.entite_concernement.field_entite - field.field.paragraph.entite_concernement.field_menace_maintien_degres @@ -15,15 +16,22 @@ targetEntityType: paragraph bundle: entite_concernement mode: default content: + field_active: + type: boolean_checkbox + weight: 0 + region: content + settings: + display_label: true + third_party_settings: { } field_actuel_future: type: options_buttons - weight: 0 + weight: 1 region: content settings: { } third_party_settings: { } field_entite: type: inline_entity_form_complex - weight: 3 + weight: 4 region: content settings: form_mode: default @@ -40,14 +48,14 @@ content: third_party_settings: { } field_menace_maintien_degres: type: number - weight: 1 + weight: 2 region: content settings: placeholder: '' third_party_settings: { } field_prise: type: number - weight: 2 + weight: 3 region: content settings: placeholder: '' diff --git a/src/config/sync/core.entity_form_display.paragraph.source.default.yml b/src/config/sync/core.entity_form_display.paragraph.source.default.yml index f1a7d54..ccbcd28 100644 --- a/src/config/sync/core.entity_form_display.paragraph.source.default.yml +++ b/src/config/sync/core.entity_form_display.paragraph.source.default.yml @@ -25,7 +25,6 @@ third_party_settings: field_group: group_tabs: children: - - group_texte - group_media - group_videos - group_audio @@ -34,7 +33,7 @@ third_party_settings: label: Tabs region: content parent_name: '' - weight: 0 + weight: 2 format_type: tabs format_settings: classes: '' @@ -43,13 +42,11 @@ third_party_settings: direction: horizontal width_breakpoint: 640 group_texte: - children: - - field_date - - field_description - label: Texte - region: content - parent_name: group_tabs - weight: 20 + children: { } + label: 'Experience vécue' + region: hidden + parent_name: '' + weight: 3 format_type: tab format_settings: classes: '' @@ -64,7 +61,7 @@ third_party_settings: label: Images region: content parent_name: group_tabs - weight: 21 + weight: 31 format_type: tab format_settings: classes: '' @@ -79,7 +76,7 @@ third_party_settings: label: Liens region: content parent_name: group_tabs - weight: 25 + weight: 35 format_type: tab format_settings: classes: '' @@ -93,7 +90,7 @@ third_party_settings: label: Details region: hidden parent_name: '' - weight: 1 + weight: 6 format_type: details format_settings: classes: '' @@ -108,7 +105,7 @@ third_party_settings: label: Documents region: content parent_name: group_tabs - weight: 24 + weight: 34 format_type: tab format_settings: classes: '' @@ -123,7 +120,7 @@ third_party_settings: label: Videos region: content parent_name: group_tabs - weight: 22 + weight: 32 format_type: tab format_settings: classes: '' @@ -138,7 +135,7 @@ third_party_settings: label: Audio region: content parent_name: group_tabs - weight: 23 + weight: 33 format_type: tab format_settings: classes: '' @@ -161,13 +158,13 @@ content: third_party_settings: { } field_date: type: datetime_default - weight: 29 + weight: 0 region: content settings: { } third_party_settings: { } field_description: type: string_textarea - weight: 30 + weight: 1 region: content settings: rows: 8 diff --git a/src/config/sync/core.entity_view_display.paragraph.entite_concernement.default.yml b/src/config/sync/core.entity_view_display.paragraph.entite_concernement.default.yml index 93b0a6f..1eb3c2b 100644 --- a/src/config/sync/core.entity_view_display.paragraph.entite_concernement.default.yml +++ b/src/config/sync/core.entity_view_display.paragraph.entite_concernement.default.yml @@ -3,6 +3,7 @@ langcode: fr status: true dependencies: config: + - field.field.paragraph.entite_concernement.field_active - field.field.paragraph.entite_concernement.field_actuel_future - field.field.paragraph.entite_concernement.field_entite - field.field.paragraph.entite_concernement.field_menace_maintien_degres @@ -15,6 +16,16 @@ targetEntityType: paragraph bundle: entite_concernement mode: default content: + field_active: + type: boolean + label: above + settings: + format: default + format_custom_false: '' + format_custom_true: '' + third_party_settings: { } + weight: 6 + region: content field_actuel_future: type: list_default label: above diff --git a/src/config/sync/core.extension.yml b/src/config/sync/core.extension.yml index dbc8e32..6681174 100644 --- a/src/config/sync/core.extension.yml +++ b/src/config/sync/core.extension.yml @@ -14,6 +14,7 @@ module: audiofield: 0 autocomplete_deluxe: 0 ban: 0 + base_field_override_ui: 0 better_exposed_filters: 0 betterlogin: 0 block: 0 diff --git a/src/config/sync/core.menu.static_menu_link_overrides.yml b/src/config/sync/core.menu.static_menu_link_overrides.yml index d78b0e6..0ca1072 100644 --- a/src/config/sync/core.menu.static_menu_link_overrides.yml +++ b/src/config/sync/core.menu.static_menu_link_overrides.yml @@ -1,4 +1,16 @@ _core: default_config_hash: jdY7AU0tU-QsjmiOw3W8vwpYMb-By--_MSFgbqKUTYM langcode: fr -definitions: { } +definitions: + admin_menus__entitees: + enabled: false + menu_name: administrator + parent: admin_menus.contents + expanded: false + weight: 2 + admin_menus__concernements: + enabled: false + menu_name: administrator + parent: admin_menus.contents + expanded: false + weight: 0 diff --git a/src/config/sync/field.field.node.concernement.field_caillou.yml b/src/config/sync/field.field.node.concernement.field_caillou.yml index 2d49045..6b4998f 100644 --- a/src/config/sync/field.field.node.concernement.field_caillou.yml +++ b/src/config/sync/field.field.node.concernement.field_caillou.yml @@ -10,7 +10,7 @@ field_name: field_caillou entity_type: node bundle: concernement label: Caillou -description: '' +description: 'Pouvez-vous décrire votre caillou dans votre chaussure, et en quoi il vous fait mal au pied quand vous marchez ?' required: false translatable: false default_value: { } diff --git a/src/config/sync/field.field.node.concernement.field_description.yml b/src/config/sync/field.field.node.concernement.field_description.yml index 818cffc..c4673dd 100644 --- a/src/config/sync/field.field.node.concernement.field_description.yml +++ b/src/config/sync/field.field.node.concernement.field_description.yml @@ -10,7 +10,7 @@ field_name: field_description entity_type: node bundle: concernement label: Description -description: '' +description: 'Pouvez-vous décrire précisément en quelques lignes en quoi la présence de cet élément vous est indispensable ?' required: false translatable: false default_value: { } diff --git a/src/config/sync/field.field.paragraph.entite_concernement.field_active.yml b/src/config/sync/field.field.paragraph.entite_concernement.field_active.yml new file mode 100644 index 0000000..0495ce3 --- /dev/null +++ b/src/config/sync/field.field.paragraph.entite_concernement.field_active.yml @@ -0,0 +1,23 @@ +uuid: c96c90fd-bae7-432a-b3f4-2f5af2961f6a +langcode: fr +status: true +dependencies: + config: + - field.storage.paragraph.field_active + - paragraphs.paragraphs_type.entite_concernement +id: paragraph.entite_concernement.field_active +field_name: field_active +entity_type: paragraph +bundle: entite_concernement +label: Active +description: '' +required: false +translatable: false +default_value: + - + value: 1 +default_value_callback: '' +settings: + on_label: Activé + off_label: Désactivé +field_type: boolean diff --git a/src/config/sync/field.field.paragraph.source.field_description.yml b/src/config/sync/field.field.paragraph.source.field_description.yml index 241a758..529f099 100644 --- a/src/config/sync/field.field.paragraph.source.field_description.yml +++ b/src/config/sync/field.field.paragraph.source.field_description.yml @@ -9,7 +9,7 @@ id: paragraph.source.field_description field_name: field_description entity_type: paragraph bundle: source -label: Description +label: 'Experience vécue' description: '' required: false translatable: false diff --git a/src/config/sync/field.storage.paragraph.field_active.yml b/src/config/sync/field.storage.paragraph.field_active.yml new file mode 100644 index 0000000..362f6a8 --- /dev/null +++ b/src/config/sync/field.storage.paragraph.field_active.yml @@ -0,0 +1,18 @@ +uuid: 5f8e42de-33cb-4ee3-a280-d514875437d0 +langcode: fr +status: true +dependencies: + module: + - paragraphs +id: paragraph.field_active +field_name: field_active +entity_type: paragraph +type: boolean +settings: { } +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/src/config/sync/paragraphs.paragraphs_type.entite_concernement.yml b/src/config/sync/paragraphs.paragraphs_type.entite_concernement.yml index c8e387a..8763523 100644 --- a/src/config/sync/paragraphs.paragraphs_type.entite_concernement.yml +++ b/src/config/sync/paragraphs.paragraphs_type.entite_concernement.yml @@ -3,7 +3,7 @@ langcode: fr status: true dependencies: { } id: entite_concernement -label: 'Entité intégrée' +label: Entité icon_uuid: null icon_default: null description: 'Paragraphe qui pointe un CT entité et y ajoute les infos propre au concernement' diff --git a/src/config/sync/views.view.admin_nodes.yml b/src/config/sync/views.view.admin_nodes.yml index ba3bfb9..058c939 100644 --- a/src/config/sync/views.view.admin_nodes.yml +++ b/src/config/sync/views.view.admin_nodes.yml @@ -5,6 +5,8 @@ dependencies: config: - node.type.concernement - node.type.entite + - user.role.admin + - user.role.root module: - content_lock - node @@ -120,9 +122,11 @@ display: sort_asc_label: Asc sort_desc_label: Desc access: - type: perm + type: role options: - perm: 'access content' + role: + admin: admin + root: root cache: type: tag options: { } @@ -288,7 +292,7 @@ display: - url - url.query_args - 'user.node_grants:view' - - user.permissions + - user.roles tags: { } page_1: id: page_1 @@ -738,6 +742,12 @@ display: multi_type: separator separator: ', ' field_api_classes: false + access: + type: role + options: + role: + admin: admin + root: root filters: status: id: status @@ -830,6 +840,7 @@ display: groups: 1: AND defaults: + access: false fields: false filters: false filter_groups: false @@ -859,7 +870,7 @@ display: - url - url.query_args - 'user.node_grants:view' - - user.permissions + - user.roles tags: { } page_2: id: page_2 @@ -1310,6 +1321,11 @@ display: multi_type: separator separator: ', ' field_api_classes: false + access: + type: role + options: + role: + root: root filters: status: id: status @@ -1482,6 +1498,7 @@ display: separator: '' hide_empty: false defaults: + access: false title: false style: false row: false @@ -1514,5 +1531,5 @@ display: - url - url.query_args - 'user.node_grants:view' - - user.permissions + - user.roles tags: { } diff --git a/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css b/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css index 71bfa20..6a3a8a0 100644 --- a/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css +++ b/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css @@ -188,6 +188,29 @@ margin-left: 200px; } + +#node-concernement-edit-form .field--name-title label, +#node-concernement-edit-form .field--name-field-description label, +#node-concernement-edit-form .field--name-field-caillou label, +#node-concernement-form .field--name-title label, +#node-concernement-form .field--name-field-description label, +#node-concernement-form .field--name-field-caillou label{ + display: none; +} + +#node-concernement-edit-form .field--name-title>.form-item>div, +#node-concernement-edit-form .field--name-field-description>.form-item>div, +#node-concernement-edit-form .field--name-field-caillou>.form-item>div, +#node-concernement-form .field--name-title>.form-item>div, +#node-concernement-form .field--name-field-description>.form-item>div, +#node-concernement-form .field--name-field-caillou>.form-item>div{ + font-weight: 600; +} + +#node-concernement-edit-form .ief-entity-operations input[type="submit"].ief-submit-remove{ + display: none; +} + #boussole-layout{ display: flex; flex-direction: row; diff --git a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme index a9979a6..5a5f2d5 100644 --- a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme +++ b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme @@ -5,10 +5,13 @@ * Functions to support theming in the Seven theme. */ +use Drupal\breakpoint\Breakpoint; use Drupal\Core\Form\FormStateInterface; use \Drupal\Core\Url; use Drupal\Core\Render\Markup; +use function Psy\debug; + /** * Implements hook_preprocess_HOOK() for HTML document templates. */ @@ -115,11 +118,46 @@ function ouatminimal_preprocess_toolbar(&$variables) { } function ouatminimal_preprocess_form_element(&$variables) { + $element = $variables['element']; + if(isset($variables['description_display'])){ $variables['description_display']="before"; } } function ouatminimal_preprocess_node_edit_form__node_concernement(&$variables) { - $variables['form']['advanced']['#group'] = "group_admin"; + // $variables['form']['advanced']['#group'] = "group_admin"; + // $ph = $variables['form']['title']['widget'][0]['value']['#placeholder']; + // $variables['form']['title']['widget']['#description'] = $ph; + // $variables['form']['title']['widget'][0]['#description'] = $ph; + // $variables['form']['title']['widget'][0]['value']['#description'] = $ph; + + + // $variables['form']['title']['widget']['#title'] = $ph; + // $variables['form']['title']['widget'][0]['#title'] = $ph; + // $variables['form']['title']['widget'][0]['value']['#title'] = $ph; + // $variables['form']['title']['widget'][0]['value']['#placeholder'] = ""; +} + +function ouatminimal_preprocess_input(&$variables) { + $element = &$variables['element']; + if ($element['#type'] === "submit") { + // edit-field-entite-0-subform-field-entite-actions-ief-add + $name = $element['#name']; + + // rename entité reference in paragraphe "add node" to "editer entité" + if (preg_match('/^ief-field_entite-\d+-subform-field_entite-form-add$/', $name)) { + $element['#value'] = $element['#attributes']['value'] = $variables['attributes']['value'] = "Editer l'entité"; + } + // rename remove (paragraphe) to "supprimer" + if (preg_match('/field_entite_\d+_remove/', $name)) { + $element['#value'] = $element['#attributes']['value'] = $variables['attributes']['value'] = "Supprimer"; + } + + // hide remove node ref submit + if (preg_match('/^ief-field_entite-\d+-subform-field_entite-form-entity-remove-\d+$/', $name)) { + $element['#value'] = $element['#attributes']['value'] = $variables['attributes']['value'] = "test"; + $variables['attributes']['class'][] = 'ief-submit-remove'; + } + } } \ No newline at end of file diff --git a/src/web/themes/custom/ouatminimal_theme/templates/form/input.html.twig b/src/web/themes/custom/ouatminimal_theme/templates/form/input.html.twig new file mode 100644 index 0000000..1409c25 --- /dev/null +++ b/src/web/themes/custom/ouatminimal_theme/templates/form/input.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Default theme implementation for an 'input' #type form element. + * + * Available variables: + * - attributes: A list of HTML attributes for the input element. + * - children: Optional additional rendered elements. + * + * @see template_preprocess_input() + * + * @ingroup themeable + */ +#} +{{ children }}