From 1735f8f6ac4892597e5d7b0d55011e121a038dfd Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 6 Jul 2023 10:54:44 +0200 Subject: [PATCH] statics can be promoted to front page (for app header menu) --- ...ntity_form_display.node.static.default.yml | 93 ++++++++++++------- ...ntity_view_display.node.static.default.yml | 19 ++-- src/config/sync/user.role.admin.yml | 7 ++ .../graphql/ouatt_extension.base.graphqls | 4 +- .../ouatt_extension.extension.graphqls | 4 + .../SchemaExtension/OuattSchemaExtension.php | 32 +++++++ .../ouatminimal_theme/ouatminimal.theme | 22 +++-- .../node-edit-form--node-static.html.twig | 31 +++++++ 8 files changed, 164 insertions(+), 48 deletions(-) create mode 100644 src/web/themes/custom/ouatminimal_theme/templates/form/node-edit-form--node-static.html.twig diff --git a/src/config/sync/core.entity_form_display.node.static.default.yml b/src/config/sync/core.entity_form_display.node.static.default.yml index 227d9ab..952dd20 100644 --- a/src/config/sync/core.entity_form_display.node.static.default.yml +++ b/src/config/sync/core.entity_form_display.node.static.default.yml @@ -6,8 +6,59 @@ dependencies: - field.field.node.static.body - node.type.static module: - - path + - field_group - text +third_party_settings: + field_group: + group_tabs: + children: + - group_contenu + - group_deta + label: Tabs + region: content + parent_name: '' + weight: 0 + format_type: tabs + format_settings: + classes: '' + show_empty_fields: false + id: '' + direction: vertical + width_breakpoint: 640 + group_contenu: + children: + - title + - body + label: Contenu + region: content + parent_name: group_tabs + weight: 13 + format_type: tab + format_settings: + classes: '' + show_empty_fields: false + id: '' + formatter: open + description: '' + required_fields: true + group_deta: + children: + - status + - promote + - uid + - created + label: Details + 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.static.default targetEntityType: node bundle: static @@ -25,40 +76,20 @@ content: third_party_settings: { } created: type: datetime_timestamp - weight: 4 - region: content - settings: { } - third_party_settings: { } - langcode: - type: language_select - weight: 2 - region: content - settings: - include_locked: true - third_party_settings: { } - path: - type: path - weight: 7 + weight: 5 region: content settings: { } third_party_settings: { } promote: type: boolean_checkbox - weight: 5 + weight: 3 region: content settings: display_label: true third_party_settings: { } status: type: boolean_checkbox - weight: 9 - region: content - settings: - display_label: true - third_party_settings: { } - sticky: - type: boolean_checkbox - weight: 6 + weight: 2 region: content settings: display_label: true @@ -73,7 +104,7 @@ content: third_party_settings: { } uid: type: entity_reference_autocomplete - weight: 3 + weight: 4 region: content settings: match_operator: CONTAINS @@ -81,9 +112,9 @@ content: size: 60 placeholder: '' third_party_settings: { } - url_redirects: - weight: 8 - region: content - settings: { } - third_party_settings: { } -hidden: { } +hidden: + langcode: true + path: true + revision_log: true + sticky: true + url_redirects: true diff --git a/src/config/sync/core.entity_view_display.node.static.default.yml b/src/config/sync/core.entity_view_display.node.static.default.yml index e1aa8e0..20a522c 100644 --- a/src/config/sync/core.entity_view_display.node.static.default.yml +++ b/src/config/sync/core.entity_view_display.node.static.default.yml @@ -6,8 +6,8 @@ dependencies: - field.field.node.static.body - node.type.static module: + - manage_display - text - - user _core: default_config_hash: oGSMA6gtfWJ1AlOJQfaQ3Qpi7ZarWaHqInUX9DaJLzo id: node.static.default @@ -18,15 +18,22 @@ content: body: type: text_default label: hidden - settings: { } - third_party_settings: { } - weight: 0 - region: content - links: settings: { } third_party_settings: { } weight: 1 region: content + title: + type: title + label: hidden + settings: + link_to_entity: true + tag: h2 + third_party_settings: { } + weight: 0 + region: content hidden: + created: true langcode: true + links: true search_api_excerpt: true + uid: true diff --git a/src/config/sync/user.role.admin.yml b/src/config/sync/user.role.admin.yml index d120b9e..04295fc 100644 --- a/src/config/sync/user.role.admin.yml +++ b/src/config/sync/user.role.admin.yml @@ -15,6 +15,7 @@ dependencies: module: - actions_permissions - administerusersbyrole + - content_lock - content_translation - file - filter @@ -42,10 +43,12 @@ permissions: - 'access toolbar' - 'access user profiles' - 'access users overview' + - 'administer nodes' - 'administer productions menu items' - 'administer registration codes' - 'assign group_admin role' - 'assign group_member role' + - 'break content lock' - 'bypass confidentialite workflow_transition access' - 'cancel users with role group_admin' - 'cancel users with role group_member' @@ -108,6 +111,7 @@ permissions: - 'edit own concernement content' - 'edit own enregistrement content' - 'edit own reponse content' + - 'edit own static content' - 'edit terms in collectionneurs' - 'edit terms in entrees' - 'edit terms in genres' @@ -118,11 +122,14 @@ permissions: - 'edit users by role' - 'edit users with role group_admin' - 'edit users with role group_member' + - 'execute entity:break_lock node' - 'execute entity:save_action menu_link_content' - 'execute entity:save_action node' - 'execute entity:save_action taxonomy_term' - 'execute entity:save_action user' + - 'execute entity:unpublish_action node' - 'execute node_assign_owner_action node' + - 'execute node_make_sticky_action node' - 'execute node_promote_action node' - 'execute node_save_action node' - 'execute node_unpromote_action node' diff --git a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls index 0dc0407..43276df 100644 --- a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls +++ b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.base.graphqls @@ -20,6 +20,7 @@ type Concernement implements NodeInterface { description: String caillou: String recit: Filefield + recit_colophon: String entites: [Entiteintegre] besoins: [Besoin] doleances: [Doleance] @@ -50,7 +51,7 @@ type Entite implements NodeInterface { } type Source { - audios: Filefield + audios: [Filefield] date: Date documents: [Filefield] description: String @@ -150,6 +151,7 @@ type Static implements NodeInterface { author: String created: String changed: String + promoted: Boolean texte: String } diff --git a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.extension.graphqls b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.extension.graphqls index ab91558..4c3855b 100644 --- a/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.extension.graphqls +++ b/src/web/modules/custom/ouatt_graphql/graphql/ouatt_extension.extension.graphqls @@ -31,6 +31,10 @@ extend type Query { allstatics: [Static] } +extend type Query { + promotedstatics: [Static] +} + extend type Query { statics(ids: [Int]): [Static] } diff --git a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php index e77d5b4..5ae6e07 100644 --- a/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php +++ b/src/web/modules/custom/ouatt_graphql/src/Plugin/GraphQL/SchemaExtension/OuattSchemaExtension.php @@ -243,6 +243,13 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('position', $builder->fromValue(0)) )); + $registry->addFieldResolver('Concernement', 'recit_colophon', + $builder->produce('property_path') + ->map('type', $builder->fromValue('entity:node')) + ->map('value', $builder->fromParent()) + ->map('path', $builder->fromValue('field_recit_colophon.value')) + ); + $registry->addFieldResolver('Concernement', 'entites', $builder->produce('entity_reference_revisions') ->map('entity', $builder->fromParent()) @@ -1065,6 +1072,24 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ) ); + $registry->addFieldResolver('Query', 'promotedstatics', + $builder->compose( + $builder->callback(function($parent, $arg){ + $entity_storage = \Drupal::entityTypeManager()->getStorage('node'); + $query = $entity_storage->getQuery() + ->condition('type', ['static'], 'IN') + ->condition('promote', true) + ->accessCheck(TRUE); + $results = $query->execute(); + return $results; + }), + $builder->produce('entity_load_multiple') + ->map('type', $builder->fromValue('node')) + ->map('ids', $builder->fromParent()) + ) + ); + + $registry->addFieldResolver('Query', 'statics', $builder->produce('entity_load_multiple') ->map('type', $builder->fromValue('node')) @@ -1109,6 +1134,13 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('entity', $builder->fromParent()) )); + $registry->addFieldResolver('Static', 'promoted', + $builder->produce('property_path') + ->map('type', $builder->fromValue('entity:node')) + ->map('value', $builder->fromParent()) + ->map('path', $builder->fromValue('promote.value')) + ); + $registry->addFieldResolver('Static', 'texte', $builder->produce('property_path') ->map('type', $builder->fromValue('entity:node')) diff --git a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme index 81ca828..b07a3ca 100644 --- a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme +++ b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme @@ -58,18 +58,20 @@ function ouatminimal_form_node_form_alter(&$form, FormStateInterface $form_state $form['#theme'] = ['node_edit_form']; $form['#attached']['library'][] = 'seven/node-form'; - // unset($form['advanced']); - $form['advanced']['#type'] = 'container'; - $form['advanced']['#access'] = FALSE; - $form['meta']['#type'] = 'container'; - $form['meta']['#access'] = TRUE; - $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline'; - $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline'; + if ($form["#form_id"] != 'node_static_edit_form') { + // unset($form['advanced']); + $form['advanced']['#type'] = 'container'; + $form['advanced']['#access'] = FALSE; + $form['meta']['#type'] = 'container'; + $form['meta']['#access'] = TRUE; + $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline'; + $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline'; - $form['revision_information']['#type'] = 'container'; - $form['revision_information']['#group'] = 'meta'; + $form['revision_information']['#type'] = 'container'; + $form['revision_information']['#group'] = 'meta'; - // $form['author']['#group']['group_admin']; + // $form['author']['#group']['group_admin']; + } } diff --git a/src/web/themes/custom/ouatminimal_theme/templates/form/node-edit-form--node-static.html.twig b/src/web/themes/custom/ouatminimal_theme/templates/form/node-edit-form--node-static.html.twig new file mode 100644 index 0000000..cf747f9 --- /dev/null +++ b/src/web/themes/custom/ouatminimal_theme/templates/form/node-edit-form--node-static.html.twig @@ -0,0 +1,31 @@ +{# +/** + * @file + * Theme override for a node edit form. + * + * Two column template for the node add/edit form. + * + * This template will be used when a node edit form specifies 'node_edit_form' + * as its #theme callback. Otherwise, by default, node add/edit forms will be + * themed by form.html.twig. + * + * Available variables: + * - form: The node add/edit form. + * + * @see seven_form_node_form_alter() + */ +#} +
+
+ {{ form|without('advanced', 'footer', 'actions') }} +
+
+ {{ form.advanced }} +
+ +