template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:47 +00:00
parent 20e330a825
commit 071c876af7
7 changed files with 62 additions and 36 deletions

View File

@ -14,12 +14,10 @@ declare(strict_types=1);
namespace Modules\Attribute\Theme\Backend\Components;
use Modules\Attribute\Models\AttributeType;
use phpOMS\Localization\L11nManager;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
use Web\Backend\Views\L11nView;
/**
* Component view.

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\Attribute\Theme\Backend\Components;
use Modules\Attribute\Models\AttributeType;
use Modules\Attribute\Models\AttributeValue;
use phpOMS\Localization\L11nManager;
use phpOMS\Message\RequestAbstract;
@ -32,6 +33,14 @@ use Web\Backend\Views\L11nView;
*/
class AttributeValueView extends View
{
/**
* Attributes
*
* @var \Modules\Attribute\Models\AttributeType
* @since 1.0.0
*/
public AttributeType $type;
/**
* Attributes
*

View File

@ -18,19 +18,21 @@ use phpOMS\Uri\UriFactory;
$types = AttributeValueType::getConstants();
$isNew = $this->attribute->id === 0;
$path = $this->path;
$path = $this->path;
echo $this->data['nav']->render(); ?>
<div class="tabview tab-2">
<?php if (!$isNew) : ?>
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Type', 'Attribute', 'Backend'); ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Defaults', 'Attribute', 'Backend'); ?></label>
</ul>
</div>
<?php endif; ?>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<input type="radio" id="c-tab-1" name="tabular-2"<?= $isNew || $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-md-6 col-xs-12">
@ -45,12 +47,12 @@ echo $this->data['nav']->render(); ?>
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name', 'Attribute', 'Backend'); ?></label>
<input id="iNAme" type="text" value="<?= $this->printHtml($this->attribute->name); ?>" disabled>
<input id="iNAme" type="text" value="<?= $this->printHtml($this->attribute->name); ?>"<?= $isNew ? ' required' : ' disabled'; ?>>
</div>
<div class="form-group">
<label for="iType"><?= $this->getHtml('Datatype', 'Attribute', 'Backend'); ?></label>
<select id="iType" name="type" disabled>
<select id="iType" name="type"<?= $isNew ? '' : ' disabled'; ?>>
<?php foreach ($types as $key => $type) : ?>
<option value="<?= $type; ?>"<?= $type === $this->attribute->datatype ? ' selected' : ''; ?>><?= $this->getHtml($key, 'Attribute', 'Backend'); ?>
<?php endforeach; ?>
@ -90,6 +92,7 @@ echo $this->data['nav']->render(); ?>
</div>
</div>
<?php if (!$isNew) : ?>
<div class="row">
<?= $this->l11nView->render(
$this->l11ns,
@ -98,14 +101,20 @@ echo $this->data['nav']->render(); ?>
);
?>
</div>
<?php endif; ?>
</div>
<?php if (!$isNew) : ?>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Defaults'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="portlet-head">
<?= $this->getHtml('Defaults'); ?>
<i class="g-icon download btn end-xs">download</i>
<a class="button end-xs save" href="<?= UriFactory::build('{/base}/' . $path . '/attribute/value/create?type=' . $this->attribute->id); ?>"><?= $this->getHtml('New', '0', '0'); ?></a>
</div>
<div class="slider">
<table id="iAttributeValueList" class="default sticky">
<thead>
@ -166,5 +175,6 @@ echo $this->data['nav']->render(); ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>

View File

@ -32,20 +32,25 @@ echo $this->data['nav']->render(); ?>
</div>
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name', 'Attribute', 'Backend'); ?></label>
<input id="iName" type="text" value="<?= $this->printHtml($this->attribute->getL11n()); ?>" disabled>
<label for="iLocalization"><?= $this->getHtml('Localization', 'Attribute', 'Backend'); ?></label>
<input id="iLocalization" type="text" name="content" value="<?= $this->printHtml($this->attribute->getL11n()); ?>"<?= $isNew ? '' : ' disabled'; ?>>
</div>
<div class="form-group">
<label for="iValue"><?= $this->getHtml('Value', 'Attribute', 'Backend'); ?></label>
<?php if ($this->attribute->valueInt !== null) : ?>
<?php if ($this->type->datatype === AttributeValueType::_INT || $this->type->datatype === AttributeValueType::_FLOAT_INT) : ?>
<input id="iValue" type="number" name="value" value="<?= $this->attribute->valueInt; ?>">
<?php elseif ($this->attribute->valueDec !== null) : ?>
<?php elseif ($this->type->datatype === AttributeValueType::_FLOAT) : ?>
<input id="iValue" type="number" name="value" step="any" value="<?= $this->attribute->valueDec; ?>">
<?php elseif ($this->attribute->valueStr !== null) : ?>
<?php elseif ($this->type->datatype === AttributeValueType::_STRING) : ?>
<input id="iValue" type="text" name="value" value="<?= $this->printHtml($this->attribute->valueStr); ?>">
<?php elseif ($this->attribute->valueDat !== null) : ?>
<?php elseif ($this->type->datatype === AttributeValueType::_DATETIME) : ?>
<input id="iValue" type="text" name="value" value="<?= $this->attribute->valueDat->format('Y-m-d\TH:i'); ?>">
<?php elseif ($this->type->datatype === AttributeValueType::_BOOL) : ?>
<label class="checkbox" for="iValue">
<input type="checkbox" id="iValue" name="value" value="1"<?= $this->attribute->valueInt > 0 ? ' checked' : ''; ?>>
<span class="checkmark"></span>
</label>
<?php endif; ?>
</div>
</div>
@ -61,6 +66,7 @@ echo $this->data['nav']->render(); ?>
</div>
</div>
<?php if (!$isNew) : ?>
<div class="row">
<?= $this->l11nView->render(
$this->l11ns,
@ -68,4 +74,5 @@ echo $this->data['nav']->render(); ?>
'{/api}' . $this->path . '/attribute/value/l11n?csrf={$CSRF}'
);
?>
</div>
</div>
<?php endif; ?>

View File

@ -27,11 +27,12 @@ return ['Attribute' => [
'Type' => 'Type',
'Unit' => 'Unit',
'Value' => 'Value',
'_INT' => 'INTEGER',
'_STRING' => 'STRING',
'_FLOAT' => 'FLOAT',
'_FLOAT_INT' => 'FLOAT_INT',
'_DATETIME' => 'DATETIME',
'_INT' => 'INTEGER',
'_STRING' => 'STRING',
'_FLOAT' => 'FLOAT',
'_FLOAT_INT' => 'FLOAT_INT',
'_DATETIME' => 'DATETIME',
'_BOOL' => 'BOOL',
'Defaults' => 'Standards',
'Defaults' => 'Standards',
'Localization' => 'Lokalisierung',
]];

View File

@ -27,11 +27,12 @@ return ['Attribute' => [
'Type' => 'Type',
'Unit' => 'Unit',
'Value' => 'Value',
'_INT' => 'INTEGER',
'_FLOAT_INT' => 'FLOAT_INT',
'_STRING' => 'STRING',
'_FLOAT' => 'FLOAT',
'_DATETIME' => 'DATETIME',
'_INT' => 'INTEGER',
'_FLOAT_INT' => 'FLOAT_INT',
'_STRING' => 'STRING',
'_FLOAT' => 'FLOAT',
'_DATETIME' => 'DATETIME',
'_BOOL' => 'BOOL',
'Defaults' => 'Defaults',
'Defaults' => 'Defaults',
'Localization' => 'Localization',
]];

View File

@ -76,11 +76,11 @@ final class AttributeValueTest extends \PHPUnit\Framework\TestCase
$value = new AttributeValue();
self::assertEquals(
[
'id' => 0,
'valueInt' => null,
'valueStr' => null,
'valueDec' => null,
'valueDat' => null,
'id' => 0,
'valueInt' => null,
'valueStr' => null,
'valueDec' => null,
'valueDat' => null,
'isDefault' => false,
],
$value->toArray()
@ -92,11 +92,11 @@ final class AttributeValueTest extends \PHPUnit\Framework\TestCase
$value = new AttributeValue();
self::assertEquals(
[
'id' => 0,
'valueInt' => null,
'valueStr' => null,
'valueDec' => null,
'valueDat' => null,
'id' => 0,
'valueInt' => null,
'valueStr' => null,
'valueDec' => null,
'valueDat' => null,
'isDefault' => false,
],
$value->jsonSerialize()