template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:48 +00:00
parent 2c4dad3cf5
commit 14f71c1af9
5 changed files with 23 additions and 59 deletions

View File

@ -314,7 +314,7 @@ final class ApiController extends Controller
->with('title')
->where('title/language', $request->header->l11n->language)
->where('title/content', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute();
->executeGetArray();
$response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set($request->uri->__toString(), \array_values($tags));

View File

@ -48,7 +48,7 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Tag/Theme/Backend/tag-create');
$view->setTemplate('/Modules/Tag/Theme/Backend/tag-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007501001, $request, $response);
return $view;
@ -79,14 +79,14 @@ final class BackendController extends Controller
->limit(25);
if ($request->getData('ptype') === 'p') {
$view->data['tags'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '<')
->execute();
$view->data['tags'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '<')
->executeGetArray();
} elseif ($request->getData('ptype') === 'n') {
$view->data['tags'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '>')
->execute();
$view->data['tags'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '>')
->executeGetArray();
} else {
$view->data['tags'] = $mapper->where('id', 0, '>')
->execute();
->executeGetArray();
}
return $view;
@ -123,7 +123,7 @@ final class BackendController extends Controller
/** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */
$l11nValues = TagL11nMapper::getAll()
->where('ref', $tag->id)
->execute();
->executeGetArray();
$view->data['l11nValues'] = $l11nValues;

View File

@ -1,46 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Editor
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<form id="fUnitCreate" method="put" action="<?= UriFactory::build('{/api}tag?csrf={$CSRF}'); ?>">
<div class="portlet-head"><?= $this->getHtml('Tag'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iTitle"><?= $this->getHtml('Title'); ?></label>
<input type="text" name="title" id="iTitle" required>
</div>
<div class="form-group">
<label for="iColor"><?= $this->getHtml('Color'); ?></label>
<input type="color" name="color" id="iColor"required>
</div>
<div class="form-group">
<label for="iIcon"><?= $this->getHtml('Icon'); ?></label>
<input type="text" name="icon" id="iIcon" value="<?= $this->printHtml($tag->icon); ?>">
</div>
</div>
<div class="portlet-foot">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</div>
</div>
</div>

View File

@ -18,8 +18,8 @@ use phpOMS\Uri\UriFactory;
* @var \phpOMS\Views\View $this
* @var \Modules\Tag\Models\Tag[] $tags
*/
$previous = empty($tags) ? '{/base}/tag/list' : '{/base}/tag/list?{?}&id=' . \reset($tags)->id . '&ptype=p';
$next = empty($tags) ? '{/base}/tag/list' : '{/base}/tag/list?{?}&id=' . \end($tags)->id . '&ptype=n';
$previous = empty($tags) ? '{/base}/tag/list' : '{/base}/tag/list?{?}&offset=' . \reset($tags)->id . '&ptype=p';
$next = empty($tags) ? '{/base}/tag/list' : '{/base}/tag/list?{?}&offset=' . \end($tags)->id . '&ptype=n';
echo $this->data['nav']->render(); ?>
<div class="row">

View File

@ -12,17 +12,20 @@
*/
declare(strict_types=1);
use Modules\Tag\Models\NullTag;
use phpOMS\Uri\UriFactory;
/** @var \Modules\Tag\Models\Tag */
$tag = $this->data['tag'];
$tag = $this->data['tag'] ?? new NullTag();
$isNew = $tag->id === 0;
/** @var \phpOMS\Views\View $this */
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<form id="tagForm" method="POST" action="<?= UriFactory::build('{/api}tag?csrf={$CSRF}'); ?>"
<form id="tagForm" method="<?= $isNew ? 'PUT' : 'POST'; ?>" action="<?= UriFactory::build('{/api}tag?csrf={$CSRF}'); ?>"
data-ui-container="#tagTable tbody"
data-add-form="tagForm"
data-add-tpl="#tagTable tbody .oms-add-tpl-tag">
@ -33,6 +36,11 @@ echo $this->data['nav']->render(); ?>
<input type="color" name="color" id="iColor" value="<?= $this->printHtml(\substr($tag->color, 0, 7)); ?>" required>
</div>
<div class="form-group">
<label for="iTitle"><?= $this->getHtml('Title'); ?></label>
<input type="text" id="iTitle" name="title" value="<?= $this->printHtml($tag->getL11n()); ?>"<?= $isNew ? ' required' : ' disabled'; ?>>
</div>
<div class="form-group">
<label for="iIcon"><?= $this->getHtml('Icon'); ?></label>
<input type="text" name="icon" id="iIcon" value="<?= $this->printHtml($tag->icon); ?>">
@ -48,6 +56,7 @@ echo $this->data['nav']->render(); ?>
</div>
</div>
<?php if (!$isNew) : ?>
<div class="row">
<?= $this->data['l11nView']->render(
$this->data['l11nValues'],
@ -55,4 +64,5 @@ echo $this->data['nav']->render(); ?>
'{/api}tag/l11n?csrf={$CSRF}'
);
?>
</div>
</div>
<?php endif; ?>