From ef271210d24779bca73e95d0396d7bee88eaabb7 Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 7 Mar 2023 14:22:50 +0100 Subject: [PATCH] added admin_toolbar_content contrib module, changed toolbar home button to go to client --- src/composer.json | 1 + src/composer.lock | 126 +++++++++++++++++- .../sync/admin_toolbar_content.settings.yml | 13 ++ .../sync/admin_toolbar_tools.settings.yml | 6 + src/config/sync/core.extension.yml | 2 + ...agraph.entite_concernement.field_prise.yml | 2 +- src/config/sync/system.site.yml | 2 +- .../ouatt_extension.extension.graphqls | 4 + .../SchemaExtension/OuattSchemaExtension.php | 11 +- .../ouatminimal_theme/css/ouatminimal.css | 4 +- .../ouatminimal_theme/ouatminimal.theme | 12 +- .../templates/toolbar.html.twig | 46 +++++++ 12 files changed, 222 insertions(+), 7 deletions(-) create mode 100644 src/config/sync/admin_toolbar_content.settings.yml create mode 100644 src/config/sync/admin_toolbar_tools.settings.yml create mode 100644 src/web/themes/custom/ouatminimal_theme/templates/toolbar.html.twig diff --git a/src/composer.json b/src/composer.json index 6ccae57..9cae291 100644 --- a/src/composer.json +++ b/src/composer.json @@ -16,6 +16,7 @@ ], "require": { "composer/installers": "^1.9", + "drupal/admin_toolbar_content": "^1.3", "drupal/administerusersbyrole": "^3.3", "drupal/amswap": "^3.1", "drupal/audiofield": "1.x-dev@dev", diff --git a/src/composer.lock b/src/composer.lock index 051d7fa..10c08f4 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": "e86b83d13c4b5d3fd33d66bc0e622158", + "content-hash": "b71d40ad5fdae20202852b65c352ee54", "packages": [ { "name": "alchemy/zippy", @@ -2303,6 +2303,130 @@ "issues": "https://www.drupal.org/project/issues/admin_toolbar" } }, + { + "name": "drupal/admin_toolbar_content", + "version": "1.3.12", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/admin_toolbar_content.git", + "reference": "1.3.12" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/admin_toolbar_content-1.3.12.zip", + "reference": "1.3.12", + "shasum": "62c73317d0c94a4c1cc4ff488e08b6f23b99f505" + }, + "require": { + "drupal/admin_toolbar": "*", + "drupal/admin_toolbar_tools": "*", + "drupal/core": "^8.8 || ^9 || ^10" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "1.3.12", + "datestamp": "1676377124", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Kris Booghmans", + "homepage": "http://www.calibrate.be", + "email": "kris@calibrate.be" + }, + { + "name": "Mschudders", + "homepage": "https://www.drupal.org/user/1314320" + }, + { + "name": "Stefdewa", + "homepage": "https://www.drupal.org/user/2480344" + }, + { + "name": "tim-diels", + "homepage": "https://www.drupal.org/user/2915097" + } + ], + "description": "Provides extra content admin enhancements in the admin toolbar.", + "homepage": "https://www.drupal.org/project/admin_toolbar_content", + "keywords": [ + "Calibr8", + "Calibrate", + "Drupal 9", + "Toolbar", + "UX" + ], + "support": { + "source": "https://git.drupalcode.org/project/admin_toolbar_content" + } + }, + { + "name": "drupal/admin_toolbar_tools", + "version": "3.3.0", + "require": { + "drupal/admin_toolbar": "*", + "drupal/core": "^9.2 || ^10" + }, + "type": "metapackage", + "extra": { + "drupal": { + "version": "3.3.0", + "datestamp": "1669567837", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "adriancid", + "homepage": "https://www.drupal.org/user/1962106" + }, + { + "name": "bolbol", + "homepage": "https://www.drupal.org/user/3400070" + }, + { + "name": "eme", + "homepage": "https://www.drupal.org/user/542492" + }, + { + "name": "fethi.krout", + "homepage": "https://www.drupal.org/user/3206765" + }, + { + "name": "matio89", + "homepage": "https://www.drupal.org/user/2320090" + }, + { + "name": "Musa.thomas", + "homepage": "https://www.drupal.org/user/1213824" + }, + { + "name": "romainj", + "homepage": "https://www.drupal.org/user/370706" + } + ], + "description": "Adds menu links like Flush cache, Run cron, Run updates, and Logout under Drupal icon.", + "homepage": "https://www.drupal.org/project/admin_toolbar", + "support": { + "source": "https://git.drupalcode.org/project/admin_toolbar" + } + }, { "name": "drupal/adminimal_theme", "version": "1.6.0", diff --git a/src/config/sync/admin_toolbar_content.settings.yml b/src/config/sync/admin_toolbar_content.settings.yml new file mode 100644 index 0000000..102cade --- /dev/null +++ b/src/config/sync/admin_toolbar_content.settings.yml @@ -0,0 +1,13 @@ +_core: + default_config_hash: J_pW_t3Kr8hKGmouyvHK7hwllxgm5E7Ur85BMZJjfao +langcode: fr +recent_items: 10 +recent_items_link: default +hide_non_content_items: true +show_account_link: edit +enhance_content_item: true +show_categories_item: true +show_media_item: true +show_webforms_item: true +show_menus_item: true +group_collections: '' diff --git a/src/config/sync/admin_toolbar_tools.settings.yml b/src/config/sync/admin_toolbar_tools.settings.yml new file mode 100644 index 0000000..2fc3dac --- /dev/null +++ b/src/config/sync/admin_toolbar_tools.settings.yml @@ -0,0 +1,6 @@ +_core: + default_config_hash: WgdZsrd_5w9jlmcHV4R9dD2tG9OZEkYo4I_O8h7Gq8Q +langcode: fr +max_bundle_number: 20 +hoverintent_functionality: true +show_local_tasks: false diff --git a/src/config/sync/core.extension.yml b/src/config/sync/core.extension.yml index 8d1c6d2..266e944 100644 --- a/src/config/sync/core.extension.yml +++ b/src/config/sync/core.extension.yml @@ -5,7 +5,9 @@ module: actions_permissions: 0 admin_menus: 0 admin_toolbar: 0 + admin_toolbar_content: 0 admin_toolbar_links_access_filter: 0 + admin_toolbar_tools: 0 administerusersbyrole: 0 advanced_text_formatter: 0 amswap: 0 diff --git a/src/config/sync/field.field.paragraph.entite_concernement.field_prise.yml b/src/config/sync/field.field.paragraph.entite_concernement.field_prise.yml index 29c5e50..c3fb7e8 100644 --- a/src/config/sync/field.field.paragraph.entite_concernement.field_prise.yml +++ b/src/config/sync/field.field.paragraph.entite_concernement.field_prise.yml @@ -15,7 +15,7 @@ required: false translatable: false default_value: - - value: !!float 0 + value: !!float 100 default_value_callback: '' settings: min: !!float 0 diff --git a/src/config/sync/system.site.yml b/src/config/sync/system.site.yml index 543c29f..4fb4b2e 100644 --- a/src/config/sync/system.site.yml +++ b/src/config/sync/system.site.yml @@ -8,7 +8,7 @@ slogan: 'S’outiller collectivement, se préparer pour atterrir autrement, et s page: 403: '' 404: '' - front: /user/login + front: / admin_compact_mode: false weight_select_max: 100 default_langcode: fr 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 39c5aac..1a01f72 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 @@ -39,6 +39,10 @@ extend type Query { static(id: Int!): Static } +extend type Query { + user(id: Int!): User +} + extend type Query { allgroups: [Group] } 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 a8737ef..d748524 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 @@ -215,7 +215,9 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { ->map('entity', $builder->fromParent()) ->map('field', $builder->fromValue('field_entite')), $builder->callback(function ($items) { - return $items[0]; + if (isset($items[0])) { + return $items[0]; + } }) )); @@ -559,6 +561,13 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase { // \____/____/\___/_/ protected function addUser(ResolverRegistryInterface $registry, ResolverBuilder $builder) { + $registry->addFieldResolver('Query', 'user', + $builder->produce('entity_load') + ->map('type', $builder->fromValue('user')) + // ->map('bundles', $builder->fromValue(['static'])) + ->map('id', $builder->fromArgument('id')) + ); + $registry->addFieldResolver('User', 'id', $builder->produce('entity_id') ->map('entity', $builder->fromParent()) diff --git a/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css b/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css index 98aa64d..1aa5dbf 100644 --- a/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css +++ b/src/web/themes/custom/ouatminimal_theme/css/ouatminimal.css @@ -171,9 +171,9 @@ #boussole-layout .form-item[data-drupal-selector="edit-field-entite"] table.field-multiple-table>tbody>tr{ border: none; } -#boussole-layout .form-item[data-drupal-selector="edit-field-entite"] table.field-multiple-table>tbody>tr>td.field-multiple-drag{ +/* #boussole-layout .form-item[data-drupal-selector="edit-field-entite"] table.field-multiple-table>tbody>tr>td.field-multiple-drag{ -} +} */ #boussole-layout .form-item[data-drupal-selector="edit-field-entite"] table.field-multiple-table>tbody>tr>td:not(.field-multiple-drag)>div{ padding:0.5em; border: 1px solid #bbb; diff --git a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme index 9e53f43..ad1b5c4 100644 --- a/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme +++ b/src/web/themes/custom/ouatminimal_theme/ouatminimal.theme @@ -6,7 +6,8 @@ */ use Drupal\Core\Form\FormStateInterface; - +use \Drupal\Core\Url; +use Drupal\Core\Render\Markup; /** * Implements hook_preprocess_HOOK() for HTML document templates. @@ -99,3 +100,12 @@ function ouatminimal_preprocess_field_multiple_value_form__field_entite__node_co // $t="t"; // } // } + +function ouatminimal_preprocess_toolbar(&$variables) { + unset($variables['tabs']['home']['link']['#options']['attributes']['data-toolbar-escape-admin']); + unset($variables['tabs']['home']['link']['#attributes']['data-toolbar-escape-admin']); + unset($variables['tabs']['home']['link']['#markup']); + unset($variables['tabs']['home']['link']['#children']); + $uri = $_SERVER['HTTP_REFERER']; + $variables['tabs']['home']['link']['#url'] = Url::fromUri($uri); +} \ No newline at end of file diff --git a/src/web/themes/custom/ouatminimal_theme/templates/toolbar.html.twig b/src/web/themes/custom/ouatminimal_theme/templates/toolbar.html.twig new file mode 100644 index 0000000..5ef3ffa --- /dev/null +++ b/src/web/themes/custom/ouatminimal_theme/templates/toolbar.html.twig @@ -0,0 +1,46 @@ +{# +/** + * @file + * Theme override for the administrative toolbar. + * + * Available variables: + * - attributes: HTML attributes for the wrapper. + * - toolbar_attributes: HTML attributes to apply to the toolbar. + * - toolbar_heading: The heading or label for the toolbar. + * - tabs: List of tabs for the toolbar. + * - attributes: HTML attributes for the tab container. + * - link: Link or button for the menu tab. + * - trays: Toolbar tray list, each associated with a tab. Each tray in trays + * contains: + * - attributes: HTML attributes to apply to the tray. + * - label: The tray's label. + * - links: The tray menu links. + * - remainder: Any non-tray, non-tab elements left to be rendered. + * + * @see template_preprocess_toolbar() + */ +#} + + +

{{ toolbar_heading }}

+ {% for key, tab in tabs %} + {% set tray = trays[key] %} + + {{ tab.link }} + {% apply spaceless %} + + {% if tray.label %} + + {{ remainder }} +