From e96d2aa5dc96c5950aa23d0872986f2ba5bdc07b Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Thu, 21 Sep 2023 16:59:33 +0200 Subject: [PATCH 001/166] Setup AdminBundle as a Node.js package --- package.json | 1 + src/Sylius/Bundle/AdminBundle/index.js | 44 ++++++++++++++++++++++ src/Sylius/Bundle/AdminBundle/package.json | 27 +++++++++++++ webpack.config.js | 20 ++-------- 4 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/index.js create mode 100644 src/Sylius/Bundle/AdminBundle/package.json diff --git a/package.json b/package.json index ae3b19a68b..9257dcf4fd 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "license": "MIT", "author": "Sylius Sp. z o.o.", "dependencies": { + "@sylius-ui/admin": "file:src/Sylius/Bundle/AdminBundle", "chart.js": "^3.7.1", "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", diff --git a/src/Sylius/Bundle/AdminBundle/index.js b/src/Sylius/Bundle/AdminBundle/index.js new file mode 100644 index 0000000000..923fcee96e --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/index.js @@ -0,0 +1,44 @@ +/* + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +const path = require('path'); +const Encore = require('@symfony/webpack-encore'); + +class SyliusAdmin { + static getWebpackConfig() { + const uiBundleScripts = path.resolve(__dirname, '../UiBundle/Resources/private/js/'); + const uiBundleResources = path.resolve(__dirname, '../UiBundle/Resources/private/'); + + Encore + .setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', path.resolve(__dirname, 'Resources/assets/entrypoint.js')) + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader((options) => { + // eslint-disable-next-line no-param-reassign + options.additionalData = `$assetsPath: ${path.resolve(__dirname, 'Resources/assets')};`; + }); + + const adminConfig = Encore.getWebpackConfig(); + + adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; + adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; + adminConfig.externals = { ...adminConfig.externals, window: 'window', document: 'document' }; + adminConfig.name = 'admin'; + + Encore.reset(); + + return adminConfig; + } +} + +module.exports = SyliusAdmin; diff --git a/src/Sylius/Bundle/AdminBundle/package.json b/src/Sylius/Bundle/AdminBundle/package.json new file mode 100644 index 0000000000..617a14b7cb --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/package.json @@ -0,0 +1,27 @@ +{ + "name": "@sylius-ui/admin", + "version": "1.0.0", + "license": "MIT", + "author": "Sylius Sp. z o.o.", + "dependencies": { + "@popperjs/core": "^2.11.8", + "@symfony/webpack-encore": "^3.1.0", + "@tabler/core": "^1.0.0-beta20", + "apexcharts": "^3.41.0", + "bootstrap": "^5.3.0", + "choices.js": "^10.2.0" + }, + "devDependencies": { + "sass": "^1.54.8", + "sass-loader": "^13.0.0" + }, + "engines": { + "node": "^18 || ^20" + }, + "engineStrict": true, + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/Sylius/SyliusAdminBundle.git" + } +} diff --git a/webpack.config.js b/webpack.config.js index 8b1ebe62cd..0654b5eaea 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,8 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); +const SyliusAdmin = require('@sylius-ui/admin'); + const uiBundleScripts = path.resolve(__dirname, 'src/Sylius/Bundle/UiBundle/Resources/private/js/'); const uiBundleResources = path.resolve(__dirname, 'src/Sylius/Bundle/UiBundle/Resources/private/'); @@ -23,22 +25,6 @@ shopConfig.name = 'shop'; Encore.reset(); -// Admin config -Encore - .setOutputPath('public/build/admin/') - .setPublicPath('/build/admin') - .addEntry('admin-entry', './src/Sylius/Bundle/AdminBundle/Resources/private/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); - -const adminConfig = Encore.getWebpackConfig(); - -adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; -adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; -adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); -adminConfig.name = 'admin'; +const adminConfig = SyliusAdmin.getWebpackConfig(); module.exports = [shopConfig, adminConfig]; From a3dd068e025d0550f331dce3cec644b32c9ce04a Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 08:27:12 +0200 Subject: [PATCH 002/166] Switch to the dev branch of tabler --- src/Sylius/Bundle/AdminBundle/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sylius/Bundle/AdminBundle/package.json b/src/Sylius/Bundle/AdminBundle/package.json index 617a14b7cb..96ed630ce6 100644 --- a/src/Sylius/Bundle/AdminBundle/package.json +++ b/src/Sylius/Bundle/AdminBundle/package.json @@ -6,7 +6,7 @@ "dependencies": { "@popperjs/core": "^2.11.8", "@symfony/webpack-encore": "^3.1.0", - "@tabler/core": "^1.0.0-beta20", + "@tabler/core": "tabler/tabler#dev", "apexcharts": "^3.41.0", "bootstrap": "^5.3.0", "choices.js": "^10.2.0" From c4f700b6d284beaef000d11747aa6909baf98db9 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 08:27:38 +0200 Subject: [PATCH 003/166] Add the $rootDir variable to the SCSS loader --- src/Sylius/Bundle/AdminBundle/index.js | 4 ++-- webpack.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/index.js b/src/Sylius/Bundle/AdminBundle/index.js index 923fcee96e..fe38691704 100644 --- a/src/Sylius/Bundle/AdminBundle/index.js +++ b/src/Sylius/Bundle/AdminBundle/index.js @@ -11,7 +11,7 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); class SyliusAdmin { - static getWebpackConfig() { + static getWebpackConfig(rootDir) { const uiBundleScripts = path.resolve(__dirname, '../UiBundle/Resources/private/js/'); const uiBundleResources = path.resolve(__dirname, '../UiBundle/Resources/private/'); @@ -25,7 +25,7 @@ class SyliusAdmin { .enableVersioning(Encore.isProduction()) .enableSassLoader((options) => { // eslint-disable-next-line no-param-reassign - options.additionalData = `$assetsPath: ${path.resolve(__dirname, 'Resources/assets')};`; + options.additionalData = `$rootDir: ${rootDir};`; }); const adminConfig = Encore.getWebpackConfig(); diff --git a/webpack.config.js b/webpack.config.js index 0654b5eaea..9490ea0f7c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -25,6 +25,6 @@ shopConfig.name = 'shop'; Encore.reset(); -const adminConfig = SyliusAdmin.getWebpackConfig(); +const adminConfig = SyliusAdmin.getWebpackConfig(path.resolve(__dirname)); module.exports = [shopConfig, adminConfig]; From 3d98ff1f479656040c77f34b7e9dafef491f683f Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 08:27:51 +0200 Subject: [PATCH 004/166] Set up entrypoint.js --- .../Resources/assets/entrypoint.js | 15 +++ .../Resources/assets/scripts/apexcharts.js | 99 +++++++++++++++++++ .../Resources/assets/scripts/choices.js | 22 +++++ .../Resources/assets/styles/_flags.scss | 11 +++ .../Resources/assets/styles/main.scss | 23 +++++ .../Resources/assets/styles/ui/_flags.scss | 31 ++++++ 6 files changed, 201 insertions(+) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/apexcharts.js create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/choices.js create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_flags.scss create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/styles/ui/_flags.scss diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js b/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js new file mode 100644 index 0000000000..778bf8d907 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js @@ -0,0 +1,15 @@ +/* + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import './styles/main.scss'; + +import './scripts/apexcharts'; +import './scripts/choices'; + +import 'bootstrap'; diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/apexcharts.js b/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/apexcharts.js new file mode 100644 index 0000000000..fe7bea214d --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/apexcharts.js @@ -0,0 +1,99 @@ +/* + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import ApexCharts from 'apexcharts'; + +(function () { + const options = { + series: [{ + name: 'Inflation', + data: [2.3, 3.1, 4.0, 10.1, 4.0, 3.6, 3.2, 2.3, 1.4, 0.8, 0.5, 0.2], + }], + chart: { + height: 350, + type: 'bar', + }, + plotOptions: { + bar: { + borderRadius: 10, + dataLabels: { + position: 'top', // top, center, bottom + }, + }, + }, + dataLabels: { + enabled: true, + formatter(val) { + return `${val}%`; + }, + offsetY: -20, + style: { + fontSize: '12px', + colors: ['#304758'], + }, + }, + + xaxis: { + categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + position: 'top', + axisBorder: { + show: false, + }, + axisTicks: { + show: false, + }, + crosshairs: { + fill: { + type: 'gradient', + gradient: { + colorFrom: '#D8E3F0', + colorTo: '#BED1E6', + stops: [0, 100], + opacityFrom: 0.4, + opacityTo: 0.5, + }, + }, + }, + tooltip: { + enabled: true, + } + }, + yaxis: { + axisBorder: { + show: false, + }, + axisTicks: { + show: false, + }, + labels: { + show: false, + formatter(val) { + return `${val}%`; + }, + }, + + }, + title: { + floating: true, + offsetY: 330, + align: 'center', + style: { + color: '#444', + }, + }, + }; + + // eslint-disable-next-line no-undef + const ch = document.querySelector('#chart-demo'); + if (ch) { + // eslint-disable-next-line no-undef + const chart = new ApexCharts(document.querySelector('#chart-demo'), options); + chart.render(); + } +}()); diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/choices.js b/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/choices.js new file mode 100644 index 0000000000..a44587167b --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/scripts/choices.js @@ -0,0 +1,22 @@ +/* + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import Choices from 'choices.js'; + +(function () { + // eslint-disable-next-line no-undef + const items = document.querySelectorAll('[data-choices]'); + + if (items.length) { + items.forEach((el) => { + // eslint-disable-next-line no-new + new Choices(el); + }); + } +}()); diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_flags.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_flags.scss new file mode 100644 index 0000000000..783a3753de --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_flags.scss @@ -0,0 +1,11 @@ +/*! + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +@import "@tabler/core/src/scss/config"; +@import "ui/flags"; diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss new file mode 100644 index 0000000000..4e3dad47ae --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss @@ -0,0 +1,23 @@ +/* + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$assets-base: $rootDir + "/node_modules/@tabler/core/dist"; + +@import "choices.js/src/styles/choices.scss"; +@import "@tabler/core/src/scss/tabler.scss"; + + +// TODO: Once https://github.com/tabler/tabler/pull/1718 merged or resolve remove the custom _flags.scss and import the tabler's one +//@import "@tabler/core/src/scss/tabler-flags.scss"; +@import "_flags.scss"; + +body { + font-family: "Inter", sans-serif; + font-feature-settings: "cv03", "cv04", "cv11"; +} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/ui/_flags.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/ui/_flags.scss new file mode 100644 index 0000000000..42729f92c9 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/ui/_flags.scss @@ -0,0 +1,31 @@ +$countries: ( + 'ad', 'af', 'ae', 'afrun', 'ag', 'ai', 'al', 'am', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'bq-bo', 'bq-sa', 'bq-se', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cw', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb-eng', 'gb-sct', 'gb', 'gb-wls', 'gb-nir', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mf', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 'rainbow', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'ss', 'st', 'sv', 'sx', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'um', 'unasur', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'za', 'zm', 'zw' +); + +.flag { + position: relative; + display: inline-block; + height: $avatar-size; + aspect-ratio: 1.33333; + background: no-repeat center/cover; + box-shadow: $flag-box-shadow; + border-radius: $flag-border-radius; + vertical-align: bottom; + + &.flag-country-np { + box-shadow: none; + border-radius: 0; + } +} + +@each $country in $countries { + .flag-country-#{$country} { + background-image: url("#{$assets-base}/img/flags/#{$country}.svg"); + } +} + +@each $flag-size, $size in $flag-sizes { + .flag-#{$flag-size} { + height: map-get($size, size); + } +} From 4f29d2cd5d5dc90f36f39b7b374d5c7c2a3e8ab8 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 09:55:12 +0200 Subject: [PATCH 005/166] Add basic template events for CRUD's index --- .../Resources/config/app/config.yml | 2 +- .../Resources/config/app/events.yaml | 1370 ----------------- .../Resources/config/app/template_events.yaml | 13 + .../Resources/views/Crud/index.html.twig | 36 +- .../Shared/Crud/Common/_content.html.twig | 3 + .../Shared/Crud/Common/_navbar.html.twig | 5 + .../Shared/Crud/Common/_sidebar.html.twig | 5 + .../views/Shared/Crud/index.html.twig | 14 + .../views/Shared/Layout/base.html.twig | 22 + 9 files changed, 82 insertions(+), 1388 deletions(-) delete mode 100644 src/Sylius/Bundle/AdminBundle/Resources/config/app/events.yaml create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_navbar.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_sidebar.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml index 9c1dd7975d..35b0b07b08 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml @@ -1,7 +1,7 @@ imports: - { resource: "@SyliusUiBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminBundle/Resources/config/app/events.yaml" } + - { resource: "@SyliusAdminBundle/Resources/config/app/template_events.yaml" } - { resource: "@SyliusAdminBundle/Resources/config/app/sylius/sylius_mailer.yml" } - { resource: "@SyliusAdminBundle/Resources/config/grids/address_log_entry.yml" } - { resource: "@SyliusAdminBundle/Resources/config/grids/admin_user.yml" } diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/events.yaml deleted file mode 100644 index 4f45dcf2fc..0000000000 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/events.yaml +++ /dev/null @@ -1,1370 +0,0 @@ -# This file is part of the Sylius package. -# (c) Sylius Sp. z o.o. - -sylius_ui: - events: - sylius.admin.index: - blocks: - before_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - postfix: index.before_header - header: - template: "@SyliusAdmin/Crud/Index/_header.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - postfix: index.after_header - content: - template: "@SyliusAdmin/Crud/Index/_content.html.twig" - priority: 10 - after_content: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - postfix: index.after_content - - sylius.admin.index.stylesheets: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - postfix: index.stylesheets - - sylius.admin.index.javascripts: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - postfix: index.javascripts - - sylius.admin.index.header: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: index.header - - sylius.admin.create: - blocks: - before_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - postfix: create.before_header - header: - template: "@SyliusAdmin/Crud/Create/_header.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - postfix: create.after_header - content: - template: "@SyliusAdmin/Crud/Create/_content.html.twig" - priority: 10 - after_content: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - postfix: create.after_content - - sylius.admin.create.stylesheets: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: create.stylesheets - - sylius.admin.create.javascripts: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: create.javascripts - - sylius.admin.create.header: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: create.header - - sylius.admin.create.form: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: create.form - - sylius.admin.update: - blocks: - before_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - postfix: update.before_header - header: - template: "@SyliusAdmin/Crud/Update/_header.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - postfix: update.after_header - content: - template: "@SyliusAdmin/Crud/Update/_content.html.twig" - priority: 10 - after_content: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - postfix: update.after_content - - sylius.admin.update.stylesheets: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: update.stylesheets - - sylius.admin.update.javascripts: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: update.javascripts - - sylius.admin.update.header: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: update.header - - sylius.admin.update.form: - blocks: - legacy: - template: "@SyliusAdmin/Crud/Block/_legacySonataEvent.html.twig" - context: - postfix: update.form - - sylius.admin.layout.sidebar: - blocks: - top_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.layout.sidebar_top - logo: - template: "@SyliusAdmin/_logo.html.twig" - priority: 20 - menu: - template: "@SyliusAdmin/_menu.html.twig" - priority: 10 - down_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.layout.sidebar_down - - sylius.admin.layout.javascripts: - blocks: - scripts: - template: "@SyliusAdmin/_scripts.html.twig" - priority: 10 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 0 - context: - event: sylius.admin.layout.javascripts - - sylius.admin.layout.stylesheets: - blocks: - styles: - template: "@SyliusAdmin/_styles.html.twig" - priority: 10 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 0 - context: - event: sylius.admin.layout.stylesheets - - sylius.admin.layout.topbar_left: - blocks: - sidebar_toggle: - template: "@SyliusAdmin/Layout/_sidebarToggle.html.twig" - priority: 30 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.layout.topbar_left - channel_links: - template: "@SyliusAdmin/Layout/_channelLinksWidget.html.twig" - priority: 20 - search: - template: "@SyliusAdmin/_search.html.twig" - priority: 10 - - sylius.admin.layout.topbar_middle: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.layout.topbar_middle - - sylius.admin.layout.topbar_right: - blocks: - notifications: - template: "@SyliusAdmin/Layout/_notificationWidget.html.twig" - priority: 30 - support: - template: "@SyliusAdmin/_support.html.twig" - priority: 20 - security: - template: "@SyliusAdmin/_security.html.twig" - priority: 10 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.layout.topbar_right - - sylius.admin.order.update.form: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.order.update.form - - sylius.admin.product_variant.generate.form: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product_variant.generate.form - - sylius.admin.promotion_coupon.generate.form: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.promotion_coupon.generate.form - - sylius.admin.login.form: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.login.form - - sylius.admin.taxon.update.before_content: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.taxon.update.before_content - - sylius.admin.taxon.create.before_content: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.taxon.create.before_content - - sylius.admin.taxon.create.taxon_tree: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.taxon.create.before_taxon_tree - tree: - template: "@SyliusAdmin/Taxon/_taxonTree.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.taxon.create.after_taxon_tree - - sylius.admin.taxon.update.taxon_tree: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.taxon.update.before_taxon_tree - tree: - template: "@SyliusAdmin/Taxon/_taxonTree.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.taxon.update.after_taxon_tree - - sylius.admin.login.content: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.login.before_content - tree: - template: "@SyliusAdmin/Security/_content.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.login.after_content - - sylius.admin.login.form.content: - blocks: - divider: - template: "@SyliusAdmin/_divider.html.twig" - priority: 0 - request_password_reset: - template: "@SyliusAdmin/Security/Form/_requestPasswordResetButton.html.twig" - priority: 0 - - sylius.admin.dashboard.header.content: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.dashboard.header - - sylius.admin.product_variant.create.tab_taxes: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product_variant.create.tab_taxes - - sylius.admin.product_variant.update.tab_taxes: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product_variant.update.tab_taxes - - sylius.admin.product_variant.create.tab_details: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product_variant.create.tab_details - - sylius.admin.product_variant.update.tab_details: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product_variant.update.tab_details - - sylius.admin.product.create.tab_associations: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.create.tab_associations - - sylius.admin.product.update.tab_associations: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.update.tab_associations - - sylius.admin.product.create.tab_attributes: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.create.tab_attributes - - sylius.admin.product.update.tab_attributes: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.update.tab_attributes - - sylius.admin.product.create.tab_details: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.create.tab_details - - sylius.admin.product.update.tab_details: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.update.tab_details - - sylius.admin.product.create.tab_media: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.create.tab_media - - sylius.admin.product.update.tab_media: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.update.tab_media - - sylius.admin.product.create.tab_taxonomy: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.create.tab_taxonomy - - sylius.admin.product.update.tab_taxonomy: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - context: - event: sylius.admin.product.update.tab_taxonomy - - sylius.admin.promotion_coupon.index.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.promotion_coupon.index.before_header - header: - template: "@SyliusAdmin/PromotionCoupon/Index/_headerWidget.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.promotion_coupon.index.after_header - content: - template: "@SyliusAdmin/Crud/Index/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.promotion_coupon.index.after_content - - sylius.admin.promotion_coupon.generate.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.promotion_coupon.generate.before_header - header: - template: "@SyliusAdmin/PromotionCoupon/Generate/_header.html.twig" - priority: 30 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.promotion_coupon.generate.after_header - breadcrumb: - template: "@SyliusAdmin/PromotionCoupon/Generate/_breadcrumb.html.twig" - priority: 20 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.promotion_coupon.generate.after_breadcrumb - content: - template: "@SyliusAdmin/PromotionCoupon/Generate/_formWidget.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.promotion_coupon.generate.after_content - - sylius.admin.customer.show.address: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.customer.show.before_address - header: - template: "@SyliusAdmin/Customer/Show/Address/_header.html.twig" - priority: 20 - content: - template: "@SyliusAdmin/Customer/Show/Address/_content.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.customer.show.after_address - - sylius.admin.order.update.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.order.update.before_header - header: - template: "@SyliusAdmin/Order/Update/_header.html.twig" - priority: 30 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.order.update.after_header - breadcrumb: - template: "@SyliusAdmin/Order/Update/_breadcrumb.html.twig" - priority: 20 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.order.update.after_breadcrumb - content: - template: "@SyliusAdmin/Order/Update/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.order.update.after_content - - sylius.admin.order.show.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.order.show.before_header - header: - template: "@SyliusAdmin/Order/Show/_headerWidget.html.twig" - priority: 30 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.order.show.after_header - breadcrumb: - template: "@SyliusAdmin/Order/Show/_breadcrumb.html.twig" - priority: 20 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.order.show.after_breadcrumb - content: - template: "@SyliusAdmin/Order/Show/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.order.show.after_content - - sylius.admin.order.show.summary: - blocks: - before_summary_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.order.show.before_summary - summary: - template: "@SyliusAdmin/Order/Show/_summaryWidget.html.twig" - priority: 20 - after_summary_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.order.show.after_summary - notes: - template: "@SyliusAdmin/Order/Show/_notes.html.twig" - priority: 10 - - sylius.admin.order.show.sidebar: - blocks: - before_customer_information_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 55 - context: - event: sylius.admin.order.show.before_customer_information - customer: - template: "@SyliusAdmin/Order/Show/_customer.html.twig" - priority: 50 - before_payments_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 45 - context: - event: sylius.admin.order.show.before_payments - payments: - template: "@SyliusAdmin/Order/Show/_payments.html.twig" - priority: 40 - shipments: - template: "@SyliusAdmin/Order/Show/_shipments.html.twig" - priority: 35 - before_addresses_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 30 - context: - event: sylius.admin.order.show.before_addresses - addresses: - template: "@SyliusAdmin/Order/Show/_addresses.html.twig" - priority: 20 - resend_email: - template: "@SyliusAdmin/Order/Show/_resendEmail.html.twig" - priority: 10 - after_shipments_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.order.show.after_shipments - - sylius.admin.order.show.header_items: - blocks: - content: - template: '@SyliusAdmin/Order/Show/_headerItems.html.twig' - priority: 10 - - sylius.admin.order.show.payments_content: - blocks: - content: - template: '@SyliusAdmin/Order/Show/_paymentsContent.html.twig' - priority: 10 - - sylius.admin.order.show.payment_content: - blocks: - header: - template: '@SyliusAdmin/Order/Show/Payment/_header.html.twig' - priority: 40 - content: - template: '@SyliusAdmin/Order/Show/Payment/_content.html.twig' - priority: 30 - complete_transition: - template: '@SyliusAdmin/Order/Show/Payment/_completeTransition.html.twig' - priority: 20 - refund_transition: - template: '@SyliusAdmin/Order/Show/Payment/_refundTransition.html.twig' - priority: 10 - - sylius.admin.order.show.shipments_content: - blocks: - content: - template: '@SyliusAdmin/Order/Show/_shipmentsContent.html.twig' - priority: 10 - - sylius.admin.order.show.shipment_content: - blocks: - header: - template: '@SyliusAdmin/Order/Show/Shipment/_header.html.twig' - priority: 60 - content: - template: '@SyliusAdmin/Order/Show/Shipment/_content.html.twig' - priority: 50 - ship_transition: - template: '@SyliusAdmin/Order/Show/Shipment/_shipTransition.html.twig' - priority: 40 - tracking: - template: '@SyliusAdmin/Order/Show/Shipment/_tracking.html.twig' - priority: 30 - show_button: - template: '@SyliusAdmin/Order/Show/Shipment/_showButton.html.twig' - priority: 20 - resend_confirmation_email_button: - template: '@SyliusAdmin/Order/Show/Shipment/_resendConfirmationEmailButton.html.twig' - priority: 10 - - sylius.admin.customer.show.information: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.customer.show.before_information - primary: - template: "@SyliusAdmin/Customer/Show/Details/_primary.html.twig" - priority: 30 - email: - template: "@SyliusAdmin/Customer/Show/Details/_email.html.twig" - priority: 20 - contact: - template: "@SyliusAdmin/Customer/Show/Details/_contact.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.customer.show.after_information - - sylius.admin.product_variant.index.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.product_variant.index.before_header - header: - template: "@SyliusAdmin/ProductVariant/Index/_headerWidget.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product_variant.index.after_header - content: - template: "@SyliusAdmin/Crud/Index/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.product_variant.index.after_content - - sylius.admin.product_variant.generate.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.product_variant.generate.before_header - header: - template: "@SyliusAdmin/ProductVariant/Generate/_header.html.twig" - priority: 30 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.product_variant.generate.after_header - breadcrumb: - template: "@SyliusAdmin/ProductVariant/Generate/_breadcrumb.html.twig" - priority: 20 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product_variant.generate.after_breadcrumb - content: - template: "@SyliusAdmin/ProductVariant/Generate/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.product_variant.generate.after_content - - sylius.admin.order.history.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.order.history.before_header - header: - template: "@SyliusAdmin/Order/History/_headerWidget.html.twig" - priority: 30 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.order.history.after_header - breadcrumb: - template: "@SyliusAdmin/Order/History/_breadcrumb.html.twig" - priority: 20 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.order.history.after_breadcrumb - content: - template: "@SyliusAdmin/Order/History/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.order.history.after_content - - sylius.admin.product.index.header: - blocks: - content: - template: "@SyliusAdmin/Product/Index/Header/_content.html.twig" - priority: 20 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product.index.header - breadcrumb: - template: "@SyliusAdmin/Product/Index/Header/_breadcrumb.html.twig" - priority: 10 - - sylius.admin.product_variant.index.header.content: - blocks: - content: - template: "@SyliusAdmin/ProductVariant/Index/ProductHeader/_content.html.twig" - priority: 20 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product_variant.index.header - breadcrumb: - template: "@SyliusAdmin/ProductVariant/Index/ProductHeader/_breadcrumb.html.twig" - priority: 10 - - sylius.admin.product.index.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.product.index.before_header - header: - template: "@SyliusAdmin/Product/Index/_headerWidget.html.twig" - priority: 20 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product.index.after_header - content: - template: "@SyliusAdmin/Product/Index/_content.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.product.index.after_content - - sylius.admin.product.show.variants_content: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_variantsContent.html.twig' - priority: 10 - - sylius.admin.customer.show.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 45 - context: - event: sylius.admin.customer.show.before_header - header: - template: "@SyliusAdmin/Customer/Show/_headerWidget.html.twig" - priority: 40 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.customer.show.after_header - breadcrumb: - template: "@SyliusAdmin/Customer/Show/_breadcrumb.html.twig" - priority: 30 - after_breadcrumb_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.customer.show.after_breadcrumb - statistics: - template: "@SyliusAdmin/Customer/Show/_statistics.html.twig" - priority: 20 - after_statistics_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.customer.show.after_statistics - content: - template: "@SyliusAdmin/Customer/Show/_contentWidget.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.customer.show.after_content - - sylius.admin.dashboard.content: - blocks: - before_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 45 - context: - event: sylius.admin.dashboard.before_header - header: - template: "@SyliusAdmin/Dashboard/_header.html.twig" - priority: 40 - after_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 35 - context: - event: sylius.admin.dashboard.after_header - statistics: - template: "@SyliusAdmin/Dashboard/_statistics.html.twig" - priority: 30 - after_statistics_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 25 - context: - event: sylius.admin.customer.show.after_statistics - menu: - template: "@SyliusAdmin/Dashboard/_menu.html.twig" - priority: 20 - after_menu_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.dashboard.after_menu - latest: - template: "@SyliusAdmin/Dashboard/_latest.html.twig" - priority: 10 - after_content_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.dashboard.after_content - - sylius.admin.customer.show.header.content: - blocks: - content: - template: "@SyliusAdmin/Customer/Show/_header.html.twig" - priority: 20 - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.customer.show.header - menu: - template: "@SyliusAdmin/Customer/Show/_headerMenu.html.twig" - priority: 10 - - sylius.admin.product.index.content.main: - blocks: - legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product.index.content.before_filters - content: - template: "@SyliusAdmin/Crud/Index/_content.html.twig" - priority: 10 - - sylius.admin.product.index.content.sidebar: - blocks: - before_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 15 - context: - event: sylius.admin.product.index.before_taxon_tree - content: - template: "@SyliusAdmin/Product/Index/Content/_taxonTree.html.twig" - priority: 10 - after_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 5 - context: - event: sylius.admin.product.index.after_taxon_tree - - sylius.admin.catalog_promotion.product_variant.index.content: - blocks: - header: - template: "@SyliusAdmin/CatalogPromotion/ProductVariant/Index/_headerWidget.html.twig" - priority: 20 - content: - template: "@SyliusAdmin/Crud/Index/_content.html.twig" - priority: 10 - - sylius.admin.catalog_promotion.product_variant.index.header.content: - blocks: - content: - template: "@SyliusAdmin/CatalogPromotion/ProductVariant/Index/Header/_content.html.twig" - priority: 20 - breadcrumb: - template: "@SyliusAdmin/CatalogPromotion/ProductVariant/Index/Header/_breadcrumb.html.twig" - priority: 10 - - sylius.admin.catalog_promotion.show.content: - blocks: - header: - template: "@SyliusAdmin/CatalogPromotion/Show/_headerWidget.html.twig" - priority: 15 - breadcrumb: - template: "@SyliusAdmin/CatalogPromotion/Show/_breadcrumb.html.twig" - priority: 10 - content: - template: "@SyliusAdmin/CatalogPromotion/Show/_content.html.twig" - priority: 5 - - sylius.admin.catalog_promotion.show.header.content: - blocks: - content: - template: "@SyliusAdmin/CatalogPromotion/Show/_header.html.twig" - priority: 10 - menu: - template: "@SyliusAdmin/CatalogPromotion/Show/_headerMenu.html.twig" - priority: 5 - - sylius.admin.catalog_promotion.show.content.left_bar: - blocks: - content: - template: "@SyliusAdmin/CatalogPromotion/Show/_details.html.twig" - priority: 10 - menu: - template: "@SyliusAdmin/CatalogPromotion/Show/_translations.html.twig" - priority: 5 - - sylius.admin.catalog_promotion.show.content.right_bar: - blocks: - content: - template: "@SyliusAdmin/CatalogPromotion/Show/_scopes.html.twig" - priority: 10 - menu: - template: "@SyliusAdmin/CatalogPromotion/Show/_actions.html.twig" - priority: 5 - - sylius.admin.admin_user.form: - blocks: - content: - template: '@SyliusAdmin/AdminUser/Form/_content.html.twig' - priority: 10 - - sylius.admin.admin_user.form.columns: - blocks: - first_column: - template: '@SyliusAdmin/AdminUser/Form/_firstColumn.html.twig' - priority: 20 - second_column: - template: '@SyliusAdmin/AdminUser/Form/_secondColumn.html.twig' - priority: 10 - - sylius.admin.admin_user.form.first_column: - blocks: - general_info: - template: '@SyliusAdmin/AdminUser/Form/_generalInfo.html.twig' - priority: 20 - general_info_extended: - template: '@SyliusAdmin/AdminUser/Form/_generalInfoExtended.html.twig' - priority: 10 - - sylius.admin.admin_user.form.second_column: - blocks: - additional_information: - template: '@SyliusAdmin/AdminUser/Form/_additionalInformation.html.twig' - priority: 20 - preferences: - template: '@SyliusAdmin/AdminUser/Form/_preferences.html.twig' - priority: 10 - - sylius.admin.admin_user.form.additional_information: - blocks: - personals: - template: '@SyliusAdmin/AdminUser/Form/_personals.html.twig' - priority: 20 - avatar: - template: '@SyliusAdmin/AdminUser/Form/_avatar.html.twig' - priority: 10 - - sylius.admin.channel.form: - blocks: - content: - template: '@SyliusAdmin/Channel/Form/_content.html.twig' - priority: 10 - - sylius.admin.channel.form.content: - blocks: - first_column: - template: '@SyliusAdmin/Channel/Form/_firstColumn.html.twig' - priority: 20 - second_column: - template: '@SyliusAdmin/Channel/Form/_secondColumn.html.twig' - priority: 10 - - sylius.admin.channel.form.first_column_content: - blocks: - general: - template: '@SyliusAdmin/Channel/Form/_general.html.twig' - priority: 40 - general_host: - template: '@SyliusAdmin/Channel/Form/_generalHost.html.twig' - priority: 30 - countries: - template: '@SyliusAdmin/Channel/Form/_countries.html.twig' - priority: 20 - required_address_in_checkout: - template: '@SyliusAdmin/Channel/Form/_shippingAddressInCheckoutRequired.html.twig' - priority: 15 - money: - template: '@SyliusAdmin/Channel/Form/_money.html.twig' - priority: 10 - - sylius.admin.channel.form.second_column_content: - blocks: - general: - template: '@SyliusAdmin/Channel/Form/_billingData.html.twig' - priority: 20 - look_and_feel: - template: '@SyliusAdmin/Channel/Form/_lookAndFeel.html.twig' - priority: 10 - price_history: - template: '@SyliusAdmin/Channel/Form/_priceHistoryConfig.html.twig' - priority: 0 - - sylius.admin.customer.form: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_content.html.twig' - priority: 10 - - sylius.admin.customer.form.content: - blocks: - columns: - template: '@SyliusAdmin/Customer/Form/_columns.html.twig' - priority: 10 - - sylius.admin.customer.form.first_column: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_firstColumn.html.twig' - priority: 10 - - sylius.admin.customer.form.customer_details: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_details.html.twig' - priority: 10 - - sylius.admin.customer.form.extra_information: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_extraInformation.html.twig' - priority: 10 - - sylius.admin.customer.form.second_column: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_secondColumn.html.twig' - priority: 10 - - sylius.admin.customer.form.account_credentials: - blocks: - content: - template: '@SyliusAdmin/Customer/Form/_accountCredentials.html.twig' - priority: 10 - - sylius.admin.dashboard.channel_switch: - blocks: - content: - template: '@SyliusAdmin/Dashboard/_channelSwitchContent.html.twig' - priority: 10 - - sylius.admin.dashboard.channel_switch_menu: - blocks: - search: - template: '@SyliusAdmin/Dashboard/ChannelSwitchMenu/_search.html.twig' - priority: 20 - channels: - template: '@SyliusAdmin/Dashboard/ChannelSwitchMenu/_channels.html.twig' - priority: 10 - - sylius.admin.product_variant.tab_inventory_content: - blocks: - content: - template: '@SyliusAdmin/ProductVariant/Tab/_inventoryContent.html.twig' - priority: 10 - - sylius.admin.product.tab_inventory_content: - blocks: - content: - template: '@SyliusAdmin/Product/Tab/_inventoryContent.html.twig' - priority: 10 - - sylius.admin.simple_product.show.details: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_details.html.twig' - priority: 10 - - sylius.admin.simple_product.show.details_content: - blocks: - labels: - template: '@SyliusAdmin/Product/Show/_detailsLabels.html.twig' - priority: 20 - table: - template: '@SyliusAdmin/Product/Show/_detailsTable.html.twig' - priority: 10 - - sylius.admin.simple_product.show.taxonomy: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_taxonomy.html.twig' - priority: 10 - - sylius.admin.simple_product.show.pricing: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_pricing.html.twig' - priority: 10 - - sylius.admin.simple_product.show.shipping: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_shipping.html.twig' - priority: 10 - - sylius.admin.simple_product.show.media: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_media.html.twig' - priority: 10 - - sylius.admin.simple_product.show.more_details: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_moreDetails.html.twig' - priority: 10 - - sylius.admin.simple_product.show.attributes: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_attributes.html.twig' - priority: 10 - - sylius.admin.simple_product.show.associations: - blocks: - content: - template: '@SyliusAdmin/Product/Show/_associations.html.twig' - priority: 10 - - sylius.admin.configurable_product.show: - blocks: - variants: - template: '@SyliusAdmin/Product/Show/_variants.html.twig' - priority: 10 - - sylius.admin.configurable_product.show.variant_item: - blocks: - button: - template: '@SyliusAdmin/Product/Show/VariantItem/_button.html.twig' - priority: 80 - item: - template: '@SyliusAdmin/Product/Show/VariantItem/_item.html.twig' - priority: 70 - option_values: - template: '@SyliusAdmin/Product/Show/VariantItem/_optionValues.html.twig' - priority: 60 - tracking: - template: '@SyliusAdmin/Product/Show/VariantItem/_tracking.html.twig' - priority: 50 - shipping: - template: '@SyliusAdmin/Product/Show/VariantItem/_shipping.html.twig' - priority: 40 - tax_category: - template: '@SyliusAdmin/Product/Show/VariantItem/_taxCategory.html.twig' - priority: 30 - stock: - template: '@SyliusAdmin/Product/Show/VariantItem/_stock.html.twig' - priority: 20 - edit_button: - template: '@SyliusAdmin/Product/Show/VariantItem/_editButton.html.twig' - priority: 10 - - sylius.admin.configurable_product.show.variant_content: - blocks: - shipping: - template: '@SyliusAdmin/Product/Show/_variantContentShipping.html.twig' - priority: 20 - pricing: - template: '@SyliusAdmin/Product/Show/_variantContentPricing.html.twig' - priority: 10 - - sylius.admin.shipment.ship_with_tracking_code: - blocks: - content: - template: '@SyliusAdmin/Shipment/Grid/Action/_shipWithTrackingCodeContent.html.twig' - priority: 10 - - sylius.admin.shipment.grid.ship: - blocks: - content: - template: '@SyliusAdmin/Shipment/Grid/_shipContent.html.twig' - priority: 10 - - sylius.admin.shipment.partial.ship: - blocks: - content: - template: '@SyliusAdmin/Shipment/Partial/_shipContent.html.twig' - priority: 10 - - sylius.admin.shipment.show.content: - blocks: - header: - template: '@SyliusAdmin/Shipment/Show/_headerWidget.html.twig' - priority: 30 - breadcrumb: - template: '@SyliusAdmin/Shipment/Show/_breadcrumb.html.twig' - priority: 20 - shipment_units: - template: '@SyliusAdmin/Shipment/Show/_shipmentUnits.html.twig' - priority: 10 - - sylius.admin.request_password_reset.content: - blocks: - form: - template: '@SyliusAdmin/Security/RequestPasswordReset/_form.html.twig' - priority: 10 - - sylius.admin.request_password_reset.before_form: - blocks: - header: - template: "@SyliusAdmin/Security/_logo.html.twig" - priority: 20 - flashes: - template: "@SyliusUi/_flashes.html.twig" - priority: 10 - - sylius.admin.request_password_reset.form.content: - blocks: - email: - template: '@SyliusAdmin/Security/RequestPasswordReset/_email.html.twig' - priority: 20 - submit: - template: '@SyliusAdmin/Security/RequestPasswordReset/_submit.html.twig' - priority: 10 - - sylius.admin.reset_password.content: - blocks: - form: - template: '@SyliusAdmin/Security/ResetPassword/_content.html.twig' - priority: 10 - - sylius.admin.reset_password.form: - blocks: - logo: - template: '@SyliusAdmin/Security/_logo.html.twig' - priority: 20 - content: - template: '@SyliusAdmin/Security/ResetPassword/_form.html.twig' - priority: 10 - - sylius.admin.reset_password.form.content: - blocks: - passwords: - template: '@SyliusAdmin/Security/ResetPassword/Form/_passwords.html.twig' - priority: 20 - submit: - template: '@SyliusAdmin/Security/ResetPassword/Form/_submit.html.twig' - priority: 10 diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml new file mode 100644 index 0000000000..681a942e6c --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml @@ -0,0 +1,13 @@ +# This file is part of the Sylius package. +# (c) Sylius Sp. z o.o. + +sylius_ui: + events: + sylius.admin.index.body: + blocks: + sidebar: + template: '@SyliusAdmin/Shared/Crud/Common/_sidebar.html.twig' + navbar: + template: '@SyliusAdmin/Shared/Crud/Common/_navbar.html.twig' + content: + template: '@SyliusAdmin/Shared/Crud/Common/_content.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Crud/index.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Crud/index.html.twig index 771150ac7d..9a49ffb602 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Crud/index.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Crud/index.html.twig @@ -1,25 +1,27 @@ -{% extends '@SyliusAdmin/layout.html.twig' %} +{% extends '@SyliusAdmin/Shared/Crud/index.html.twig' %} -{% set definition = resources.definition %} -{% set data = resources.data %} -{% set event_prefix = metadata.applicationName ~ '.admin.' ~ metadata.name ~ '.index' %} +{#{% extends '@SyliusAdmin/layout.html.twig' %}#} -{% set header = configuration.vars.header|default(metadata.applicationName~'.ui.'~metadata.pluralName) %} +{#{% set definition = resources.definition %}#} +{#{% set data = resources.data %}#} +{#{% set event_prefix = metadata.applicationName ~ '.admin.' ~ metadata.name ~ '.index' %}#} -{% block title %}{{ header|trans }} {{ parent() }}{% endblock %} +{#{% set header = configuration.vars.header|default(metadata.applicationName~'.ui.'~metadata.pluralName) %}#} -{% block content %} - {{ sylius_template_event([event_prefix, 'sylius.admin.index'], _context) }} -{% endblock %} +{#{% block title %}{{ header|trans }} {{ parent() }}{% endblock %}#} -{% block stylesheets %} - {{ parent() }} +{#{% block content %}#} +{# {{ sylius_template_event([event_prefix, 'sylius.admin.index'], _context) }}#} +{#{% endblock %}#} - {{ sylius_template_event([event_prefix ~ '.stylesheets', 'sylius.admin.index.stylesheets'], { 'metadata': metadata }) }} -{% endblock %} +{#{% block stylesheets %}#} +{# {{ parent() }}#} -{% block javascripts %} - {{ parent() }} +{# {{ sylius_template_event([event_prefix ~ '.stylesheets', 'sylius.admin.index.stylesheets'], { 'metadata': metadata }) }}#} +{#{% endblock %}#} - {{ sylius_template_event([event_prefix ~ '.javascripts', 'sylius.admin.index.javascripts'], { 'metadata': metadata }) }} -{% endblock %} +{#{% block javascripts %}#} +{# {{ parent() }}#} + +{# {{ sylius_template_event([event_prefix ~ '.javascripts', 'sylius.admin.index.javascripts'], { 'metadata': metadata }) }}#} +{#{% endblock %}#} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig new file mode 100644 index 0000000000..6dfc34673a --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig @@ -0,0 +1,3 @@ +
+ {{ sylius_template_event(_context.resource_event_prefix ~ '.content', { event_prefix: _context.event_prefix, resource_event_prefix: _context.resource_event_prefix }) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_navbar.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_navbar.html.twig new file mode 100644 index 0000000000..f66cbc5846 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_navbar.html.twig @@ -0,0 +1,5 @@ + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_sidebar.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_sidebar.html.twig new file mode 100644 index 0000000000..5e8e8ab520 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_sidebar.html.twig @@ -0,0 +1,5 @@ + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig new file mode 100644 index 0000000000..ab9546bd09 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig @@ -0,0 +1,14 @@ +{% extends '@SyliusAdmin/Shared/Layout/base.html.twig' %} + +{% set definition = resources.definition %} +{% set data = resources.data %} +{% set event_prefix = metadata.applicationName ~ '.admin.' ~ 'index' %} +{% set resource_event_prefix = metadata.applicationName ~ '.admin.' ~ metadata.name ~ '.index' %} + +{% set header = configuration.vars.header|default(metadata.applicationName~'.ui.'~metadata.pluralName) %} + +{% block title %}{{ header|trans }} {{ parent() }}{% endblock %} + +{% block body %} + {{ sylius_template_event('sylius.admin.index.body', { event_prefix: event_prefix, resource_event_prefix: resource_event_prefix }) }} +{% endblock %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig new file mode 100644 index 0000000000..e28f16e847 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig @@ -0,0 +1,22 @@ + + + + + + + + {% block title %}Sylius{% endblock %} + + {% block metatags %}{% endblock %} + {{ encore_entry_link_tags('admin-entry', null, 'admin') }} + {% block stylesheets %}{% endblock %} + + +
+ {% block body %}{% endblock %} +
+ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} +{% block javascript %}{% endblock %} + + From 7a84255b6deb4aa396a62ea60219f935dd5633af Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Sun, 17 Sep 2023 09:57:23 +0200 Subject: [PATCH 006/166] Add support for Twig Components in Template Events --- composer.json | 1 + config/bundles.php | 1 + rector.php | 19 ++--- .../AdminBundle/test/config/bundles.php | 1 + .../Tests/Application/config/bundles.php | 1 + .../Bundle/CoreBundle/test/config/bundles.php | 1 + .../DependencyInjection/Configuration.php | 1 + .../DependencyInjection/SyliusUiExtension.php | 3 +- .../UiBundle/Registry/TemplateBlock.php | 7 ++ .../HtmlDebugTemplateBlockRenderer.php | 59 +++++++++++----- .../HtmlDebugTemplateEventRenderer.php | 16 ++++- .../Renderer/TwigComponentBlockRenderer.php | 39 +++++++++++ .../config/services/template_event.xml | 5 ++ .../SyliusUiExtensionTest.php | 14 ++-- .../UiBundle/Tests/Functional/Kernel.php | 22 ++++++ .../Tests/Functional/TemplateEventTest.php | 23 +++++++ .../Functional/src/SomeTwigComponent.php | 39 +++++++++++ .../twigComponent/someTwigComponent.html.twig | 2 + .../templateEventsButComponent.txt.twig | 2 + src/Sylius/Bundle/UiBundle/composer.json | 1 + .../DefaultContextProviderSpec.php | 6 +- .../Registry/TemplateBlockRegistrySpec.php | 46 ++++++------- .../spec/Registry/TemplateBlockSpec.php | 27 ++++---- .../DelegatingTemplateEventRendererSpec.php | 4 +- .../HtmlDebugTemplateBlockRendererSpec.php | 43 +++++++----- .../HtmlDebugTemplateEventRendererSpec.php | 69 +++++++++++-------- .../TwigComponentBlockRendererSpec.php | 64 +++++++++++++++++ .../TwigTemplateBlockRendererSpec.php | 2 +- symfony.lock | 3 + 29 files changed, 395 insertions(+), 126 deletions(-) create mode 100644 src/Sylius/Bundle/UiBundle/Renderer/TwigComponentBlockRenderer.php create mode 100644 src/Sylius/Bundle/UiBundle/Tests/Functional/src/SomeTwigComponent.php create mode 100644 src/Sylius/Bundle/UiBundle/Tests/Functional/templates/blocks/twigComponent/someTwigComponent.html.twig create mode 100644 src/Sylius/Bundle/UiBundle/Tests/Functional/templates/templateEventsButComponent.txt.twig create mode 100644 src/Sylius/Bundle/UiBundle/spec/Renderer/TwigComponentBlockRendererSpec.php diff --git a/composer.json b/composer.json index 040547138d..85eb1d9329 100644 --- a/composer.json +++ b/composer.json @@ -131,6 +131,7 @@ "symfony/translation": "^6.3.3", "symfony/translation-contracts": "^2.5.2", "symfony/twig-bundle": "^6.3.0", + "symfony/ux-twig-component": "^2.11.2", "symfony/validator": "^6.3.4", "symfony/webpack-encore-bundle": "^1.17.1", "symfony/yaml": "^6.3.3", diff --git a/config/bundles.php b/config/bundles.php index b433583b42..359bcb430d 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -59,4 +59,5 @@ return [ SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/rector.php b/rector.php index 6f399dadbd..47f27d17ab 100644 --- a/rector.php +++ b/rector.php @@ -2,21 +2,12 @@ declare(strict_types=1); -use Rector\Core\Configuration\Option; -use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; -use Rector\Php74\Rector\Property\TypedPropertyRector; +use Rector\Config\RectorConfig; use Rector\Set\ValueObject\LevelSetList; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -return static function (ContainerConfigurator $containerConfigurator): void +return static function (RectorConfig $config): void { - $containerConfigurator->import(LevelSetList::UP_TO_PHP_80); - - $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::AUTO_IMPORT_NAMES, true); - $parameters->set(Option::IMPORT_SHORT_CLASSES, false); - - $services = $containerConfigurator->services(); - $services->set(TypedPropertyRector::class); - $services->set(ClosureToArrowFunctionRector::class); + $config->sets([ + LevelSetList::UP_TO_PHP_82 + ]); }; diff --git a/src/Sylius/Bundle/AdminBundle/test/config/bundles.php b/src/Sylius/Bundle/AdminBundle/test/config/bundles.php index 6d2563035c..5ca5b1789e 100644 --- a/src/Sylius/Bundle/AdminBundle/test/config/bundles.php +++ b/src/Sylius/Bundle/AdminBundle/test/config/bundles.php @@ -59,4 +59,5 @@ return [ SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/src/Sylius/Bundle/ApiBundle/Tests/Application/config/bundles.php b/src/Sylius/Bundle/ApiBundle/Tests/Application/config/bundles.php index f1ad14ebee..0a46f5807a 100644 --- a/src/Sylius/Bundle/ApiBundle/Tests/Application/config/bundles.php +++ b/src/Sylius/Bundle/ApiBundle/Tests/Application/config/bundles.php @@ -62,4 +62,5 @@ return [ SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/src/Sylius/Bundle/CoreBundle/test/config/bundles.php b/src/Sylius/Bundle/CoreBundle/test/config/bundles.php index b8d178f6b8..5d96f063b4 100644 --- a/src/Sylius/Bundle/CoreBundle/test/config/bundles.php +++ b/src/Sylius/Bundle/CoreBundle/test/config/bundles.php @@ -56,4 +56,5 @@ return [ Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/src/Sylius/Bundle/UiBundle/DependencyInjection/Configuration.php b/src/Sylius/Bundle/UiBundle/DependencyInjection/Configuration.php index fc8ea94709..c6ff67ec55 100644 --- a/src/Sylius/Bundle/UiBundle/DependencyInjection/Configuration.php +++ b/src/Sylius/Bundle/UiBundle/DependencyInjection/Configuration.php @@ -46,6 +46,7 @@ final class Configuration implements ConfigurationInterface ->booleanNode('enabled')->defaultNull()->end() ->arrayNode('context')->addDefaultsIfNotSet()->ignoreExtraKeys(false)->end() ->scalarNode('template')->defaultNull()->end() + ->scalarNode('component')->defaultNull()->end() ->integerNode('priority')->defaultNull()->end() ; diff --git a/src/Sylius/Bundle/UiBundle/DependencyInjection/SyliusUiExtension.php b/src/Sylius/Bundle/UiBundle/DependencyInjection/SyliusUiExtension.php index e6cf08af28..56c81ed1ce 100644 --- a/src/Sylius/Bundle/UiBundle/DependencyInjection/SyliusUiExtension.php +++ b/src/Sylius/Bundle/UiBundle/DependencyInjection/SyliusUiExtension.php @@ -57,8 +57,8 @@ final class SyliusUiExtension extends Extension $blocksPriorityQueue->insert($details, $details['priority'] ?? 0); } + /** @psalm-var array{name: string, eventName: string, template: string, component: string|null, context: array, priority: int, enabled: bool} $details */ foreach ($blocksPriorityQueue->toArray() as $details) { - /** @psalm-var array{name: string, eventName: string, template: string, context: array, priority: int, enabled: bool} $details */ $blocksForEvents[$eventName][$details['name']] = new Definition(TemplateBlock::class, [ $details['name'], $details['eventName'], @@ -66,6 +66,7 @@ final class SyliusUiExtension extends Extension $details['context'], $details['priority'], $details['enabled'], + $details['component'], ]); } } diff --git a/src/Sylius/Bundle/UiBundle/Registry/TemplateBlock.php b/src/Sylius/Bundle/UiBundle/Registry/TemplateBlock.php index 256dc91f1c..96c82cdf03 100644 --- a/src/Sylius/Bundle/UiBundle/Registry/TemplateBlock.php +++ b/src/Sylius/Bundle/UiBundle/Registry/TemplateBlock.php @@ -22,6 +22,7 @@ final class TemplateBlock private ?array $context, private ?int $priority, private ?bool $enabled, + private ?string $component = null, ) { } @@ -48,6 +49,11 @@ final class TemplateBlock return $this->template; } + public function getComponent(): ?string + { + return $this->component; + } + public function getContext(): array { return $this->context ?? []; @@ -80,6 +86,7 @@ final class TemplateBlock $block->context ?? $this->context, $block->priority ?? $this->priority, $block->enabled ?? $this->enabled, + $block->component ?? $this->component, ); } } diff --git a/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateBlockRenderer.php b/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateBlockRenderer.php index 677a1ab141..a8fe4d34c6 100644 --- a/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateBlockRenderer.php +++ b/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateBlockRenderer.php @@ -23,30 +23,55 @@ final class HtmlDebugTemplateBlockRenderer implements TemplateBlockRendererInter public function render(TemplateBlock $templateBlock, array $context = []): string { - $shouldRenderHtmlDebug = strrpos($templateBlock->getTemplate(), '.html.twig') !== false; + $isTemplateBlockComponent = null !== $templateBlock->getComponent(); + $shouldRenderHtmlDebug = $isTemplateBlockComponent || strrpos($templateBlock->getTemplate(), '.html.twig') !== false; + + if (!$shouldRenderHtmlDebug) { + return $this->templateBlockRenderer->render($templateBlock, $context); + } $renderedParts = []; - if ($shouldRenderHtmlDebug) { - $renderedParts[] = sprintf( - '', - $templateBlock->getEventName(), - $templateBlock->getName(), - $templateBlock->getTemplate(), - $templateBlock->getPriority(), - ); + if ($isTemplateBlockComponent) { + $renderedParts[] = $this->getBeginBlockForComponent($templateBlock); + } else { + $renderedParts[] = $this->getBeginBlockForTemplate($templateBlock); } $renderedParts[] = $this->templateBlockRenderer->render($templateBlock, $context); - - if ($shouldRenderHtmlDebug) { - $renderedParts[] = sprintf( - '', - $templateBlock->getEventName(), - $templateBlock->getName(), - ); - } + $renderedParts[] = $this->getEndBlock($templateBlock); return implode("\n", $renderedParts); } + + private function getBeginBlockForTemplate(TemplateBlock $templateBlock): string + { + return sprintf( + '', + $templateBlock->getEventName(), + $templateBlock->getName(), + $templateBlock->getTemplate(), + $templateBlock->getPriority(), + ); + } + + private function getBeginBlockForComponent(TemplateBlock $templateBlock): string + { + return sprintf( + '', + $templateBlock->getEventName(), + $templateBlock->getName(), + $templateBlock->getComponent(), + $templateBlock->getPriority(), + ); + } + + private function getEndBlock(TemplateBlock $templateBlock): string + { + return sprintf( + '', + $templateBlock->getEventName(), + $templateBlock->getName(), + ); + } } diff --git a/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateEventRenderer.php b/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateEventRenderer.php index 273e9eca1c..74eabf46cd 100644 --- a/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateEventRenderer.php +++ b/src/Sylius/Bundle/UiBundle/Renderer/HtmlDebugTemplateEventRenderer.php @@ -54,6 +54,20 @@ final class HtmlDebugTemplateEventRenderer implements TemplateEventRendererInter */ private function shouldRenderHtmlDebug(array $templateBlocks): bool { - return count($templateBlocks) === 0 || count(array_filter($templateBlocks, static fn (TemplateBlock $templateBlock): bool => strrpos($templateBlock->getTemplate(), '.html.twig') !== false)) >= 1; + return count($templateBlocks) === 0 || $this->hasAnyBlockWithComponentOrTemplate($templateBlocks); + } + + /** + * @param array $templateBlocks + */ + private function hasAnyBlockWithComponentOrTemplate(array $templateBlocks): bool + { + foreach ($templateBlocks as $templateBlock) { + if (null !== $templateBlock->getComponent() || strrpos($templateBlock->getTemplate(), '.html.twig') !== false) { + return true; + } + } + + return false; } } diff --git a/src/Sylius/Bundle/UiBundle/Renderer/TwigComponentBlockRenderer.php b/src/Sylius/Bundle/UiBundle/Renderer/TwigComponentBlockRenderer.php new file mode 100644 index 0000000000..6ccf48433b --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/Renderer/TwigComponentBlockRenderer.php @@ -0,0 +1,39 @@ + $context + */ + public function render(TemplateBlock $templateBlock, array $context = []): string + { + if (null === $templateBlock->getComponent()) { + return $this->decoratedRenderer->render($templateBlock, $context); + } + + return $this->componentRenderer->createAndRender($templateBlock->getComponent(), ['context' => $templateBlock->getContext() + $context]); + } +} diff --git a/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml b/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml index d7417506b1..02d6a12799 100644 --- a/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml +++ b/src/Sylius/Bundle/UiBundle/Resources/config/services/template_event.xml @@ -22,6 +22,11 @@ + + + + + diff --git a/src/Sylius/Bundle/UiBundle/Tests/DependencyInjection/SyliusUiExtensionTest.php b/src/Sylius/Bundle/UiBundle/Tests/DependencyInjection/SyliusUiExtensionTest.php index 9d66309240..f91dc8fe96 100644 --- a/src/Sylius/Bundle/UiBundle/Tests/DependencyInjection/SyliusUiExtensionTest.php +++ b/src/Sylius/Bundle/UiBundle/Tests/DependencyInjection/SyliusUiExtensionTest.php @@ -41,11 +41,11 @@ final class SyliusUiExtensionTest extends AbstractExtensionTestCase 0, [ 'first_event' => [ - 'first_block' => new Definition(TemplateBlock::class, ['first_block', 'first_event', 'first.html.twig', [], 0, true]), - 'second_block' => new Definition(TemplateBlock::class, ['second_block', 'first_event', 'second.html.twig', ['foo' => 'bar'], 0, true]), + 'first_block' => new Definition(TemplateBlock::class, ['first_block', 'first_event', 'first.html.twig', [], 0, true, null]), + 'second_block' => new Definition(TemplateBlock::class, ['second_block', 'first_event', 'second.html.twig', ['foo' => 'bar'], 0, true, null]), ], 'second_event' => [ - 'another_block' => new Definition(TemplateBlock::class, ['another_block', 'second_event', 'another.html.twig', [], 0, true]), + 'another_block' => new Definition(TemplateBlock::class, ['another_block', 'second_event', 'another.html.twig', [], 0, true, null]), ], ], ); @@ -69,10 +69,10 @@ final class SyliusUiExtensionTest extends AbstractExtensionTestCase TemplateBlockRegistryInterface::class, 0, ['event_name' => [ - 'first_block' => new Definition(TemplateBlock::class, ['first_block', 'event_name', 'first.html.twig', [], 5, true]), - 'second_block' => new Definition(TemplateBlock::class, ['second_block', 'event_name', 'second.html.twig', [], 0, true]), - 'third_block' => new Definition(TemplateBlock::class, ['third_block', 'event_name', 'third.html.twig', [], 0, true]), - 'fourth_block' => new Definition(TemplateBlock::class, ['fourth_block', 'event_name', 'fourth.html.twig', [], -5, true]), + 'first_block' => new Definition(TemplateBlock::class, ['first_block', 'event_name', 'first.html.twig', [], 5, true, null]), + 'second_block' => new Definition(TemplateBlock::class, ['second_block', 'event_name', 'second.html.twig', [], 0, true, null]), + 'third_block' => new Definition(TemplateBlock::class, ['third_block', 'event_name', 'third.html.twig', [], 0, true, null]), + 'fourth_block' => new Definition(TemplateBlock::class, ['fourth_block', 'event_name', 'fourth.html.twig', [], -5, true, null]), ]], ); } diff --git a/src/Sylius/Bundle/UiBundle/Tests/Functional/Kernel.php b/src/Sylius/Bundle/UiBundle/Tests/Functional/Kernel.php index d77d75743a..0f4a947b6e 100644 --- a/src/Sylius/Bundle/UiBundle/Tests/Functional/Kernel.php +++ b/src/Sylius/Bundle/UiBundle/Tests/Functional/Kernel.php @@ -16,12 +16,14 @@ namespace Sylius\Bundle\UiBundle\Tests\Functional; use Sonata\BlockBundle\SonataBlockBundle; use Sylius\Bundle\UiBundle\SyliusUiBundle; use Sylius\Bundle\UiBundle\Tests\Functional\src\CustomContextProvider; +use Sylius\Bundle\UiBundle\Tests\Functional\src\SomeTwigComponent; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\SecurityBundle\SecurityBundle; use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as HttpKernel; +use Symfony\UX\TwigComponent\TwigComponentBundle; use Symfony\WebpackEncoreBundle\WebpackEncoreBundle; final class Kernel extends HttpKernel @@ -37,6 +39,7 @@ final class Kernel extends HttpKernel new SonataBlockBundle(), new SyliusUiBundle(), new WebpackEncoreBundle(), + new TwigComponentBundle(), ]; } @@ -44,6 +47,8 @@ final class Kernel extends HttpKernel { $container->register(CustomContextProvider::class)->addTag('sylius.ui.template_event.context_provider'); + $container->register(SomeTwigComponent::class)->addTag('twig.component', ['template' => 'blocks/twigComponent/someTwigComponent.html.twig']); + $container->loadFromExtension('framework', [ 'secret' => 'S0ME_SECRET', ]); @@ -117,6 +122,23 @@ final class Kernel extends HttpKernel ], ], ], + 'template_event' => [ + 'blocks' => [ + 'block' => [ + 'component' => 'SomeTwigComponent', + ], + ], + ], + 'template_event_with_context' => [ + 'blocks' => [ + 'block' => [ + 'component' => 'SomeTwigComponent', + 'context' => [ + 'baz' => 'qux', + ], + ], + ], + ], ]]); $container->loadFromExtension('webpack_encore', [ diff --git a/src/Sylius/Bundle/UiBundle/Tests/Functional/TemplateEventTest.php b/src/Sylius/Bundle/UiBundle/Tests/Functional/TemplateEventTest.php index c9455a784e..fc0ddf6383 100644 --- a/src/Sylius/Bundle/UiBundle/Tests/Functional/TemplateEventTest.php +++ b/src/Sylius/Bundle/UiBundle/Tests/Functional/TemplateEventTest.php @@ -100,4 +100,27 @@ final class TemplateEventTest extends KernelTestCase Assert::assertSame($expectedLines, $renderedLines); } + + /** @test */ + public function it_renders_component(): void + { + $expectedLines = [ + '', + '', + 'Hello from the Twig Component :)', + 'Context: no context', + '', + '', + '', + '', + 'Hello from the Twig Component :)', + 'Context: baz=qux, foo=bar', + '', + '', + ]; + + $renderedLines = array_values(array_filter(explode("\n", $this->twig->render('templateEventsButComponent.txt.twig')))); + + Assert::assertSame($expectedLines, $renderedLines); + } } diff --git a/src/Sylius/Bundle/UiBundle/Tests/Functional/src/SomeTwigComponent.php b/src/Sylius/Bundle/UiBundle/Tests/Functional/src/SomeTwigComponent.php new file mode 100644 index 0000000000..2ddc5fa7bb --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/Tests/Functional/src/SomeTwigComponent.php @@ -0,0 +1,39 @@ +context) { + return 'no context'; + } + + $result = []; + + foreach ($this->context as $key => $value) { + $result[] = $key . '=' . $value; + } + + return implode(', ', $result); + } +} diff --git a/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/blocks/twigComponent/someTwigComponent.html.twig b/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/blocks/twigComponent/someTwigComponent.html.twig new file mode 100644 index 0000000000..e2e7985d81 --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/blocks/twigComponent/someTwigComponent.html.twig @@ -0,0 +1,2 @@ +Hello from the Twig Component :) +Context: {{ contextAsString }} diff --git a/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/templateEventsButComponent.txt.twig b/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/templateEventsButComponent.txt.twig new file mode 100644 index 0000000000..bc0f916d20 --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/Tests/Functional/templates/templateEventsButComponent.txt.twig @@ -0,0 +1,2 @@ +{{ sylius_template_event('template_event') }} +{{ sylius_template_event('template_event_with_context', { foo: 'bar' }) }} diff --git a/src/Sylius/Bundle/UiBundle/composer.json b/src/Sylius/Bundle/UiBundle/composer.json index e7570c3fef..6c5765babf 100644 --- a/src/Sylius/Bundle/UiBundle/composer.json +++ b/src/Sylius/Bundle/UiBundle/composer.json @@ -40,6 +40,7 @@ "symfony/security-core": "^6.3.3", "symfony/security-bundle": "^6.3.4", "symfony/templating": "^6.3.0", + "symfony/ux-twig-component": "^2.11.2", "symfony/webpack-encore-bundle": "^1.17.1", "laminas/laminas-stdlib": "^3.3.1" }, diff --git a/src/Sylius/Bundle/UiBundle/spec/ContextProvider/DefaultContextProviderSpec.php b/src/Sylius/Bundle/UiBundle/spec/ContextProvider/DefaultContextProviderSpec.php index ced9468556..b2fbdca261 100644 --- a/src/Sylius/Bundle/UiBundle/spec/ContextProvider/DefaultContextProviderSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/ContextProvider/DefaultContextProviderSpec.php @@ -26,7 +26,7 @@ final class DefaultContextProviderSpec extends ObjectBehavior function it_replaces_block_context_with_a_template_context(): void { - $templateBlock = new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['foo' => 'quux', 'quuz' => 'corge'], 0, true); + $templateBlock = new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['foo' => 'quux', 'quuz' => 'corge'], 0, true, null); $this ->provide(['foo' => 'bar', 'baz' => 'qux'], $templateBlock) @@ -41,12 +41,12 @@ final class DefaultContextProviderSpec extends ObjectBehavior function it_supports_all_template_blocks(): void { $this - ->supports(new TemplateBlock('block_name', 'event_name', null, null, null, null)) + ->supports(new TemplateBlock('block_name', 'event_name', null, null, null, null, null)) ->shouldReturn(true) ; $this - ->supports(new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['foo' => 'quux', 'quuz' => 'corge'], 0, true)) + ->supports(new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['foo' => 'quux', 'quuz' => 'corge'], 0, true, null)) ->shouldReturn(true) ; } diff --git a/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockRegistrySpec.php b/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockRegistrySpec.php index a4c1a74798..aad07c5dae 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockRegistrySpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockRegistrySpec.php @@ -31,7 +31,7 @@ final class TemplateBlockRegistrySpec extends ObjectBehavior function it_returns_all_template_blocks(): void { - $templateBlock = new TemplateBlock('block_name', 'event', 'block.html.twig', [], 10, true); + $templateBlock = new TemplateBlock('block_name', 'event', 'block.html.twig', [], 10, true, null); $this->beConstructedWith(['event' => ['block_name' => $templateBlock]]); @@ -40,9 +40,9 @@ final class TemplateBlockRegistrySpec extends ObjectBehavior function it_returns_enabled_template_blocks_for_a_given_event(): void { - $firstTemplateBlock = new TemplateBlock('first_block', 'event', 'first.html.twig', [], 0, true); - $secondTemplateBlock = new TemplateBlock('second_block', 'event', 'second.html.twig', [], 10, false); - $thirdTemplateBlock = new TemplateBlock('third_block', 'event', 'third.html.twig', [], 50, true); + $firstTemplateBlock = new TemplateBlock('first_block', 'event', 'first.html.twig', [], 0, true, null); + $secondTemplateBlock = new TemplateBlock('second_block', 'event', 'second.html.twig', [], 10, false, null); + $thirdTemplateBlock = new TemplateBlock('third_block', 'event', 'third.html.twig', [], 50, true, null); $this->beConstructedWith([ 'event' => [ @@ -61,24 +61,24 @@ final class TemplateBlockRegistrySpec extends ObjectBehavior { $this->beConstructedWith([ 'generic_event' => ['block' => new TemplateBlock('block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 0, true)], - 'specific_event_template' => ['block' => new TemplateBlock('block', 'specific_event_template', 'specific.html.twig', null, null, null)], - 'specific_event_context' => ['block' => new TemplateBlock('block', 'specific_event_context', null, ['other' => 'context'], null, null)], - 'specific_event_priority' => ['block' => new TemplateBlock('block', 'specific_event_priority', null, null, 10, null)], - 'specific_event_enabled' => ['block' => new TemplateBlock('block', 'specific_event_enabled', null, null, null, false)], + 'specific_event_template' => ['block' => new TemplateBlock('block', 'specific_event_template', 'specific.html.twig', null, null, null, null)], + 'specific_event_context' => ['block' => new TemplateBlock('block', 'specific_event_context', null, ['other' => 'context'], null, null, null)], + 'specific_event_priority' => ['block' => new TemplateBlock('block', 'specific_event_priority', null, null, 10, null, null)], + 'specific_event_enabled' => ['block' => new TemplateBlock('block', 'specific_event_enabled', null, null, null, false, null)], ]); $this->findEnabledForEvents(['specific_event_template', 'generic_event'])->shouldIterateLike([ - new TemplateBlock('block', 'specific_event_template', 'specific.html.twig', ['foo' => 'bar'], 0, true), + new TemplateBlock('block', 'specific_event_template', 'specific.html.twig', ['foo' => 'bar'], 0, true, null), ]); $this->findEnabledForEvents(['specific_event_context', 'generic_event'])->shouldIterateLike([ - new TemplateBlock('block', 'specific_event_context', 'generic.html.twig', ['other' => 'context'], 0, true), + new TemplateBlock('block', 'specific_event_context', 'generic.html.twig', ['other' => 'context'], 0, true, null), ]); $this->findEnabledForEvents(['specific_event_priority', 'generic_event'])->shouldIterateLike([ - new TemplateBlock('block', 'specific_event_priority', 'generic.html.twig', ['foo' => 'bar'], 10, true), + new TemplateBlock('block', 'specific_event_priority', 'generic.html.twig', ['foo' => 'bar'], 10, true, null), ]); $this->findEnabledForEvents(['specific_event_enabled', 'generic_event'])->shouldReturn([]); $this->findEnabledForEvents(['specific_event_priority', 'specific_event_template', 'generic_event'])->shouldIterateLike([ - new TemplateBlock('block', 'specific_event_priority', 'specific.html.twig', ['foo' => 'bar'], 10, true), + new TemplateBlock('block', 'specific_event_priority', 'specific.html.twig', ['foo' => 'bar'], 10, true, null), ]); } @@ -86,23 +86,23 @@ final class TemplateBlockRegistrySpec extends ObjectBehavior { $this->beConstructedWith([ 'generic_event' => [ - 'first_block' => new TemplateBlock('first_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 50, true), - 'third_block' => new TemplateBlock('third_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], -10, true), - 'second_block' => new TemplateBlock('second_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 0, true), - 'invisible_block' => new TemplateBlock('invisible_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 0, false), + 'first_block' => new TemplateBlock('first_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 50, true, null), + 'third_block' => new TemplateBlock('third_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], -10, true, null), + 'second_block' => new TemplateBlock('second_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 0, true, null), + 'invisible_block' => new TemplateBlock('invisible_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 0, false, null), ], 'specific_event' => [ - 'additional_block' => new TemplateBlock('additional_block', 'specific_event', 'specific.html.twig', [], 75, true), - 'second_block' => new TemplateBlock('second_block', 'specific_event', null, null, null, false), - 'third_block' => new TemplateBlock('third_block', 'specific_event', null, null, 100, null), - 'invisible_block' => new TemplateBlock('invisible_block', 'specific_event', null, [], null, null), + 'additional_block' => new TemplateBlock('additional_block', 'specific_event', 'specific.html.twig', [], 75, true, null), + 'second_block' => new TemplateBlock('second_block', 'specific_event', null, null, null, false, null), + 'third_block' => new TemplateBlock('third_block', 'specific_event', null, null, 100, null, null), + 'invisible_block' => new TemplateBlock('invisible_block', 'specific_event', null, [], null, null, null), ], ]); $this->findEnabledForEvents(['specific_event', 'generic_event'])->shouldIterateLike([ - new TemplateBlock('third_block', 'specific_event', 'generic.html.twig', ['foo' => 'bar'], 100, true), - new TemplateBlock('additional_block', 'specific_event', 'specific.html.twig', [], 75, true), - new TemplateBlock('first_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 50, true), + new TemplateBlock('third_block', 'specific_event', 'generic.html.twig', ['foo' => 'bar'], 100, true, null), + new TemplateBlock('additional_block', 'specific_event', 'specific.html.twig', [], 75, true, null), + new TemplateBlock('first_block', 'generic_event', 'generic.html.twig', ['foo' => 'bar'], 50, true, null), ]); } } diff --git a/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockSpec.php b/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockSpec.php index bf74737465..01679f729b 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Registry/TemplateBlockSpec.php @@ -20,11 +20,12 @@ final class TemplateBlockSpec extends ObjectBehavior { function it_represents_a_template_block(): void { - $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false); + $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false, null); $this->getName()->shouldReturn('block_name'); $this->getEventName()->shouldReturn('event_name'); $this->getTemplate()->shouldReturn('block.html.twig'); + $this->getComponent()->shouldReturn(null); $this->getContext()->shouldReturn(['foo' => 'bar']); $this->getPriority()->shouldReturn(10); $this->isEnabled()->shouldReturn(false); @@ -32,39 +33,39 @@ final class TemplateBlockSpec extends ObjectBehavior function it_overwrites_a_template_block_with_an_another_template_block(): void { - $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false); + $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false, null); $this - ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', 'another.html.twig', null, null, null)) - ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'another.html.twig', ['foo' => 'bar'], 10, false)) + ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', 'another.html.twig', null, null, null, 'some_component')) + ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'another.html.twig', ['foo' => 'bar'], 10, false, 'some_component')) ; $this - ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, [], null, null)) - ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', [], 10, false)) + ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, [], null, null, null)) + ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', [], 10, false, null)) ; $this - ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, null, -5, null)) - ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', ['foo' => 'bar'], -5, false)) + ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, null, -5, null, null)) + ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', ['foo' => 'bar'], -5, false, null)) ; $this - ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, null, null, true)) - ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', ['foo' => 'bar'], 10, true)) + ->overwriteWith(new TemplateBlock('block_name', 'specific_event_name', null, null, null, true, null)) + ->shouldBeLike(new TemplateBlock('block_name', 'specific_event_name', 'block.html.twig', ['foo' => 'bar'], 10, true, null)) ; } function it_throws_an_exception_if_trying_to_overwrite_with_a_differently_named_block(): void { - $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false); + $this->beConstructedWith('block_name', 'event_name', 'block.html.twig', ['foo' => 'bar'], 10, false, null); - $this->shouldThrow(\DomainException::class)->during('overwriteWith', [new TemplateBlock('different_name', 'specific_event_name', null, null, null, null)]); + $this->shouldThrow(\DomainException::class)->during('overwriteWith', [new TemplateBlock('different_name', 'specific_event_name', null, null, null, null, null)]); } function it_has_sensible_defaults(): void { - $this->beConstructedWith('block_name', 'event_name', null, null, null, null); + $this->beConstructedWith('block_name', 'event_name', null, null, null, null, null); $this->shouldThrow(\DomainException::class)->during('getTemplate'); $this->getContext()->shouldReturn([]); diff --git a/src/Sylius/Bundle/UiBundle/spec/Renderer/DelegatingTemplateEventRendererSpec.php b/src/Sylius/Bundle/UiBundle/spec/Renderer/DelegatingTemplateEventRendererSpec.php index 7e059be237..e1d080ca65 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Renderer/DelegatingTemplateEventRendererSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Renderer/DelegatingTemplateEventRendererSpec.php @@ -36,8 +36,8 @@ final class DelegatingTemplateEventRendererSpec extends ObjectBehavior TemplateBlockRegistryInterface $templateBlockRegistry, TemplateBlockRendererInterface $templateBlockRenderer, ): void { - $firstTemplateBlock = new TemplateBlock('first_block', 'best_event_ever', 'firstBlock.txt.twig', [], 0, true); - $secondTemplateBlock = new TemplateBlock('second_block', 'best_event_ever', 'secondBlock.txt.twig', [], 0, true); + $firstTemplateBlock = new TemplateBlock('first_block', 'best_event_ever', 'firstBlock.txt.twig', [], 0, true, null); + $secondTemplateBlock = new TemplateBlock('second_block', 'best_event_ever', 'secondBlock.txt.twig', [], 0, true, null); $templateBlockRegistry->findEnabledForEvents(['best_event_ever'])->willReturn([$firstTemplateBlock, $secondTemplateBlock]); diff --git a/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateBlockRendererSpec.php b/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateBlockRendererSpec.php index a40f4a13f6..b2a7a50ca2 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateBlockRendererSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateBlockRendererSpec.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace spec\Sylius\Bundle\UiBundle\Renderer; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use Sylius\Bundle\UiBundle\Registry\TemplateBlock; use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface; @@ -30,29 +29,41 @@ final class HtmlDebugTemplateBlockRendererSpec extends ObjectBehavior $this->shouldImplement(TemplateBlockRendererInterface::class); } - function it_renders_html_debug_comment_prepending_the_block_if_rendering_html_template( + function it_does_not_render_a_debug_html_comment_if_the_template_block_is_not_a_component_nor_a_twig_template( TemplateBlockRendererInterface $templateBlockRenderer, ): void { - $templateBlockRenderer->render(Argument::cetera())->willReturn('Block content'); + $templateBlock = new TemplateBlock('block_name', 'event_name', 'some_content', null, null, true, null); - $this->render( - new TemplateBlock('block_name', 'event_name', 'block.html.twig', [], 0, true), - ['foo' => 'bar'], - )->shouldReturn( - '' . "\n" . - 'Block content' . "\n" . - '', + $templateBlockRenderer->render($templateBlock, [])->willReturn('Rendered template'); + + $this->render($templateBlock, [])->shouldReturn('Rendered template'); + } + + function it_renders_a_debug_html_comment_if_the_template_block_has_a_configured_component( + TemplateBlockRendererInterface $templateBlockRenderer, + ): void { + $templateBlock = new TemplateBlock('block_name', 'event_name', 'some_content', null, null, true, 'component_name'); + + $templateBlockRenderer->render($templateBlock, [])->willReturn('Rendered template'); + + $this->render($templateBlock, [])->shouldReturn( + '' . "\n" . + 'Rendered template' . "\n" . + '' ); } - function it_does_not_render_html_debug_comment_prepending_the_block_if_rendering_non_html_template( + function it_renders_a_debug_html_comment_if_the_template_block_has_a_configured_twig_template( TemplateBlockRendererInterface $templateBlockRenderer, ): void { - $templateBlockRenderer->render(Argument::cetera())->willReturn('Block content'); + $templateBlock = new TemplateBlock('block_name', 'event_name', 'template.html.twig', [], null, true, null); - $this->render( - new TemplateBlock('block_name', 'event_name', 'block.txt.twig', [], 0, true), - ['foo' => 'bar'], - )->shouldReturn('Block content'); + $templateBlockRenderer->render($templateBlock, [])->willReturn('Rendered template'); + + $this->render($templateBlock, [])->shouldReturn( + '' . "\n" . + 'Rendered template' . "\n" . + '' + ); } } diff --git a/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateEventRendererSpec.php b/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateEventRendererSpec.php index 020f5b3f5d..34d626a3bc 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateEventRendererSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Renderer/HtmlDebugTemplateEventRendererSpec.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace spec\Sylius\Bundle\UiBundle\Renderer; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; use Sylius\Bundle\UiBundle\Registry\TemplateBlock; use Sylius\Bundle\UiBundle\Registry\TemplateBlockRegistryInterface; use Sylius\Bundle\UiBundle\Renderer\TemplateEventRendererInterface; @@ -31,51 +30,65 @@ final class HtmlDebugTemplateEventRendererSpec extends ObjectBehavior $this->shouldImplement(TemplateEventRendererInterface::class); } - function it_renders_html_debug_comment_if_at_least_one_template_is_a_html_one( + function it_does_not_render_html_debug_comments_when_there_are_no_template_blocks_with_a_defined_component_nor_template( TemplateEventRendererInterface $templateEventRenderer, - TemplateBlockRegistryInterface $templateBlockRegistry, + TemplateBlockRegistryInterface $templateBlockRegistry ): void { - $firstTemplateBlock = new TemplateBlock('first_block', 'event_block', 'firstBlock.txt.twig', [], 0, true); - $secondTemplateBlock = new TemplateBlock('second_block', 'event_block', 'secondBlock.html.twig', [], 0, true); + $templateBlockRegistry->findEnabledForEvents(['event_name'])->willReturn([ + new TemplateBlock('some_block_one', 'some_event', 'some content', null, null, true, null), + ]); - $templateBlockRegistry->findEnabledForEvents(['best_event_ever'])->willReturn([$firstTemplateBlock, $secondTemplateBlock]); + $templateEventRenderer->render(['event_name'], [])->willReturn('rendered_content'); - $templateEventRenderer->render(['best_event_ever'], ['foo' => 'bar'])->willReturn("First block\nSecond block"); + $this->render(['event_name'])->shouldReturn('rendered_content'); + } - $this->render(['best_event_ever'], ['foo' => 'bar'])->shouldReturn( - '' . "\n" . - 'First block' . "\n" . - 'Second block' . "\n" . - '', + function it_renders_html_debug_comment_when_no_template_block_passed( + TemplateEventRendererInterface $templateEventRenderer, + TemplateBlockRegistryInterface $templateBlockRegistry + ): void { + $templateBlockRegistry->findEnabledForEvents(['event_name'])->willReturn([]); + + $templateEventRenderer->render(['event_name'], [])->willReturn('rendered_content'); + + $this->render(['event_name'])->shouldReturn( + '' . "\n" . + 'rendered_content' . "\n" . + '' ); } - function it_does_not_render_html_debug_comment_if_no_html_templates_are_found( + function it_renders_html_debug_comment_when_at_least_one_block_has_a_configured_component( TemplateEventRendererInterface $templateEventRenderer, - TemplateBlockRegistryInterface $templateBlockRegistry, + TemplateBlockRegistryInterface $templateBlockRegistry ): void { - $firstTemplateBlock = new TemplateBlock('first_block', 'event_block', 'firstBlock.txt.twig', [], 0, true); - $secondTemplateBlock = new TemplateBlock('second_block', 'event_block', 'secondBlock.txt.twig', [], 0, true); + $templateBlockRegistry->findEnabledForEvents(['event_name'])->willReturn([ + new TemplateBlock('some_block_one', 'some_event', 'some content', null, null, true, 'SomeComponent'), + ]); - $templateBlockRegistry->findEnabledForEvents(['best_event_ever'])->willReturn([$firstTemplateBlock, $secondTemplateBlock]); + $templateEventRenderer->render(['event_name'], [])->willReturn('rendered_content'); - $templateEventRenderer->render(['best_event_ever'], ['foo' => 'bar'])->willReturn("First block\nSecond block"); - - $this->render(['best_event_ever'], ['foo' => 'bar'])->shouldReturn("First block\nSecond block"); + $this->render(['event_name'])->shouldReturn( + '' . "\n" . + 'rendered_content' . "\n" . + '' + ); } - function it_returns_html_debug_comment_if_no_blocks_are_found_for_an_event( + function it_renders_html_debug_comment_when_at_least_one_block_has_a_configured_twig_template( TemplateEventRendererInterface $templateEventRenderer, - TemplateBlockRegistryInterface $templateBlockRegistry, + TemplateBlockRegistryInterface $templateBlockRegistry ): void { - $templateBlockRegistry->findEnabledForEvents(['best_event_ever'])->willReturn([]); + $templateBlockRegistry->findEnabledForEvents(['event_name'])->willReturn([ + new TemplateBlock('some_block_one', 'some_event', 'some_template.html.twig', null, null, true, null), + ]); - $templateEventRenderer->render(Argument::cetera())->willReturn(''); + $templateEventRenderer->render(['event_name'], [])->willReturn('rendered_content'); - $this->render(['best_event_ever'])->shouldReturn( - '' . "\n" . - "\n" . - '', + $this->render(['event_name'])->shouldReturn( + '' . "\n" . + 'rendered_content' . "\n" . + '' ); } } diff --git a/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigComponentBlockRendererSpec.php b/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigComponentBlockRendererSpec.php new file mode 100644 index 0000000000..67c9b23678 --- /dev/null +++ b/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigComponentBlockRendererSpec.php @@ -0,0 +1,64 @@ +beConstructedWith($decoratedRenderer, $componentRenderer); + } + + function it_invokes_decorated_renderer_when_no_component_is_set( + TemplateBlockRendererInterface $decoratedRenderer, + ): void { + $someTemplateBlock = new TemplateBlock( + 'some_name', + 'some_event_name', + 'some_template', + ['some' => 'context'], + 0, + true, + null, + ); + $decoratedRenderer->render($someTemplateBlock, ['some' => 'context'])->shouldBeCalled(); + + $this->render($someTemplateBlock, ['some' => 'context']); + } + + function it_renders_a_component_when_component_is_set( + ComponentRendererInterface $componentRenderer, + ): void { + $someTemplateBlock = new TemplateBlock( + 'some_name', + 'some_event_name', + 'some_template', + ['another' => 'value'], + 0, + true, + 'some_component', + ); + $componentRenderer + ->createAndRender('some_component', ['context' => ['another' => 'value', 'some' => 'value']]) + ->willReturn('some_rendered_component') + ; + + $this->render($someTemplateBlock, ['some' => 'value'])->shouldReturn('some_rendered_component'); + } +} diff --git a/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigTemplateBlockRendererSpec.php b/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigTemplateBlockRendererSpec.php index e377111abd..57b504e67f 100644 --- a/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigTemplateBlockRendererSpec.php +++ b/src/Sylius/Bundle/UiBundle/spec/Renderer/TwigTemplateBlockRendererSpec.php @@ -43,7 +43,7 @@ final class TwigTemplateBlockRendererSpec extends ObjectBehavior ContextProviderInterface $firstContextProvider, ContextProviderInterface $secondContextProvider, ): void { - $templateBlock = new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['sample' => 'Hi', 'switch' => true], 0, true); + $templateBlock = new TemplateBlock('block_name', 'event_name', 'block.txt.twig', ['sample' => 'Hi', 'switch' => true], 0, true, null); $twig->render('block.txt.twig', ['sample' => 'Hello', 'switch' => true])->willReturn('Block content'); diff --git a/symfony.lock b/symfony.lock index bd5a114ac4..8b30d00909 100644 --- a/symfony.lock +++ b/symfony.lock @@ -882,6 +882,9 @@ "templates/base.html.twig" ] }, + "symfony/ux-twig-component": { + "version": "v2.11.2" + }, "symfony/validator": { "version": "4.3", "recipe": { From e33eb4d94fd1ea387dcba855f23ef7e7c23e1feb Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 10:56:29 +0200 Subject: [PATCH 007/166] Add navbar notifications button --- .../Resources/config/app/template_events.yaml | 10 + .../AdminBundle/Resources/config/services.xml | 1 + .../config/services/twig_component.xml | 18 ++ .../Components/Navbar/notifications.html.twig | 53 ++++ .../Shared/Components/Navbar/user.html.twig | 46 ++++ .../Crud/Common/Navbar/_items.html.twig | 3 + .../Shared/Crud/Common/Navbar/_menu.html.twig | 3 + .../views/Shared/Helper/avatar.html.twig | 10 + .../views/Shared/Helper/button.html.twig | 98 ++++++++ .../views/Shared/Helper/dropdown.html.twig | 55 ++++ .../views/Shared/Helper/icon.html.twig | 235 ++++++++++++++++++ .../Shared/Navbar/NotificationsComponent.php | 28 +++ 12 files changed, 560 insertions(+) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/notifications.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_menu.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/dropdown.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/icon.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/NotificationsComponent.php diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml index 681a942e6c..dbac38fc60 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml @@ -11,3 +11,13 @@ sylius_ui: template: '@SyliusAdmin/Shared/Crud/Common/_navbar.html.twig' content: template: '@SyliusAdmin/Shared/Crud/Common/_content.html.twig' + sylius.admin.index.navbar: + blocks: + items: + template: '@SyliusAdmin/Shared/Crud/Common/Navbar/_items.html.twig' + menu: + template: '@SyliusAdmin/Shared/Crud/Common/Navbar/_menu.html.twig' + sylius.admin.index.navbar.items: + blocks: + notifications: + component: 'SyliusAdminNavbarNotifications' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml index 1430fe51c2..bdc9ce558e 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml @@ -19,6 +19,7 @@ + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml new file mode 100644 index 0000000000..66fe71df42 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/notifications.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/notifications.html.twig new file mode 100644 index 0000000000..ac13de8832 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/notifications.html.twig @@ -0,0 +1,53 @@ +{# Rendered by \Sylius\Bundle\AdminBundle\TwigComponent\Shared\Navbar\NotificationsComponent #} + +{% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as dropdown %} +{% from '@SyliusAdmin/Shared/Helper/icon.html.twig' import icon %} + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig new file mode 100644 index 0000000000..27cd447bb8 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig @@ -0,0 +1,46 @@ +{% import '@SyliusAdmin/Shared/Helper/avatar.html.twig' as avatar %} +{% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as dropdown %} + +{% set dropdown_trigger %} +
+ {% set avatarPath = user.avatar.path|imagine_filter('sylius_admin_admin_user_avatar_thumbnail') %} + {{ avatar.small(avatarPath) }} +
+
Hello
+
{{ user.firstName }}
+
+
+{% endset %} + +{# TODO: Consider moving it to a separate method or create a Twig Component from it #} +{% set menu = [ + { + "title": "My account", + "url": path('sylius_admin_admin_user_update', {'id': user.id}), + "icon": "user", + }, + { + "title": "Logout", + "url": path('sylius_admin_logout'), + "icon": "logout", + }, + { + "type": "divider" + }, + { + "title": "Documentation", + "url": "https://docs.sylius.com", + "class":"small text-muted" + }, + { + "title": "Join Slack", + "url": "https://sylius.com/slack", + "class": "small text-muted" + }, + { + "title": "Report an issue", + "url": "https://github.com/Sylius/Sylius/issues", + "class": "small text-muted" + }, +] %} +{{ dropdown.list({ customTrigger: dropdown_trigger, direction: 'down-end' }, menu) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig new file mode 100644 index 0000000000..c9c167242b --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig @@ -0,0 +1,3 @@ + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_menu.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_menu.html.twig new file mode 100644 index 0000000000..f16ff57c33 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_menu.html.twig @@ -0,0 +1,3 @@ + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig new file mode 100644 index 0000000000..c6e15a70bc --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig @@ -0,0 +1,10 @@ +{% macro default(img, content, class) %} + + {{ content ? content }} + +{% endmacro %} + +{% macro small(img, content, class) %} + {% import _self as _ %} + {{ _.default(img, content, 'avatar-sm ' ~ class) }} +{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig new file mode 100644 index 0000000000..2bb4bdd533 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig @@ -0,0 +1,98 @@ +{% from '@SyliusAdmin/Shared/Helper/icon.html.twig' import icon as i %} + +{% macro default(params = {}) %} + {% set p = { + attr: null, + class: null, + text: "Button", + disabled: false, + dropdown: false, + icon: null, + iconOnly: false, + id: null, + size: null, + type: "button", + url: null, + }|merge(params) %} + + {% set buttonClass = 'btn' ~ + (p.class ? ' ' ~ p.class : '') ~ + (p.disabled ? ' disabled' : '') ~ + (p.dropdown ? ' dropdown-toggle' : '') ~ + (p.iconOnly ? ' btn-icon' : '') ~ + (p.size == 'large' ? ' btn-lg' : '') ~ + (p.size == 'small' ? ' btn-sm' : '') %} + + {% if p.url %} + + {{ p.icon ? i({ icon: p.icon }) }} + {{ not p.iconOnly ? p.text }} + + {% else %} + + {% endif %} +{% endmacro %} + +{% macro primary(params = {}) %} + {% import _self as _ %} + {% set params = { + class: null, + }|merge(params) %} + + {% set newParams = params|merge({ class: 'btn-primary ' ~ params.class }) %} + {{ _.default(newParams) }} +{% endmacro %} + +{% macro delete(params = {}) %} + {% import _self as _ %} + {% set params = { + class: null, + }|merge(params) %} + + {% set newParams = { text: 'Delete' }|merge(params)|merge({ class: 'btn btn-ghost-danger ' ~ params.class }) %} + {{ _.default(newParams) }} +{% endmacro %} + +{% macro create(params = {}) %} + {% import _self as _ %} + {% set params = { + type: 'submit', + text: 'sylius.ui.create'|trans, + }|merge(params) %} + + {{ _.primary(params) }} +{% endmacro %} + +{% macro update(params = {}) %} + {% import _self as _ %} + {% set params = { + type: 'submit', + text: 'sylius.ui.save_changes'|trans, + }|merge(params) %} + + {{ _.primary(params) }} +{% endmacro %} + +{% macro cancel(params = {}) %} + {% import _self as _ %} + {% set params = { + class: null, + text: 'sylius.ui.cancel'|trans, + url: app.request.headers.get('referer'), + }|merge(params)%} + + {{ _.default(params) }} +{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/dropdown.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/dropdown.html.twig new file mode 100644 index 0000000000..7d14e59757 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/dropdown.html.twig @@ -0,0 +1,55 @@ +{% macro default(params) %} + {% import '@SyliusAdmin/Shared/Helper/button.html.twig' as button %} + {% set p = { + button: {}, + class: null, + content: null, + customTrigger: null, + direction: 'down' + }|merge(params) %} + + {% if p.direction == 'down' %}{% set drop = '' %}{% endif %} + {% if p.direction == 'down-end' %}{% set drop = ' dropdown-menu-end' %}{% endif %} + + +{% endmacro %} + +{% macro list(params, items) %} + {% from '@SyliusAdmin/Shared/Helper/icon.html.twig' import icon %} + {% import _self as _ %} + + {% set content %} + {% for item in items %} + {% set item = { + type: null, + class: null, + icon: null + }|merge(item) %} + + {% if item.type == 'header' %} + {{ item.title }} + {% elseif item.type == 'divider' %} + + {% else %} + {% set extra_class = item.class ? ' ' ~ item.class %} + + {{ item.icon ? icon({ icon: item.icon, class: 'icon dropdown-item-icon icon-tabler' ~ extra_class }) }} + {{ item.title }} + + {% endif %} + {% endfor %} + {% endset %} + + {% set newParams = params|merge({ content: content }) %} + {{ _.default(newParams) }} +{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/icon.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/icon.html.twig new file mode 100644 index 0000000000..f05fb27beb --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/icon.html.twig @@ -0,0 +1,235 @@ +{% macro icon(params) %} + {% set icon = params.icon %} + {% set class = params.class|default('icon icon-tabler') %} + {% set width = params.width|default(24) %} + {% set height = params.height|default(24) %} + {% set stroke = params.stroke|default(2) %} + {% set strokeColor = params.strokeColor|default('currentColor') %} + {% set fill = params.fill|default('none') %} + + + {% if icon == 'search' %} + + + + {% endif %} + + {% if icon == 'bell' %} + + + + {% endif %} + + {% if icon == 'dashboard' %} + + + + + {% endif %} + + {% if icon == 'list-details' %} + + + + + + + + {% endif %} + + {% if icon == 'shopping-bag' %} + + + + {% endif %} + + {% if icon == 'user' %} + + + + {% endif %} + + {% if icon == 'users' %} + + + + + + {% endif %} + + {% if icon == 'percentage' %} + + + + + {% endif %} + + {% if icon == 'payment' %} + + + + + + {% endif %} + + {% if icon == 'adjustments' %} + + + + + + + + + + + {% endif %} + + {% if icon == 'plus' %} + + + + {% endif %} + + {% if icon == 'chevron-up' %} + + + {% endif %} + + {% if icon == 'chevron-down' %} + + + {% endif %} + + {% if icon == 'chevron-left' %} + + + {% endif %} + + {% if icon == 'chevron-right' %} + + + {% endif %} + + {% if icon == 'pencil' %} + + + + {% endif %} + + {% if icon == 'eye' %} + + + + {% endif %} + + {% if icon == 'trash-x' %} + + + + + + {% endif %} + + {% if icon == 'arrow-up-right' %} + + + + {% endif %} + + {% if icon == 'circle-check' %} + + + + {% endif %} + + {% if icon == 'info-circle' %} + + + + + {% endif %} + + {% if icon == 'exclamation-circle' %} + + + + + {% endif %} + + {% if icon == 'check' %} + + + {% endif %} + + {% if icon == 'x' %} + + + + {% endif %} + + {% if icon == 'history' %} + + + + {% endif %} + + {% if icon == 'send' %} + + + + {% endif %} + + {% if icon == 'spy' %} + + + + + + + {% endif %} + + {% if icon == 'coins' %} + + + + + + + {% endif %} + + {% if icon == 'slash' %} + + + {% endif %} + + {% if icon == 'external-link' %} + + + + + {% endif %} + + {% if icon == 'logout' %} + + + + + {% endif %} + + {% if icon == 'selector' %} + + + + {% endif %} + +{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/NotificationsComponent.php b/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/NotificationsComponent.php new file mode 100644 index 0000000000..c49fbb86dc --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/NotificationsComponent.php @@ -0,0 +1,28 @@ + + */ + #[ExposeInTemplate] + public function getNotifications(): array + { + return []; + } +} From 92fe99709121e1f56ebc2c0f065d51f5c65ba468 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 11:25:35 +0200 Subject: [PATCH 008/166] Add navbar user dropdown --- .../Resources/assets/styles/_navbar.scss | 14 ++++ .../Resources/assets/styles/main.scss | 2 + .../Resources/config/app/template_events.yaml | 2 + .../config/services/twig_component.xml | 8 ++ .../Shared/Components/Navbar/user.html.twig | 55 ++++---------- .../Crud/Common/Navbar/_items.html.twig | 2 +- .../Shared/Navbar/UserDropdown.php | 74 +++++++++++++++++++ .../Resources/translations/messages.en.yml | 1 + 8 files changed, 115 insertions(+), 43 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss create mode 100644 src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/UserDropdown.php diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss new file mode 100644 index 0000000000..69e280c3d9 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_navbar.scss @@ -0,0 +1,14 @@ +/*! + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +.sylius { + &.navbar-nav { + gap: 0.5rem; + } +} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss index 4e3dad47ae..f6bbd130d0 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss @@ -21,3 +21,5 @@ body { font-family: "Inter", sans-serif; font-feature-settings: "cv03", "cv04", "cv11"; } + +@import "navbar"; diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml index dbac38fc60..838ed8005b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml @@ -21,3 +21,5 @@ sylius_ui: blocks: notifications: component: 'SyliusAdminNavbarNotifications' + user_dropdown: + component: 'SyliusAdminUserDropdown' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml index 66fe71df42..0913d645c0 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig_component.xml @@ -14,5 +14,13 @@ + + + + + + + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig index 27cd447bb8..f87171c454 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig @@ -1,46 +1,17 @@ {% import '@SyliusAdmin/Shared/Helper/avatar.html.twig' as avatar %} {% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as dropdown %} -{% set dropdown_trigger %} -
- {% set avatarPath = user.avatar.path|imagine_filter('sylius_admin_admin_user_avatar_thumbnail') %} - {{ avatar.small(avatarPath) }} -
-
Hello
-
{{ user.firstName }}
-
-
-{% endset %} + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig index c9c167242b..c68b1b3ba2 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/_items.html.twig @@ -1,3 +1,3 @@ - {% endset %} - {{ dropdown.list({ customTrigger: dropdown_trigger, direction: 'down-end' }, menuElements) }} + {{ dropdown.list({ customTrigger: dropdown_trigger, direction: 'down-end' }, menuItems) }} diff --git a/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/UserDropdown.php b/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/UserDropdown.php index 5a4b987e47..69deffad77 100644 --- a/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/UserDropdown.php +++ b/src/Sylius/Bundle/AdminBundle/TwigComponent/Shared/Navbar/UserDropdown.php @@ -13,9 +13,9 @@ declare(strict_types=1); namespace Sylius\Bundle\AdminBundle\TwigComponent\Shared\Navbar; +use Sylius\Component\User\Model\UserInterface; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate; @@ -31,19 +31,25 @@ final class UserDropdown #[ExposeInTemplate] public function getUser(): UserInterface { - return $this->security->getUser(); + $user = $this->security->getUser(); + + if (!$user instanceof UserInterface) { + throw new \RuntimeException('User must be an instance of Sylius\Component\User\Model\UserInterface'); + } + + return $user; } /** * @return array */ #[ExposeInTemplate] - public function getMenuElements(): array + public function getMenuItems(): array { return [ [ 'title' => $this->translator->trans('sylius.ui.my_account'), - 'url' => $this->urlGenerator->generate('sylius_admin_admin_user_update', ['id' => 1]), + 'url' => $this->urlGenerator->generate('sylius_admin_admin_user_update', ['id' => $this->getUser()->getId()]), 'icon' => 'user', ], [ From 15fa9840bd5d97eaeecc914acd5db9e97caf146d Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 13:48:03 +0200 Subject: [PATCH 015/166] Add user dropdown on the mobile view --- .../Resources/assets/styles/_avatar.scss | 14 +++++++++++ .../Resources/assets/styles/main.scss | 1 + .../Resources/config/app/template_events.yaml | 6 ++--- .../Shared/Components/Navbar/user.html.twig | 24 +++++++++---------- .../Navbar/Items/_userDropdown.html.twig | 6 +++++ .../Sidebar/_mobileUserDropdown.html.twig | 4 ---- .../Common/Sidebar/_userDropdown.html.twig | 3 +++ .../views/Shared/Helper/avatar.html.twig | 2 +- 8 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_avatar.scss create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/Items/_userDropdown.html.twig delete mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_mobileUserDropdown.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_userDropdown.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_avatar.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_avatar.scss new file mode 100644 index 0000000000..afb9a2e9c2 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/_avatar.scss @@ -0,0 +1,14 @@ +/*! + * This file is part of the Sylius package. + * + * (c) Sylius Sp. z o.o. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +.sylius { + &.avatar { + background-color: $gray-100; + } +} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss index f6bbd130d0..70a096fdda 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/styles/main.scss @@ -22,4 +22,5 @@ body { font-feature-settings: "cv03", "cv04", "cv11"; } +@import "avatar"; @import "navbar"; diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml index d4473ca307..bc0f2cff96 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml @@ -22,7 +22,7 @@ sylius_ui: notifications: component: 'SyliusAdminNavbarNotifications' user_dropdown: - component: 'SyliusAdminUserDropdown' + template: '@SyliusAdmin/Shared/Crud/Common/Navbar/Items/_userDropdown.html.twig' sylius.admin.common.navbar.menu: blocks: search: @@ -31,7 +31,7 @@ sylius_ui: blocks: logo: template: '@SyliusAdmin/Shared/Crud/Common/Sidebar/_logo.html.twig' - mobile_user_dropdown: - template: '@SyliusAdmin/Shared/Crud/Common/Sidebar/_mobileUserDropdown.html.twig' + user_dropdown: + template: '@SyliusAdmin/Shared/Crud/Common/Sidebar/_userDropdown.html.twig' menu: template: '@SyliusAdmin/Shared/Crud/Common/Sidebar/_menu.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig index 485c1907eb..72a17ab8c6 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Components/Navbar/user.html.twig @@ -1,17 +1,15 @@ {% import '@SyliusAdmin/Shared/Helper/avatar.html.twig' as avatar %} {% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as dropdown %} - +{{ dropdown.list({ customTrigger: dropdown_trigger, direction: 'down-end' }, menuItems) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/Items/_userDropdown.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/Items/_userDropdown.html.twig new file mode 100644 index 0000000000..f24c6bb5b5 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Navbar/Items/_userDropdown.html.twig @@ -0,0 +1,6 @@ +{% import '@SyliusAdmin/Shared/Helper/avatar.html.twig' as avatar %} +{% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as dropdown %} + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_mobileUserDropdown.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_mobileUserDropdown.html.twig deleted file mode 100644 index c324e8f987..0000000000 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_mobileUserDropdown.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -
- {# TODO: finish #} - {# {% include '_user.html' with { user: navbar.user } only %}#} -
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_userDropdown.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_userDropdown.html.twig new file mode 100644 index 0000000000..e408b06f69 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Sidebar/_userDropdown.html.twig @@ -0,0 +1,3 @@ +
+ {{ component('SyliusAdminUserDropdown') }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig index c6e15a70bc..c03ed4cc2d 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/avatar.html.twig @@ -1,5 +1,5 @@ {% macro default(img, content, class) %} - + {{ content ? content }} {% endmacro %} From 2cecce283825cc0baa89dc61cf1564b5f4e31864 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Fri, 22 Sep 2023 15:40:27 +0200 Subject: [PATCH 016/166] Add Admin Panel login page --- .../Resources/assets/entrypoint.js | 1 + .../assets/images/sylius-logo-dark-text.png | Bin 0 -> 17408 bytes .../Resources/assets/styles/_navbar.scss | 4 ++++ .../Resources/assets/styles/main.scss | 1 + .../Resources/config/app/template_events.yaml | 22 ++++++++++++++++++ .../Content/Form/_passwordField.html.twig | 1 + .../Content/Form/_rememberMeField.html.twig | 1 + .../Content/Form/_submitButton.html.twig | 3 +++ .../Content/Form/_usernameField.html.twig | 1 + .../Security/Login/Content/_form.html.twig | 7 ++++++ .../Security/Login/Content/_header.html.twig | 1 + .../views/Security/Login/_content.html.twig | 7 ++++++ .../views/Security/Login/_logo.html.twig | 3 +++ .../views/Security/_content.html.twig | 6 ----- .../Resources/views/Security/_logo.html.twig | 1 - .../Resources/views/Security/login.html.twig | 20 ++++++++-------- .../views/Shared/Layout/base.html.twig | 2 +- .../Resources/translations/messages.en.yml | 1 + 18 files changed, 64 insertions(+), 18 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/assets/images/sylius-logo-dark-text.png create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/Form/_passwordField.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/Form/_rememberMeField.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/Form/_submitButton.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/Form/_usernameField.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/_form.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/_header.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_content.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_logo.html.twig delete mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/_content.html.twig delete mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Security/_logo.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js b/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js index b91b3eaae7..adb9723c04 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js +++ b/src/Sylius/Bundle/AdminBundle/Resources/assets/entrypoint.js @@ -15,3 +15,4 @@ import './scripts/choices'; import 'bootstrap'; import './images/sylius-logo.svg'; +import './images/sylius-logo-dark-text.png'; diff --git a/src/Sylius/Bundle/AdminBundle/Resources/assets/images/sylius-logo-dark-text.png b/src/Sylius/Bundle/AdminBundle/Resources/assets/images/sylius-logo-dark-text.png new file mode 100644 index 0000000000000000000000000000000000000000..e561950db290f8cfe767d453d2d8dba8b450e589 GIT binary patch literal 17408 zcmXtgbwE_#^Y&f36p)q%2?eR8TS8Py#HG8tJ6GuxM5IAlmhNr|>0UaerKJ14e7^6G zKZxb-J?G4wGxI#p%-OK_N^*~Ip5g!i@aXLunGXPfq5=M1hJ^usAKxc<3jRQImU{aU z3;goIG6@C$#&&q4=?nm*;KigLAQHG|b>NE>F0vXfs`h3s?uJgLfV;aphozmhv$3Ir zDTlq2dCI;hcqcmGt<0;B9;tf^o<1KZFC`9#oz0n(0(BwPb{2$h_S4`|Q{CvFt8*(R z_9(UX)U{Qxes+TK6wEfn zTP2=+W9lDBYaDnse0}=w^u_N~XK{3%RH4oJO#+#2R$cCUQ4GIX2VQ**S1r$hT~R44 z`oOa816Kg@tpw+K)M3D${6-simr*Q=+oq_u`Q+jMe1BZw>HB}zNmwqhz5s&9aL%5v zx*VsDliKD!ra%HItX<+#)Dx53em0I1!l||8-z30A()On@SVVx{pNBihc$q|upl(Vy zo7<@}obxje{QYAZG(W+E*~VV$giRkv&_PonyH#N?>V~Aa1H?9uFRxjSoZ`ZIN|LyI zqt@CV#xSIuVQ?80_*GF{O=;_ z>xIlUEc|#jukFwsiWll1?y-Ug-eY?E%lmHyDUU#o;flpQ&aqK25?Y-J7le|Ir9 z`MmyPJmF?Ny{V~*LZ;@1-(R6T_5Hf6`hHC|6r8J+pj-_WHJ8t5v2Wt}!otXVe@{9B zNjieE?76k+B_|d*+utn(a5@A-u_Wv%k5cX%$1@Z0QOR)tnZOp`YX%9Mh#s0Gu zVTG(kKpg43&$s)QX;eHKT} z%+^w=#OL;^lBe@=2E@(61vi~8|GW4$=W8Rn^Z_o}#vN93#Y?y~ zG}#$ab@&53Z%M)X@0Y!#qTH1-|LM;TiP)T<9f}riQz9wP?+^NZBl(Ncx%T|YZ{z{9aNT&D!6nat=I#IH z6>mf6woIwK;95-)aqoAYz91*U1FZ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=z9fAuv1U2Le>>-?D*ZgpMo$mws&Z5{&6MQkqQB(!Rxei=H(5*}x31D6`KB%ky!&M^W2Flg}Lcd1_b(YMFAk`d_&u;}KsbH*ONN?p>Iz??;d=`sT=st(>!_6)k z@5Hb;z0(-y`1o^M!%cadiE1M&>7xnKmQx@nw%1*;1AWd2#9|i0>VQ~;L2=y9fIkB> z#%k`ihM1I;qZ+Ky(La{b!xWq-!?Y77Ex+&rP@9Lo7Gt%wy$V=9zkGQ-C=MuG|dNH~-r z>$>+RR0ESICAtpM=2hx!!e;iPy+gCeckr4f{&&2?7}!_goV5K#Z}Z~GaP04Rf(|mj#SX)Jli(5Jh?O8jur)cDK=lV*3h2iXnv0Mlac5Gy4x0uoN z7(6BE$MbN6tXloN(#U2)x;X;r*`aY%o^R*D;PZSv_RQ;Rx?djW_ion>;ztwjPW>vIi969fmP-y zqOfo`(UBj{()?DElkmAY2-Le$j)Dlpg20pRzh}WiA^E7SBK#P1#f7|H3}(Sg2XbI~ z`0G7talC7~9mfs5herO~UPk9||cdp&?n^Na8^BjFl{StQ!l^N=1b>tvq> zLvjhQIQ%U{Fp!|6cUmf&`f{gvrM(5<2Lxw#*=IIFA*eAalsBu$sHj0?^KJ9)!5R4A z0Qh^>j~zC_qYYBFNX*vLfeTPl!GFc!Kq^(oz6XkuEXB{ z7smiN|JECDnxoCtZ(MTyNRJ~4agd^-qLWNBaTS0|VeJZ>T>ze7#(cvt-n2KJ5JDs` zD<@b0FnnS7b_Q00000NkvXXu0mjf +{{ form_end(form, {'render_rest': false}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/_header.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/_header.html.twig new file mode 100644 index 0000000000..3ebc72019e --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/Content/_header.html.twig @@ -0,0 +1 @@ +

{{ 'sylius.ui.login_to_your_account'|trans }}

diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_content.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_content.html.twig new file mode 100644 index 0000000000..57ecda8e7b --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_content.html.twig @@ -0,0 +1,7 @@ +{% set event_name = _context.event_prefix ~ '.content' %} + +
+
+ {{ sylius_template_event(event_name, _context|merge({ event_prefix: event_name })) }} +
+
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_logo.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_logo.html.twig new file mode 100644 index 0000000000..3a44a06cd1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/Login/_logo.html.twig @@ -0,0 +1,3 @@ +
+ Sylius +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_content.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_content.html.twig deleted file mode 100644 index 3cdf42fac3..0000000000 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_content.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% include '@SyliusUi/Security/_login.html.twig' - with { - 'action': path('sylius_admin_login_check'), - 'paths': {'logo': asset('build/admin/images/logo.png', 'admin')} - } -%} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_logo.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_logo.html.twig deleted file mode 100644 index 06765f40a9..0000000000 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/_logo.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@SyliusUi/Security/_logo.html.twig' with {'paths': {'logo': asset('build/admin/images/logo.png', 'admin')}} %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/login.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/login.html.twig index 622287c2a8..ca0b452149 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Security/login.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Security/login.html.twig @@ -1,15 +1,15 @@ -{% extends '@SyliusUi/Layout/centered.html.twig' %} +{% extends '@SyliusAdmin/Shared/Layout/base.html.twig' %} + +{% set event_name = 'sylius.admin.security.login' %} {% block title %}Sylius | {{ 'sylius.ui.administration_panel_login'|trans }}{% endblock %} -{% block stylesheets %} - {{ sylius_template_event('sylius.admin.layout.stylesheets') }} -{% endblock %} +{% block body_class %}d-flex flex-column{% endblock %} -{% block content %} - {{ sylius_template_event('sylius.admin.login.content', _context) }} -{% endblock %} - -{% block javascripts %} - {{ sylius_template_event('sylius.admin.layout.javascripts') }} +{% block body %} +
+
+ {{ sylius_template_event(event_name, { event_prefix: event_name }|merge(_context)) }} +
+
{% endblock %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig index e28f16e847..a6ca4a7f28 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Layout/base.html.twig @@ -11,7 +11,7 @@ {{ encore_entry_link_tags('admin-entry', null, 'admin') }} {% block stylesheets %}{% endblock %} - +
{% block body %}{% endblock %}
diff --git a/src/Sylius/Bundle/UiBundle/Resources/translations/messages.en.yml b/src/Sylius/Bundle/UiBundle/Resources/translations/messages.en.yml index 90fd0d620c..25b7156bfb 100644 --- a/src/Sylius/Bundle/UiBundle/Resources/translations/messages.en.yml +++ b/src/Sylius/Bundle/UiBundle/Resources/translations/messages.en.yml @@ -447,6 +447,7 @@ sylius: login: 'Login' login_button: 'Login' login_sylius_store: 'Login Sylius store' + login_to_your_account: 'Login to your account' logout: 'Logout' look_and_feel: 'Look & feel' lowest_price_before_discount: 'Lowest price before discount' From 63136e4d277cf2878aa415c158e21d07e16dcd45 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Sat, 23 Sep 2023 13:39:55 +0200 Subject: [PATCH 017/166] Add header to the CRUD's index page --- .../Resources/config/app/template_events.yaml | 11 +++----- .../config/app/template_events/crud.yaml | 26 +++++++++++++++++++ .../config/app/template_events/customer.yaml | 0 .../Header/TitleBlock/_actions.html.twig | 12 +++++++++ .../Header/TitleBlock/_title.html.twig | 9 +++++++ .../Content/Header/_titleBlock.html.twig | 6 +++++ .../Crud/Common/Content/_header.html.twig | 8 ++++++ .../Shared/Crud/Common/_content.html.twig | 6 ++--- .../Content/Header/_breadcrumbs.html.twig | 6 +++++ .../views/Shared/Crud/index.html.twig | 5 ++-- .../views/Shared/Helper/breadcrumbs.html.twig | 14 ++++++++++ .../views/Shared/Helper/header.html.twig | 17 ++++++++++++ 12 files changed, 106 insertions(+), 14 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/customer.yaml create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/_titleBlock.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/_header.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Header/_breadcrumbs.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/header.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml index 71ff64c0fd..a1c81d71c0 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events.yaml @@ -1,16 +1,11 @@ # This file is part of the Sylius package. # (c) Sylius Sp. z o.o. +imports: + - { resource: 'template_events/*.yaml' } + sylius_ui: events: - sylius.admin.index.body: - blocks: - sidebar: - template: '@SyliusAdmin/Shared/Crud/Common/_sidebar.html.twig' - navbar: - template: '@SyliusAdmin/Shared/Crud/Common/_navbar.html.twig' - content: - template: '@SyliusAdmin/Shared/Crud/Common/_content.html.twig' sylius.admin.common.navbar: blocks: items: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml new file mode 100644 index 0000000000..6ddaef15ab --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml @@ -0,0 +1,26 @@ +sylius_ui: + events: + sylius.admin.index.body: + blocks: + sidebar: + template: '@SyliusAdmin/Shared/Crud/Common/_sidebar.html.twig' + navbar: + template: '@SyliusAdmin/Shared/Crud/Common/_navbar.html.twig' + content: + template: '@SyliusAdmin/Shared/Crud/Common/_content.html.twig' + sylius.admin.index.body.content: + blocks: + header: + template: '@SyliusAdmin/Shared/Crud/Common/Content/_header.html.twig' + sylius.admin.index.body.content.header: + blocks: + breadcrumbs: + template: '@SyliusAdmin/Shared/Crud/Index/Content/Header/_breadcrumbs.html.twig' + title_block: + template: '@SyliusAdmin/Shared/Crud/Common/Content/Header/_titleBlock.html.twig' + sylius.admin.index.body.content.header.title_block: + blocks: + title: + template: '@SyliusAdmin/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig' + actions: + template: '@SyliusAdmin/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/customer.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/customer.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig new file mode 100644 index 0000000000..4235115ee1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig @@ -0,0 +1,12 @@ +{% import '@SyliusAdmin/Shared/Helper/dropdown.html.twig' as _dropdown %} + +
+ {% if resources.definition.actionGroups.main is defined %} + {% set actions %} + {% for action in resources.definition.getEnabledActions('main') %} + {{ sylius_grid_render_action(resources, action, null) }} + {% endfor %} + {% endset %} + {{ _dropdown.default({ content: actions, button: { text: 'Actions' } }) }} + {% endif %} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig new file mode 100644 index 0000000000..a5573f4004 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig @@ -0,0 +1,9 @@ +{% import '@SyliusAdmin/Shared/Helper/header.html.twig' as _header %} + +{% set header = configuration.vars.header|default(metadata.applicationName~'.ui.'~metadata.pluralName) %} + +
+
+ {{ _header.h1(header|trans) }} +
+
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/_titleBlock.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/_titleBlock.html.twig new file mode 100644 index 0000000000..c24ffcbd33 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/_titleBlock.html.twig @@ -0,0 +1,6 @@ +{% set event_name = event_prefix ~ '.title_block' %} +{% set resource_event_name = resource_event_prefix ~ '.title_block' %} + +
+ {{ sylius_template_event([resource_event_name, event_name], _context|merge({ event_prefix: event_name, resource_event_prefix: resource_event_name })) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/_header.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/_header.html.twig new file mode 100644 index 0000000000..6d7ec5b7d9 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/_header.html.twig @@ -0,0 +1,8 @@ +{% set event_name = event_prefix ~ '.header' %} +{% set resource_event_name = resource_event_prefix ~ '.header' %} + + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig index 71450a8907..a3c0b46154 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/_content.html.twig @@ -1,6 +1,6 @@ -{% set event_name = _context.event_prefix ~ '.content' %} -{% set resource_event_name = _context.resource_event_prefix ~ '.content' %} +{% set event_name = event_prefix ~ '.content' %} +{% set resource_event_name = resource_event_prefix ~ '.content' %}
- {{ sylius_template_event(event_name, { event_prefix: event_name, resource_event_prefix: resource_event_name }) }} + {{ sylius_template_event([resource_event_name, event_name], _context|merge({ event_prefix: event_name, resource_event_prefix: resource_event_name })) }}
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Header/_breadcrumbs.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Header/_breadcrumbs.html.twig new file mode 100644 index 0000000000..daa0d53a40 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Header/_breadcrumbs.html.twig @@ -0,0 +1,6 @@ +{% import '@SyliusAdmin/Shared/Helper/breadcrumbs.html.twig' as _breadcrumbs %} + +{{ _breadcrumbs.default([ + { 'name': 'Dashboard', 'url': path('sylius_admin_dashboard'), 'active': false }, + { 'name': metadata.applicationName~'.ui.'~metadata.pluralName, 'active': true }, +]) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig index 0397a89a87..ffded543b3 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/index.html.twig @@ -1,14 +1,13 @@ {% extends '@SyliusAdmin/Shared/Layout/base.html.twig' %} {% set definition = resources.definition %} -{% set data = resources.data %} {% set event_name = metadata.applicationName ~ '.admin.' ~ 'index.body' %} {% set resource_event_name = metadata.applicationName ~ '.admin.' ~ metadata.name ~ '.index.body' %} {% set header = configuration.vars.header|default(metadata.applicationName~'.ui.'~metadata.pluralName) %} -{% block title %}{{ header|trans }} {{ parent() }}{% endblock %} +{% block title %}{{ header|trans }} | {{ parent() }}{% endblock %} {% block body %} - {{ sylius_template_event(event_name, { event_prefix: event_name, resource_event_prefix: resource_event_name }) }} + {{ sylius_template_event([resource_event_name, event_name], { event_prefix: event_name, resource_event_prefix: resource_event_name, resources: resources, metadata: metadata, configuration: configuration }) }} {% endblock %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig new file mode 100644 index 0000000000..94564f3237 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig @@ -0,0 +1,14 @@ +{% macro default(breadcrumbs) %} + +{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/header.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/header.html.twig new file mode 100644 index 0000000000..f3d9e5f669 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/header.html.twig @@ -0,0 +1,17 @@ +{% macro default(level, header, icon, subheader) %} + + {# TODO: Decide whether we want to have an image here #} + {# {% if icon is not empty %}#} + {# #} + {# {% endif %}#} + {{ header }} + {% if subheader is not empty %} + {# TODO: Fix subheader styling #} + {# {{ subheader }}#} + {% endif %} + +{% endmacro %} + +{% macro h1(header, icon, subheader) %} + {{ _self.default(1, header, icon, subheader) }} +{% endmacro %} From 852f7030e40b065eb0ad6b80b1f094ac6b949577 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Sat, 23 Sep 2023 15:48:27 +0200 Subject: [PATCH 018/166] Add filters to the CRUD's index page --- .../Resources/config/app/config.yml | 11 ++++- .../config/app/template_events/crud.yaml | 6 +++ .../Index/Content/Grid/_filters.html.twig | 30 ++++++++++++ .../Crud/Index/Content/Grid/_table.twig | 0 .../Shared/Crud/Index/Content/_grid.html.twig | 49 +++++++++++++++++++ .../Shared/Grid/Filter/_boolean.html.twig | 3 ++ .../views/Shared/Grid/Filter/_date.html.twig | 10 ++++ .../Shared/Grid/Filter/_entities.html.twig | 3 ++ .../Shared/Grid/Filter/_entity.html.twig | 3 ++ .../Shared/Grid/Filter/_exists.html.twig | 3 ++ .../views/Shared/Grid/Filter/_money.html.twig | 11 +++++ .../Filter/_resourceAutocomplete.html.twig | 3 ++ .../Shared/Grid/Filter/_select.html.twig | 3 ++ .../Shared/Grid/Filter/_string.html.twig | 8 +++ .../views/Shared/Helper/accordion.html.twig | 39 +++++++++++++++ .../views/Shared/Helper/breadcrumbs.html.twig | 1 - .../views/Shared/Helper/table.html.twig | 0 17 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_filters.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_table.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/_grid.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_boolean.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_date.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entities.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entity.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_exists.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_money.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_resourceAutocomplete.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_select.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_string.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/accordion.html.twig create mode 100644 src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/table.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml index 35b0b07b08..03f01b3e4a 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/config.yml @@ -56,8 +56,15 @@ sylius_grid: update_product_positions: "@SyliusAdmin/Product/Grid/Action/updatePositions.html.twig" update_product_variant_positions: "@SyliusAdmin/ProductVariant/Grid/Action/updatePositions.html.twig" filter: - entities: '@SyliusUi/Grid/Filter/entities.html.twig' - resource_autocomplete: '@SyliusUi/Grid/Filter/resourceAutocomplete.html.twig' + boolean: '@SyliusAdmin/Shared/Grid/Filter/_boolean.html.twig' + date: '@SyliusAdmin/Shared/Grid/Filter/_date.html.twig' + entities: '@SyliusAdmin/Shared/Grid/Filter/_entities.html.twig' + entity: '@SyliusAdmin/Shared/Grid/Filter/_entity.html.twig' + exists: '@SyliusAdmin/Shared/Grid/Filter/_exists.html.twig' + money: '@SyliusAdmin/Shared/Grid/Filter/_money.html.twig' + resource_autocomplete: '@SyliusAdmin/Shared/Grid/Filter/_resourceAutocomplete.html.twig' + select: '@SyliusAdmin/Shared/Grid/Filter/_select.html.twig' + string: '@SyliusAdmin/Shared/Grid/Filter/_string.html.twig' liip_imagine: filter_sets: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml index 6ddaef15ab..05963b6944 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/template_events/crud.yaml @@ -12,6 +12,8 @@ sylius_ui: blocks: header: template: '@SyliusAdmin/Shared/Crud/Common/Content/_header.html.twig' + grid: + template: '@SyliusAdmin/Shared/Crud/Index/Content/_grid.html.twig' sylius.admin.index.body.content.header: blocks: breadcrumbs: @@ -24,3 +26,7 @@ sylius_ui: template: '@SyliusAdmin/Shared/Crud/Common/Content/Header/TitleBlock/_title.html.twig' actions: template: '@SyliusAdmin/Shared/Crud/Common/Content/Header/TitleBlock/_actions.html.twig' + sylius.admin.index.body.content.grid: + blocks: + filters: + template: '@SyliusAdmin/Shared/Crud/Index/Content/Grid/_filters.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_filters.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_filters.html.twig new file mode 100644 index 0000000000..3c805dd00e --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_filters.html.twig @@ -0,0 +1,30 @@ +{% import "@SyliusAdmin/Shared/Helper/accordion.html.twig" as _accordion %} +{% import "@SyliusAdmin/Shared/Helper/button.html.twig" as _button %} + +{% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')) %} +{% set areCriteriaSet = app.request.query.has('criteria') %} + +
+ {% set content %} +
+
+
+ {% for filter in resources.definition.enabledFilters|filter(filter => filter.enabled)|sort_by('position') %} +
+ {{ sylius_grid_render_filter(resources, filter) }} +
+ {% endfor %} +
+
+ {{ _button.primary({ text: 'sylius.ui.filter'|trans, type: 'submit' }) }} + {{ _button.default({ text: 'sylius.ui.reset'|trans, url: path }) }} +
+
+
+ {% endset %} + + {{ _accordion.default([{ + title: 'sylius.ui.filters'|trans, + content: content, + }], areCriteriaSet) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_table.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/Grid/_table.twig new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/_grid.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/_grid.html.twig new file mode 100644 index 0000000000..0f931da87a --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Index/Content/_grid.html.twig @@ -0,0 +1,49 @@ +{% from '@SyliusAdmin/Shared/Helper/icon.html.twig' import icon %} +{% import '@SyliusAdmin/Shared/Helper/table.html.twig' as _table %} + +{% set event_name = event_prefix ~ '.grid' %} +{% set resource_event_name = resource_event_prefix ~ '.grid' %} + +
+
+ {{ sylius_template_event([resource_event_name, event_name], _context|merge({ event_prefix: event_name, resource_event_prefix: resource_event_name })) }} +{# {{ sylius_grid_render(resources, '@SyliusAdmin/Shared/Crud/Index/Content/Grid/_content.html.twig') }}#} +{# {{ sylius_template_event('sylius.grid.filters', _context) }}#} + +{#
#} +{# {% block dataTable %}#} +{# {% if data|length > 0 %}#} +{#
#} +{# #} +{# #} +{# #} +{# {{ _table.headers(grid, definition, app.request.attributes) }}#} +{# #} +{# #} +{# #} +{# {% for row in data %}#} +{# {{ _table.row(grid, definition, row) }}#} +{# {% endfor %}#} +{# #} +{#
#} +{#
#} +{# {% else %}#} +{#
#} +{#
#} +{#
#} +{#

{{ 'sylius.grid.no_results'|trans }}

#} +{#

#} +{# {{ 'sylius.grid.no_results_adjust_your_search'|trans }}#} +{#

#} +{# #} +{#
#} +{# {% endif %}#} +{# {% endblock %}#} +{#
#} +
+
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_boolean.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_boolean.html.twig new file mode 100644 index 0000000000..2fe9d2f6f1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_boolean.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_date.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_date.html.twig new file mode 100644 index 0000000000..b6d6d14bd7 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_date.html.twig @@ -0,0 +1,10 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +
+ {{ form_row(form.from, { attr: {'class': 'sylius-filters__group'}, 'label': 'sylius.ui.date_filter', 'label_translation_parameters': {'%label%': filter.label|trans, '%altLabel%': form.from.vars.label|trans} }) }} +
+ + +
+ {{ form_row(form.to, { attr: {'class': 'sylius-filters__group'} }) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entities.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entities.html.twig new file mode 100644 index 0000000000..2fe9d2f6f1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entities.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entity.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entity.html.twig new file mode 100644 index 0000000000..2fe9d2f6f1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_entity.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_exists.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_exists.html.twig new file mode 100644 index 0000000000..2fe9d2f6f1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_exists.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_money.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_money.html.twig new file mode 100644 index 0000000000..ac7cd7257b --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_money.html.twig @@ -0,0 +1,11 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +
+ {{ form_row(form.greaterThan, {attr: {'placeholder': form.greaterThan.vars.label}, 'label': 'sylius.ui.money_filter', 'label_translation_parameters': {'%label%': filter.label|trans, '%altLabel%': form.greaterThan.vars.label|trans}}) }} +
+ + +
+ {{ form_row(form.lessThan, {attr: { 'placeholder': form.lessThan.vars.label }}) }} + {{ form_row(form.currency) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_resourceAutocomplete.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_resourceAutocomplete.html.twig new file mode 100644 index 0000000000..458236c349 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_resourceAutocomplete.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label, 'remote_url': path(filter.formOptions.remote_path), 'load_edit_url': path(filter.formOptions.load_edit_path)}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_select.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_select.html.twig new file mode 100644 index 0000000000..2fe9d2f6f1 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_select.html.twig @@ -0,0 +1,3 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +{{ form_row(form, {'label': filter.label}) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_string.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_string.html.twig new file mode 100644 index 0000000000..8d2c0b7f2a --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Filter/_string.html.twig @@ -0,0 +1,8 @@ +{% form_theme form 'bootstrap_5_layout.html.twig' %} + +
+ {% if form.type is defined %} + {{ form_row(form.type, {'label': filter.label}) }} + {% endif %} + {{ form_row(form.value, {attr: {placeholder: form.value.vars.label}, 'label': form.type is defined ? form.value.vars.label : filter.label}) }} +
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/accordion.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/accordion.html.twig new file mode 100644 index 0000000000..6ef0c81edf --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/accordion.html.twig @@ -0,0 +1,39 @@ +{% macro default(items, open = false, autoClose = null) %} + {% set autoClose = autoClose|default(true) %} + {% set id = id|default(random()) %} + +
+ {% for item in items %} + {% set item = { + 'open': open, + 'flag': null, + }|merge(item) %} + {% set item_id = item.id|default('collapse' ~ loop.index) %} + +
+

+ +

+
+ +
+ {{ item.content|default('Content') }} +
+
+
+ {% endfor %} +
+{% endmacro %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig index 94564f3237..a98b746ed7 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/breadcrumbs.html.twig @@ -1,6 +1,5 @@ {% macro default(breadcrumbs) %}