mirror of
https://github.com/Karaka-Management/oms-ItemManagement.git
synced 2026-02-15 11:48:40 +00:00
continue impl
This commit is contained in:
parent
abd87cc89a
commit
e553d1b185
|
|
@ -49,4 +49,24 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'^.*/item/l11n.*$' => [
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\ItemManagement\Controller\ApiController:apiItemL11nTypeCreate',
|
||||||
|
'verb' => RouteVerb::PUT,
|
||||||
|
'permission' => [
|
||||||
|
'module' => ApiController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::SALES_ITEM,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'dest' => '\Modules\ItemManagement\Controller\ApiController:apiItemL11nTypeUpdate',
|
||||||
|
'verb' => RouteVerb::SET,
|
||||||
|
'permission' => [
|
||||||
|
'module' => ApiController::NAME,
|
||||||
|
'type' => PermissionType::READ,
|
||||||
|
'state' => PermissionCategory::SALES_ITEM,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ use phpOMS\Localization\BaseStringL11n;
|
||||||
use phpOMS\Localization\BaseStringL11nType;
|
use phpOMS\Localization\BaseStringL11nType;
|
||||||
use phpOMS\Localization\ISO4217CharEnum;
|
use phpOMS\Localization\ISO4217CharEnum;
|
||||||
use phpOMS\Localization\ISO639x1Enum;
|
use phpOMS\Localization\ISO639x1Enum;
|
||||||
|
use phpOMS\Localization\NullBaseStringL11n;
|
||||||
use phpOMS\Localization\NullBaseStringL11nType;
|
use phpOMS\Localization\NullBaseStringL11nType;
|
||||||
use phpOMS\Message\Http\HttpRequest;
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\Http\HttpResponse;
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
|
|
@ -616,6 +617,75 @@ final class ApiController extends Controller
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api method to create item attribute
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function apiItemL11nUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||||
|
{
|
||||||
|
if (!empty($val = $this->validateItemL11nUpdate($request))) {
|
||||||
|
$response->data['l11n_update'] = new FormValidation($val);
|
||||||
|
$response->header->status = RequestStatusCode::R_400;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$old = ItemL11nMapper::get()
|
||||||
|
->where('id', (int) $request->getData('id'))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$new = $this->updateItemL11nFromRequest($request, clone $old);
|
||||||
|
|
||||||
|
$this->updateModel($request->header->account, $old, $new, ItemL11nMapper::class, 'l11n', $request->getOrigin());
|
||||||
|
$this->createStandardUpdateResponse($request, $response, $new);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create item l11n from request.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return BaseStringL11n
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private function updateItemL11nFromRequest(RequestAbstract $request, BaseStringL11n $l11n) : BaseStringL11n
|
||||||
|
{
|
||||||
|
$l11n->content = $request->getDataString('description');
|
||||||
|
|
||||||
|
return $l11n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate item attribute create request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private function validateItemL11nUpdate(RequestAbstract $request) : array
|
||||||
|
{
|
||||||
|
$val = [];
|
||||||
|
if (($val['id'] = !$request->hasData('id'))
|
||||||
|
|| ($val['value'] = !$request->hasData('value'))
|
||||||
|
) {
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Api method to create item attribute type
|
* Api method to create item attribute type
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -398,6 +398,7 @@ final class BackendController extends Controller
|
||||||
$view->data['itemImage'] = $itemImage;
|
$view->data['itemImage'] = $itemImage;
|
||||||
|
|
||||||
/** @var \Model\Setting $settings */
|
/** @var \Model\Setting $settings */
|
||||||
|
// @todo: this one should already be loaded in the backend application no?????????
|
||||||
$settings = $this->app->appSettings->get(null, [
|
$settings = $this->app->appSettings->get(null, [
|
||||||
SettingsEnum::DEFAULT_LOCALIZATION,
|
SettingsEnum::DEFAULT_LOCALIZATION,
|
||||||
]);
|
]);
|
||||||
|
|
@ -405,6 +406,8 @@ final class BackendController extends Controller
|
||||||
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
||||||
$view->data['attributeView']->data['defaultlocalization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute();
|
$view->data['attributeView']->data['defaultlocalization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute();
|
||||||
|
|
||||||
|
$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);
|
||||||
|
|
||||||
$l11nTypes = ItemL11nTypeMapper::getAll()
|
$l11nTypes = ItemL11nTypeMapper::getAll()
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ $regionSales = $this->data['regionSales'] ?? [];
|
||||||
$countrySales = $this->data['countrySales'] ?? [];
|
$countrySales = $this->data['countrySales'] ?? [];
|
||||||
$monthlySalesCosts = $this->data['monthlySalesCosts'] ?? [];
|
$monthlySalesCosts = $this->data['monthlySalesCosts'] ?? [];
|
||||||
$attributeView = $this->data['attributeView'];
|
$attributeView = $this->data['attributeView'];
|
||||||
|
$l11nView = $this->data['l11nView'];
|
||||||
|
|
||||||
$languages = ISO639Enum::getConstants();
|
$languages = ISO639Enum::getConstants();
|
||||||
|
|
||||||
|
|
@ -470,114 +471,12 @@ echo $this->data['nav']->render();
|
||||||
<input type="radio" id="c-tab-2" name="tabular-2" checked>
|
<input type="radio" id="c-tab-2" name="tabular-2" checked>
|
||||||
<div class="tab">
|
<div class="tab">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-md-6">
|
<?= $l11nView->render(
|
||||||
<section class="portlet">
|
$this->data['l11nValues'],
|
||||||
<form id="localizationForm" action="<?= UriFactory::build('{/api}itemmgmt/item'); ?>" method="post"
|
$this->data['l11nTypes'] ?? [],
|
||||||
data-ui-container="#localizationTable tbody"
|
'{/api}item/l11n'
|
||||||
data-add-form="localizationForm"
|
);
|
||||||
data-add-tpl="#localizationTable tbody .oms-add-tpl-localization">
|
?>
|
||||||
<div class="portlet-head"><?= $this->getHtml('Localization'); ?></div>
|
|
||||||
<div class="portlet-body">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="iLocaliztionId"><?= $this->getHtml('ID'); ?></label>
|
|
||||||
<input type="text" id="iLocaliztionId" name="id" data-tpl-text="/id" data-tpl-value="/id" disabled>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label for="iLocalizationLanguage"><?= $this->getHtml('Language'); ?></label>
|
|
||||||
<select id="iLocalizationLanguage" name="language" data-tpl-text="/language" data-tpl-value="/language">
|
|
||||||
<?php foreach ($languages as $code => $language) : $code = ISO639x1Enum::getByName($code); ?>
|
|
||||||
<option value="<?= $this->printHtml($code); ?>" <?= $this->printHtml(\strtolower($code) === $l11n->language ? ' selected' : ''); ?>><?= $this->printHtml($language); ?>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="iLocalizationType"><?= $this->getHtml('Type'); ?></label>
|
|
||||||
<select id="iLocalizationType" name="type" data-tpl-text="/type" data-tpl-value="/type">
|
|
||||||
<?php
|
|
||||||
$types = $this->data['l11nTypes'] ?? [];
|
|
||||||
foreach ($types as $type) : ?>
|
|
||||||
<option value="<?= $type->id; ?>"><?= $this->printHtml($type->title); ?>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="iLocalizationText"><?= $this->getHtml('Text'); ?></label>
|
|
||||||
<pre class="textarea contenteditable" id="iLocalizationText" data-name="content" data-tpl-value="/l11n" contenteditable="true"></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="portlet-foot">
|
|
||||||
<input id="bLocalizationAdd" formmethod="put" type="submit" class="add-form" value="<?= $this->getHtml('Add', '0', '0'); ?>">
|
|
||||||
<input id="bLocalizationSave" formmethod="post" type="submit" class="save-form hidden button save" value="<?= $this->getHtml('Update', '0', '0'); ?>">
|
|
||||||
<input type="submit" class="cancel-form hidden button close" value="<?= $this->getHtml('Cancel', '0', '0'); ?>">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-xs-12 col-md-6">
|
|
||||||
<section class="portlet">
|
|
||||||
<div class="portlet-head"><?= $this->getHtml('Localizations'); ?><i class="lni lni-download download btn end-xs"></i></div>
|
|
||||||
<div class="slider">
|
|
||||||
<table id="localizationTable" class="default sticky fixed-5"
|
|
||||||
data-tag="form"
|
|
||||||
data-ui-element="tr"
|
|
||||||
data-add-tpl=".oms-add-tpl-localization"
|
|
||||||
data-update-form="localizationForm">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
|
||||||
<td><?= $this->getHtml('Name'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
|
||||||
<td><?= $this->getHtml('Language'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
|
||||||
<td class="wf-100"><?= $this->getHtml('Localization'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
|
||||||
<tbody>
|
|
||||||
<template class="oms-add-tpl-attribute">
|
|
||||||
<tr data-id="" draggable="false">
|
|
||||||
<td>
|
|
||||||
<i class="fa fa-cogs btn update-form"></i>
|
|
||||||
<input id="attributeTable-remove-0" type="checkbox" class="hidden">
|
|
||||||
<label for="attributeTable-remove-0" class="checked-visibility-alt"><i class="fa fa-times btn form-action"></i></label>
|
|
||||||
<span class="checked-visibility">
|
|
||||||
<label for="attributeTable-remove-0" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
|
|
||||||
<label for="attributeTable-remove-0" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
|
|
||||||
</span>
|
|
||||||
<td data-tpl-text="/id" data-tpl-value="/id"></td>
|
|
||||||
<td data-tpl-text="/type" data-tpl-value="/type" data-value=""></td>
|
|
||||||
<td data-tpl-text="/language" data-tpl-value="/language"></td>
|
|
||||||
<td data-tpl-text="/l11n" data-tpl-value="/l11n"></td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<?php
|
|
||||||
$c = 0;
|
|
||||||
$itemL11n = $this->data['l11nValues'];
|
|
||||||
foreach ($itemL11n as $value) : ++$c; ?>
|
|
||||||
<tr data-id="<?= $value->id; ?>">
|
|
||||||
<td>
|
|
||||||
<i class="fa fa-cogs btn update-form"></i>
|
|
||||||
<?php if (!$value->type->isRequired) : ?>
|
|
||||||
<input id="localizationTable-remove-<?= $value->id; ?>" type="checkbox" class="hidden">
|
|
||||||
<label for="localizationTable-remove-<?= $value->id; ?>" class="checked-visibility-alt"><i class="fa fa-times btn form-action"></i></label>
|
|
||||||
<span class="checked-visibility">
|
|
||||||
<label for="localizationTable-remove-<?= $value->id; ?>" class="link default"><?= $this->getHtml('Cancel', '0', '0'); ?></label>
|
|
||||||
<label for="localizationTable-remove-<?= $value->id; ?>" class="remove-form link cancel"><?= $this->getHtml('Delete', '0', '0'); ?></label>
|
|
||||||
</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
<td data-tpl-text="/id" data-tpl-value="/id"><?= $value->id; ?>
|
|
||||||
<td data-tpl-text="/type" data-tpl-value="/type" data-value="<?= $value->type->id; ?>"><?= $this->printHtml($value->type->title); ?>
|
|
||||||
<td data-tpl-text="/language" data-tpl-value="/language"><?= $this->printHtml($value->getLanguage()); ?>
|
|
||||||
<td data-tpl-text="/l11n" data-tpl-value="/l11n" data-value="<?= \nl2br($this->printHtml($value->content)); ?>"><?= \nl2br($this->printHtml(\substr($value->content, 0, 100))); ?>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php if ($c === 0) : ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="radio" id="c-tab-3" name="tabular-2" checked>
|
<input type="radio" id="c-tab-3" name="tabular-2" checked>
|
||||||
|
|
@ -588,7 +487,7 @@ echo $this->data['nav']->render();
|
||||||
$this->data['attributeTypes'] ?? [],
|
$this->data['attributeTypes'] ?? [],
|
||||||
$this->data['units'] ?? [],
|
$this->data['units'] ?? [],
|
||||||
'{/api}item/attribute'
|
'{/api}item/attribute'
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user