v0.0.15 - catalags & apis many to many wip

This commit is contained in:
2025-03-31 00:48:00 -07:00
parent ce74025f6c
commit 4c65d23e2b
8 changed files with 173 additions and 69 deletions

View File

@@ -0,0 +1,18 @@
<?php
/**
* @var AppView $this
* @var EntityInterface|ExternalProductCatalog $externalProductCatalog
* @var array $productCatalogs
*/
use App\Model\Entity\ExternalProductCatalog;
use App\View\AppView;
use Cake\Datasource\EntityInterface;
$prefix = $prefix ?? '';
if ($this->request->getQuery('catalog_prefix') !== null) {
$prefix = 'external_product_catalogs_product_catalogs.' . $this->request->getQuery('catalog_prefix') . '.';
}
echo '<hr class="my-2">';
echo $this->Form->control($prefix . 'product_catalog_id', ['options' => $productCatalogs]);
?>

View File

@@ -0,0 +1,64 @@
<?php
/**
* @var AppView $this
* @var EntityInterface|ExternalProductCatalog $externalProductCatalog
* @var array $productCatalogs
*/
use App\Model\Entity\ExternalProductCatalog;
use App\View\AppView;
use Cake\Datasource\EntityInterface;
$numProductCatalogs = !$externalProductCatalog->hasValue('product_catalogs') || empty($externalProductCatalog->product_catalogs) ? 0 : count($externalProductCatalog->product_catalogs);
?>
<h4 class="mb-4">API Info</h4>
<?php
echo $this->Form->control('base_url');
echo $this->Form->control('api_url');
?>
<hr>
<h6></h6>
<h4 class="mb-4">Product Catalogs
<small class="ms-2 font-size-xs">
<?= $this->Html->link('Add Catalog', '#', [
'id' => 'add-product-catalog-button',
]); ?>
</small>
</h4>
<?= $this->Form->number('catalog_prefix', [
'value' => $numProductCatalogs - 1,
'id' => 'catalog_prefix',
'style' => 'display:none;',
'hx-get' => $this->Url->build([
'plugin' => false,
'controller' => 'ExternalProductCatalogsProductCatalogs',
'action' => 'add',
]),
'hx-trigger' => 'change',
'hx-target' => '#product-catalogs-container',
'hx-swap' => 'beforeend',
'data-test' => 1,
]); ?>
<?php
?>
<div id="product-catalogs-container" class="container">
<?php if ($externalProductCatalog->hasValue('product_catalogs')) : ?>
<?php
$cnt = 0;
foreach ($externalProductCatalog->product_catalogs as $productCatalog) {
$prefix = 'external_product_catalogs_product_catalogs.' . $cnt . '.';
echo '<hr class="my-2">';
echo $this->element('ExternalProductCatalogs/catalog_form', [
'productCatalog' => $productCatalog,
'prefix' => $prefix
]);
$cnt++;
} ?>
<?php endif; ?>
</div>
<?= $this->Html->script('CakeProducts.product_catalogs.js'); ?>