diff --git a/Block/NodeType/CategoryChild.php b/Block/NodeType/CategoryChild.php index 6768d611..f7c60c0a 100644 --- a/Block/NodeType/CategoryChild.php +++ b/Block/NodeType/CategoryChild.php @@ -7,6 +7,7 @@ use Magento\Catalog\Api\CategoryRepositoryInterface; use Snowdog\Menu\Model\TemplateResolver; use Snowdog\Menu\Model\NodeType\Category as ModelCategory; +use Snowdog\Menu\Model\NodeType\CategoryChild as ModelCategoryChild; class CategoryChild extends Category { @@ -14,6 +15,10 @@ class CategoryChild extends Category * @var string */ protected $defaultTemplate = 'menu/node_type/category_child.phtml'; + /** + * @var string + */ + protected $customTemplateFolder = 'menu/custom/category_child/'; /** * @var string */ @@ -22,6 +27,10 @@ class CategoryChild extends Category * @var CategoryRepositoryInterface */ protected $categoryRepository; + /** + * @var ModelCategoryChild + */ + private $categoryChildModel; /** * Category constructor. @@ -31,6 +40,7 @@ class CategoryChild extends Category * @param ModelCategory $categoryModel * @param TemplateResolver $templateResolver * @param CategoryRepositoryInterface $categoryRepository + * @param ModelCategoryChild $categoryChildModel * @param array $data */ public function __construct( @@ -39,10 +49,12 @@ public function __construct( ModelCategory $categoryModel, TemplateResolver $templateResolver, CategoryRepositoryInterface $categoryRepository, + ModelCategoryChild $categoryChildModel, array $data = [] ) { parent::__construct($context, $coreRegistry, $categoryModel, $templateResolver, $data); $this->categoryRepository = $categoryRepository; + $this->categoryChildModel = $categoryChildModel; } /** @@ -58,6 +70,14 @@ public function getNodeCacheKeyInfo() ]; } + /** + * @inheritDoc + */ + public function getJsonConfig() + { + return $this->categoryChildModel->fetchConfigData(); + } + /** * @return \Magento\Framework\Phrase */ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbb0334..273b20a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Hyvä footer menu compatibility with Alpine CSP and cached menu HTML (SMM-58) +- Mobile top menu remaining visible in Hyvä Checkout (SMM-58) +- Custom URL field keeping the previous node type's content after changing a node's type (SMM-59) ### Updated - Bump minimatch from 3.1.2 to 3.1.5 ([#395](https://github.com/SnowdogApps/magento2-menu/pull/395)) - Bump lodash from 4.17.21 to 4.17.23 ([#390](https://github.com/SnowdogApps/magento2-menu/pull/390)) diff --git a/Console/Command/NodesValidatorCommand.php b/Console/Command/NodesValidatorCommand.php index 1e797beb..5c5dbdde 100644 --- a/Console/Command/NodesValidatorCommand.php +++ b/Console/Command/NodesValidatorCommand.php @@ -60,7 +60,7 @@ public function __construct( /** * {@inheritdoc} */ - protected function configure() + protected function configure(): void { $description = 'It will loop all menu nodes and return the IDs and description of invalid menu nodes.' . PHP_EOL @@ -72,7 +72,7 @@ protected function configure() parent::configure(); } - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): int { $this->setAreaCode(); $invalidNodeIds = []; diff --git a/Model/NodeType/CategoryChild.php b/Model/NodeType/CategoryChild.php index 172fad29..730e9a41 100644 --- a/Model/NodeType/CategoryChild.php +++ b/Model/NodeType/CategoryChild.php @@ -4,10 +4,58 @@ namespace Snowdog\Menu\Model\NodeType; +use Magento\Framework\Profiler; +use Snowdog\Menu\Model\Menu\Node\Image\File as NodeImage; use Snowdog\Menu\Model\NodeType\AbstractNode; +use Snowdog\Menu\Model\TemplateResolver; class CategoryChild extends AbstractNode { + /** + * @var TemplateResolver + */ + private $templateResolver; + + /** + * @param Profiler $profiler + * @param NodeImage $nodeImage + * @param TemplateResolver $templateResolver + */ + public function __construct( + Profiler $profiler, + NodeImage $nodeImage, + TemplateResolver $templateResolver + ) { + $this->templateResolver = $templateResolver; + + parent::__construct($profiler, $nodeImage); + } + + /** + * @inheritDoc + */ + public function fetchConfigData() + { + $this->profiler->start(__METHOD__); + + $data = [ + 'snowMenuNodeCustomTemplates' => [ + 'defaultTemplate' => 'category_child', + 'options' => $this->templateResolver->getCustomTemplateOptions('category_child'), + 'message' => __('Template not found'), + ], + 'snowMenuSubmenuCustomTemplates' => [ + 'defaultTemplate' => 'sub_menu', + 'options' => $this->templateResolver->getCustomTemplateOptions('sub_menu'), + 'message' => __('Template not found'), + ], + ]; + + $this->profiler->stop(__METHOD__); + + return $data; + } + /** * @inheritDoc */ diff --git a/Service/Menu/SaveRequestProcessor.php b/Service/Menu/SaveRequestProcessor.php index dc6e39a5..6190622a 100644 --- a/Service/Menu/SaveRequestProcessor.php +++ b/Service/Menu/SaveRequestProcessor.php @@ -176,7 +176,7 @@ public function processNodeObject( $nodeObject->setClasses($nodeData['classes']); } - if (isset($nodeData['content'])) { + if (array_key_exists('content', $nodeData)) { $nodeObject->setContent($nodeData['content']); } diff --git a/view/adminhtml/web/vue/field-type/autocomplete-lazy.vue b/view/adminhtml/web/vue/field-type/autocomplete-lazy.vue index fff89d21..b94bdab3 100644 --- a/view/adminhtml/web/vue/field-type/autocomplete-lazy.vue +++ b/view/adminhtml/web/vue/field-type/autocomplete-lazy.vue @@ -230,7 +230,9 @@ } else if (option && typeof option === 'string') { this.$set(this.item, this.itemKey, option); - this.$set(this.item, 'title', this.options.find(item => item.value === option)?.label); + if (!this.item.title) { + this.$set(this.item, 'title', this.options.find(item => item.value === option)?.label); + } } else { this.$set(this.item, this.itemKey, this.defaultSelectedOption ? this.defaultSelectedOption.value.toString() : ''); diff --git a/view/adminhtml/web/vue/field-type/autocomplete.vue b/view/adminhtml/web/vue/field-type/autocomplete.vue index a8ea0955..276f0a65 100644 --- a/view/adminhtml/web/vue/field-type/autocomplete.vue +++ b/view/adminhtml/web/vue/field-type/autocomplete.vue @@ -131,11 +131,15 @@ if (option && typeof option === 'object') { this.$set(this.item, this.itemKey, option.value.toString()); this.$set(this.item, this.itemIdKey, option.id.toString()); - this.$set(this.item, 'title', option.label); + if (!this.item.title) { + this.$set(this.item, 'title', option.label); + } } else if (option && typeof option === 'string') { this.$set(this.item, this.itemKey, option); - this.$set(this.item, 'title', this.options.find(item => item.value === option)?.label); + if (!this.item.title) { + this.$set(this.item, 'title', this.options.find(item => item.value === option)?.label); + } } else { this.$set(this.item, this.itemKey, this.defaultSelectedOption ? this.defaultSelectedOption.value.toString() : ''); diff --git a/view/frontend/layout/default_hyva.xml b/view/frontend/layout/default_hyva.xml index 6cf04883..d3024089 100644 --- a/view/frontend/layout/default_hyva.xml +++ b/view/frontend/layout/default_hyva.xml @@ -39,6 +39,11 @@ + + + + + + + + diff --git a/view/frontend/tailwind/tailwind-source.css b/view/frontend/tailwind/tailwind-source.css index a1caa01f..9b248083 100644 --- a/view/frontend/tailwind/tailwind-source.css +++ b/view/frontend/tailwind/tailwind-source.css @@ -1,7 +1,5 @@ -@layer utilities { - .snowdog-menu-text-hover { - @apply text-blue-700; - } +@utility snowdog-menu-text-hover { + color: var(--color-blue-700); } [x-cloak="tablet"] { diff --git a/view/frontend/templates/hyva-menu-footer/menu.phtml b/view/frontend/templates/hyva-menu-footer/menu.phtml index b79edbd4..c13ea0f2 100644 --- a/view/frontend/templates/hyva-menu-footer/menu.phtml +++ b/view/frontend/templates/hyva-menu-footer/menu.phtml @@ -10,49 +10,22 @@ use Snowdog\Menu\Block\Menu; /** @var ViewModelRegistry $viewModels */ $menu = $block->getMenu(); -$uniqueId = '_' . uniqid(); $heroicons = $viewModels->require(HeroiconsOutline::class); ?> -