浏览代码

statics can be promoted to front page (for app header menu)

bach 1 年之前
父节点
当前提交
1735f8f6ac

+ 62 - 31
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

+ 12 - 5
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
@@ -20,13 +20,20 @@ content:
     label: hidden
     settings: {  }
     third_party_settings: {  }
-    weight: 0
+    weight: 1
     region: content
-  links:
-    settings: {  }
+  title:
+    type: title
+    label: hidden
+    settings:
+      link_to_entity: true
+      tag: h2
     third_party_settings: {  }
-    weight: 1
+    weight: 0
     region: content
 hidden:
+  created: true
   langcode: true
+  links: true
   search_api_excerpt: true
+  uid: true

+ 7 - 0
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'

+ 3 - 1
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
 }
 

+ 4 - 0
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]
 }

+ 32 - 0
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'))

+ 14 - 12
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';
-
-  $form['revision_information']['#type'] = 'container';
-  $form['revision_information']['#group'] = 'meta';
-
-  // $form['author']['#group']['group_admin'];
+  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['author']['#group']['group_admin'];
+  }
 
 }
 

+ 31 - 0
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()
+ */
+#}
+<div class="layout-node-form clearfix">
+  <div class="layout-region layout-region-node-main">
+    {{ form|without('advanced', 'footer', 'actions') }}
+  </div>
+  <div class="layout-region layout-region-node-secondary">
+    {{ form.advanced }}
+  </div>
+  <div class="layout-region layout-region-node-footer">
+    <div class="layout-region-node-footer__content">
+      {{ form.footer }}
+      {{ form.actions }}
+    </div>
+  </div>
+</div>