bring into standalone plugin for distribution
This commit is contained in:
55
templates/element/Layout/submenu.php
Normal file
55
templates/element/Layout/submenu.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?= $this->ActiveLink->link('Catalogs', [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCatalogs',
|
||||
'action' => 'index',
|
||||
], [
|
||||
'class' => 'submenu-link',
|
||||
'target' => [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCatalogs',
|
||||
],
|
||||
]); ?>
|
||||
<?= $this->ActiveLink->link('Products', [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'Products',
|
||||
'action' => 'index',
|
||||
], [
|
||||
'class' => 'submenu-link',
|
||||
'target' => [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'Products',
|
||||
],
|
||||
]); ?>
|
||||
<?= $this->ActiveLink->link('Categories', [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategories',
|
||||
'action' => 'index',
|
||||
], [
|
||||
'class' => 'submenu-link',
|
||||
'target' => [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategories',
|
||||
],
|
||||
]); ?>
|
||||
<?= $this->ActiveLink->link('Attributes', [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryAttributes',
|
||||
'action' => 'index',
|
||||
], [
|
||||
'class' => 'submenu-link',
|
||||
'target' => [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryAttributes',
|
||||
],
|
||||
]); ?>
|
||||
<?= $this->ActiveLink->link('External Catalogs', [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
'action' => 'index',
|
||||
], [
|
||||
'class' => 'submenu-link',
|
||||
'target' => [
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ExternalProductCatalogs',
|
||||
],
|
||||
]); ?>
|
||||
49
templates/element/ProductCategoryAttributes/form.php
Normal file
49
templates/element/ProductCategoryAttributes/form.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \Cake\Datasource\EntityInterface $productCategoryAttribute
|
||||
* @var \Cake\Collection\CollectionInterface|string[] $productCategories
|
||||
*/
|
||||
|
||||
$numOptions = !$productCategoryAttribute->hasValue('product_category_attribute_options') || empty($productCategoryAttribute->product_category_attribute_options) ? 0 : count($productCategoryAttribute->product_category_attribute_options);
|
||||
$cnt = 0;
|
||||
$prefix = $prefix ?? '';
|
||||
?>
|
||||
<?php
|
||||
echo $this->Form->control('name');
|
||||
echo $this->Form->control('product_category_id', ['options' => $productCategories, 'empty' => true]);
|
||||
echo $this->Form->control('attribute_type_id');
|
||||
echo $this->Form->control('enabled');
|
||||
?>
|
||||
<legend><?= __('Attribute Options') . '<small class="ms-2">' . $this->Html->link('Add Option', '#', [
|
||||
'id' => 'add-option-button',
|
||||
]) . '</small>'; ?></legend>
|
||||
<?= $this->Form->number('prefix', [
|
||||
'value' => $numOptions - 1,
|
||||
'id' => 'attribute_options_prefix',
|
||||
'style' => 'display:none;',
|
||||
'hx-get' => $this->Url->build([
|
||||
'plugin' => 'CakeProducts',
|
||||
'controller' => 'ProductCategoryAttributeOptions',
|
||||
'action' => 'add',
|
||||
]),
|
||||
'hx-trigger' => 'change',
|
||||
'hx-target' => '#attribute-options-container',
|
||||
'hx-swap' => 'beforeend',
|
||||
'data-test' => 1,
|
||||
]); ?>
|
||||
|
||||
<div id="attribute-options-container" class="container">
|
||||
<?php if ($productCategoryAttribute->hasValue('product_category_attribute_options')) : ?>
|
||||
<?php
|
||||
foreach ($productCategoryAttribute->product_category_attribute_options as $attributeOption) {
|
||||
$prefix = 'product_category_attribute_options.' . $cnt . '.';
|
||||
echo '<hr class="my-2">';
|
||||
echo $this->element('CakeProducts.ProductCategoryAttributes/product_category_attribute_option_form', [
|
||||
'attributeOption' => $attributeOption,
|
||||
'prefix' => $prefix,
|
||||
]);
|
||||
$cnt++;
|
||||
} ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \App\View\AppView $this
|
||||
* @var \Cake\Datasource\EntityInterface $productCategoryAttributeOption
|
||||
*/
|
||||
$cnt = 0;
|
||||
$prefix = $prefix ?? '';
|
||||
\Cake\Log\Log::debug('$prefix');
|
||||
\Cake\Log\Log::debug($prefix);
|
||||
?>
|
||||
<div class="container product-category-attribute-options-container" data-test="1" data-prefix="<?= $prefix; ?>">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?= $this->Form->control($prefix . 'attribute_value', [
|
||||
'label' => 'Value',
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col">
|
||||
<?= $this->Form->control($prefix . 'attribute_label', [
|
||||
'label' => 'Label',
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col">
|
||||
<?= $this->Form->control($prefix . 'enabled', [
|
||||
'type' => 'checkbox',
|
||||
'checked' => true,
|
||||
'label' => 'Enabled',
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user