From d84e23a06ea210cd0216c4d6ca251f568da747a2 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 16 Aug 2022 19:11:58 +0200 Subject: [PATCH] add css version --- Controller/ApiController.php | 41 +++++++------------ Controller/BackendController.php | 2 +- .../department-selector.tpl.php | 2 +- .../position-selector.tpl.php | 2 +- .../UnitTagSelector/unit-selector.tpl.php | 6 +-- Theme/Backend/department-create.tpl.php | 7 +++- Theme/Backend/position-create.tpl.php | 7 +++- 7 files changed, 31 insertions(+), 36 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 8c0fb93..007bfcf 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -110,8 +110,8 @@ final class ApiController extends Controller public function apiUnitSet(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { /** @var Unit $old */ - $old = clone UnitMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $new = $this->updateUnitFromRequest($request); + $old = UnitMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $new = $this->updateUnitFromRequest($request, clone $old); $this->updateModel($request->header->account, $old, $new, UnitMapper::class, 'unit', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully updated.', $new); } @@ -125,10 +125,8 @@ final class ApiController extends Controller * * @since 1.0.0 */ - private function updateUnitFromRequest(RequestAbstract $request) : Unit + private function updateUnitFromRequest(RequestAbstract $request, Unit $unit) : Unit { - /** @var Unit $unit */ - $unit = UnitMapper::get()->where('id', (int) $request->getData('id'))->execute(); $unit->name = (string) ($request->getData('name') ?? $unit->name); $unit->descriptionRaw = (string) ($request->getData('description') ?? $unit->descriptionRaw); $unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw)); @@ -213,8 +211,7 @@ final class ApiController extends Controller $unit->descriptionRaw = (string) ($request->getData('description') ?? ''); $unit->description = Markdown::parse((string) ($request->getData('description') ?? '')); - $parent = (int) $request->getData('parent'); - $unit->parent = new NullUnit($parent); + $unit->parent = new NullUnit((int) $request->getData('parent')); $unit->setStatus((int) $request->getData('status')); return $unit; @@ -350,8 +347,8 @@ final class ApiController extends Controller public function apiPositionSet(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { /** @var Position $old */ - $old = clone PositionMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $new = $this->updatePositionFromRequest($request); + $old = PositionMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $new = $this->updatePositionFromRequest($request, clone $old); $this->updateModel($request->header->account, $old, $new, PositionMapper::class, 'position', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully updated.', $new); } @@ -365,10 +362,8 @@ final class ApiController extends Controller * * @since 1.0.0 */ - private function updatePositionFromRequest(RequestAbstract $request) : Position + private function updatePositionFromRequest(RequestAbstract $request, Position $position) : Position { - /** @var Position $position */ - $position = PositionMapper::get()->where('id', (int) $request->getData('id'))->execute(); $position->name = (string) ($request->getData('name') ?? $position->name); $position->descriptionRaw = (string) ($request->getData('description') ?? $position->descriptionRaw); $position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw)); @@ -435,12 +430,8 @@ final class ApiController extends Controller $position->setStatus((int) $request->getData('status')); $position->descriptionRaw = (string) ($request->getData('description') ?? ''); $position->description = Markdown::parse((string) ($request->getData('description') ?? '')); - - $parent = (int) $request->getData('parent'); - $position->parent = new NullPosition($parent); - - $department = (int) $request->getData('department'); - $position->department = new NullDepartment($department); + $position->parent = new NullPosition((int) $request->getData('parent')); + $position->department = new NullDepartment((int) $request->getData('department')); return $position; } @@ -508,8 +499,8 @@ final class ApiController extends Controller public function apiDepartmentSet(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { /** @var Department $old */ - $old = clone DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $new = $this->updateDepartmentFromRequest($request); + $old = DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $new = $this->updateDepartmentFromRequest($request, clone $old); $this->updateModel($request->header->account, $old, $new, DepartmentMapper::class, 'department', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully updated.', $new); } @@ -523,10 +514,8 @@ final class ApiController extends Controller * * @since 1.0.0 */ - private function updateDepartmentFromRequest(RequestAbstract $request) : Department + private function updateDepartmentFromRequest(RequestAbstract $request, Department $department) : Department { - /** @var Department $department */ - $department = DepartmentMapper::get()->where('id', (int) $request->getData('id'))->execute(); $department->name = (string) ($request->getData('name') ?? $department->name); $department->descriptionRaw = (string) ($request->getData('description') ?? $department->descriptionRaw); $department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw)); @@ -578,7 +567,8 @@ final class ApiController extends Controller public function apiDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateDepartmentCreate($request))) { - $response->set('department_create', new FormValidation($val)); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, '', 'Invalid form data.', new FormValidation($val)); + $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->header->status = RequestStatusCode::R_400; return; @@ -613,8 +603,7 @@ final class ApiController extends Controller $department->name = (string) $request->getData('name'); $department->setStatus((int) $request->getData('status')); - $parent = (int) $request->getData('parent'); - $department->parent = new NullDepartment($parent); + $department->parent = new NullDepartment((int) $request->getData('parent')); $department->unit = new NullUnit((int) ($request->getData('unit') ?? 1)); $department->descriptionRaw = (string) ($request->getData('description') ?? ''); $department->description = Markdown::parse((string) ($request->getData('description') ?? '')); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 7d3e2ab..2c9a63c 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -115,7 +115,7 @@ final class BackendController extends Controller { $response->get('Content') ->getData('head') - ->addAsset(AssetType::CSS, 'Modules/Organization/Theme/Backend/css/styles.css'); + ->addAsset(AssetType::CSS, 'Modules/Organization/Theme/Backend/css/styles.css?v=1.0.0'); $view = new View($this->app->l11nManager, $request, $response); diff --git a/Theme/Backend/Components/DepartmentTagSelector/department-selector.tpl.php b/Theme/Backend/Components/DepartmentTagSelector/department-selector.tpl.php index 7f9e208..ebc2be3 100755 --- a/Theme/Backend/Components/DepartmentTagSelector/department-selector.tpl.php +++ b/Theme/Backend/Components/DepartmentTagSelector/department-selector.tpl.php @@ -13,7 +13,7 @@ } ]' formaction="">
- diff --git a/Theme/Backend/Components/PositionTagSelector/position-selector.tpl.php b/Theme/Backend/Components/PositionTagSelector/position-selector.tpl.php index c10f04a..1c49f34 100755 --- a/Theme/Backend/Components/PositionTagSelector/position-selector.tpl.php +++ b/Theme/Backend/Components/PositionTagSelector/position-selector.tpl.php @@ -13,7 +13,7 @@ } ]' formaction="">
- diff --git a/Theme/Backend/Components/UnitTagSelector/unit-selector.tpl.php b/Theme/Backend/Components/UnitTagSelector/unit-selector.tpl.php index ded1416..4c5e9be 100755 --- a/Theme/Backend/Components/UnitTagSelector/unit-selector.tpl.php +++ b/Theme/Backend/Components/UnitTagSelector/unit-selector.tpl.php @@ -5,15 +5,15 @@ { "key": 1, "listener": "click", "action": [ {"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "getId(); ?>"}, - {"key": 2, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, + {"key": 2, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, {"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name"}, "position": -1}, - {"key": 4, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, + {"key": 4, "type": "message.request", "uri": "", "method": "GET", "request_type": "json"}, {"key": 5, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name"}, "position": -1} ] } ]' formaction="">
- diff --git a/Theme/Backend/department-create.tpl.php b/Theme/Backend/department-create.tpl.php index 43d4b00..647a4dc 100755 --- a/Theme/Backend/department-create.tpl.php +++ b/Theme/Backend/department-create.tpl.php @@ -20,12 +20,15 @@ echo $this->getData('nav')->render(); ?>
-
+
getHtml('Department'); ?>
-
+
getData('department-selector')->render('iParent', 'parent', false); ?>
diff --git a/Theme/Backend/position-create.tpl.php b/Theme/Backend/position-create.tpl.php index 094b696..b62e1c6 100755 --- a/Theme/Backend/position-create.tpl.php +++ b/Theme/Backend/position-create.tpl.php @@ -21,12 +21,15 @@ echo $this->getData('nav')->render(); ?>
- +
getHtml('Position'); ?>
-
+
getData('position-selector')->render('iParent', 'parent', false); ?>