mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-17 07:08:39 +00:00
use tags
This commit is contained in:
parent
8fe0a3b1ca
commit
4d906efa7c
|
|
@ -72,6 +72,32 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"helper_template_tag": {
|
||||
"name": "helper_template_tag",
|
||||
"fields": {
|
||||
"helper_template_tag_id": {
|
||||
"name": "helper_template_tag_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"helper_template_tag_dst": {
|
||||
"name": "helper_template_tag_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "helper_template",
|
||||
"foreignKey": "helper_template_id"
|
||||
},
|
||||
"helper_template_tag_src": {
|
||||
"name": "helper_template_tag_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "tag",
|
||||
"foreignKey": "tag_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"helper_report": {
|
||||
"name": "helper_report",
|
||||
"fields": {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ use phpOMS\System\MimeType;
|
|||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||
use phpOMS\Utils\StringUtils;
|
||||
use phpOMS\Views\View;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use Modules\Tag\Models\NullTag;
|
||||
|
||||
/**
|
||||
* Helper controller class.
|
||||
|
|
@ -320,6 +322,22 @@ final class ApiController extends Controller
|
|||
$helperTemplate->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
|
||||
$helperTemplate->setDatatype((int) ($request->getData('datatype') ?? TemplateDataType::OTHER));
|
||||
|
||||
if (!empty($tags = $request->getDataJson('tags'))) {
|
||||
foreach ($tags as $tag) {
|
||||
if (!isset($tag['id'])) {
|
||||
$request->setData('title', $tag['title'], true);
|
||||
$request->setData('color', $tag['color'], true);
|
||||
$request->setData('language', $tag['language'], true);
|
||||
|
||||
$internalResponse = new HttpResponse();
|
||||
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
|
||||
$helperTemplate->addTag($internalResponse->get($request->getUri()->__toString())['response']);
|
||||
} else {
|
||||
$helperTemplate->addTag(new NullTag((int) $tag['id']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $helperTemplate;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/Helper/Theme/Backend/helper-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002701001, $request, $response));
|
||||
|
||||
$reports = TemplateMapper::getNewest(25);
|
||||
$reports = TemplateMapper::withConditional('language', $response->getHeader()->getL11n()->getLanguage())::getNewest(25);
|
||||
$view->addData('reports', $reports);
|
||||
|
||||
return $view;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use Modules\Media\Models\Collection;
|
|||
use Modules\Media\Models\NullCollection;
|
||||
use Modules\Organization\Models\NullUnit;
|
||||
use Modules\Organization\Models\Unit;
|
||||
use Modules\Tag\Models\Tag;
|
||||
|
||||
/**
|
||||
* Template model.
|
||||
|
|
@ -135,6 +136,14 @@ class Template implements \JsonSerializable
|
|||
*/
|
||||
private array $reports = [];
|
||||
|
||||
/**
|
||||
* Tags.
|
||||
*
|
||||
* @var Tag[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $tags = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
|
@ -464,6 +473,32 @@ class Template implements \JsonSerializable
|
|||
return $this->isStandalone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTags() : array
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add tag
|
||||
*
|
||||
* @param Tag $tag Tag
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addTag(Tag $tag) : void
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\AccountMapper;
|
|||
use Modules\Media\Models\CollectionMapper;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
|
||||
/**
|
||||
* Report mapper class.
|
||||
|
|
@ -93,6 +94,12 @@ final class TemplateMapper extends DataMapperAbstract
|
|||
'external' => 'helper_report_template',
|
||||
'self' => null,
|
||||
],
|
||||
'tags' => [
|
||||
'mapper' => TagMapper::class,
|
||||
'table' => 'helper_template_tag',
|
||||
'self' => 'helper_template_tag_src',
|
||||
'external' => 'helper_template_tag_dst',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ return ['Helper' => [
|
|||
'Sources' => 'Quelle',
|
||||
'Standalone' => 'Eigenständig',
|
||||
'Storage' => 'Speicher',
|
||||
'Tag' => 'Tag',
|
||||
'Template' => 'Template',
|
||||
'Title' => 'Titel',
|
||||
'Type' => 'Typ',
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ return ['Helper' => [
|
|||
'Sources' => 'Sources',
|
||||
'Standalone' => 'Standalone',
|
||||
'Storage' => 'Storage',
|
||||
'Tag' => 'Tag',
|
||||
'Template' => 'Template',
|
||||
'Title' => 'Title',
|
||||
'Type' => 'Type',
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ echo $this->getData('nav')->render(); ?>
|
|||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||
<td class="wf-100"><?= $this->getHtml('Name') ?>
|
||||
<td><?= $this->getHtml('Tag'); ?>
|
||||
<td><?= $this->getHtml('Creator') ?>
|
||||
<td><?= $this->getHtml('Updated') ?>
|
||||
<tbody>
|
||||
|
|
@ -39,8 +39,11 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php foreach ($templates as $key => $template) :
|
||||
$url = \phpOMS\Uri\UriFactory::build('{/prefix}helper/report/view?{?}&id=' . $template->getId()); ?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->getId()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->getName()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Tag') ?>">
|
||||
<?php $tags = $template->getTags(); foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->getColor()); ?>"><?= $this->printHtml($tag->getTitle()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
<td data-label="<?= $this->getHtml('Creator') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->getCreatedBy()->getName1()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Updated') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->getCreatedAt()->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user