redirect fixes

This commit is contained in:
Dennis Eichhorn 2024-04-26 22:02:22 +00:00
parent 44014a8574
commit ae04c3f295
7 changed files with 38 additions and 141 deletions

View File

@ -511,7 +511,7 @@ final class ApiController extends Controller
$newRequest->header->account = $request->header->account;
$newRequest->setData('name', 'pos:' . \strtr(\strtolower($position->name), ' ', '_'));
$newRequest->setData('status', GroupStatus::ACTIVE);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, clone $response, $data);
}
$this->createStandardCreateResponse($request, $response, $position);
@ -686,7 +686,7 @@ final class ApiController extends Controller
$newRequest->header->account = $request->header->account;
$newRequest->setData('name', 'dep:' . \strtolower($department->name));
$newRequest->setData('status', GroupStatus::ACTIVE);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, clone $response, $data);
}
$this->createStandardCreateResponse($request, $response, $department);

View File

@ -299,8 +299,9 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Organization/Theme/Backend/department-create');
$view->setTemplate('/Modules/Organization/Theme/Backend/department-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response);
$view->data['unit'] = $this->app->unitId;
$selectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app->l11nManager, $request, $response);
$view->data['department-selector'] = $selectorView;
@ -396,7 +397,7 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Organization/Theme/Backend/position-create');
$view->setTemplate('/Modules/Organization/Theme/Backend/position-view');
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004705001, $request, $response);
$selectorView = new \Modules\Organization\Theme\Backend\Components\PositionTagSelector\PositionTagSelectorView($this->app->l11nManager, $request, $response);

View File

@ -1,59 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Organization
* @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="fDepartmentCreate"
method="PUT"
action="<?= UriFactory::build('{/api}{/rootPath}{/lang}/api/organization/department?csrf={$CSRF}'); ?>"
autocomplete="off">
<div class="portlet-head"><?= $this->getHtml('Department'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label>
<input type="text" name="name" id="iName" required>
</div>
<div class="form-group">
<label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<?= $this->getData('department-selector')->render('iParent', 'parent', false); ?>
</div>
<div class="form-group">
<label for="iUnit"><?= $this->getHtml('Unit'); ?></label>
<?= $this->getData('unit-selector')->render('iUnit', 'unit', false); ?>
</div>
<div class="form-group">
<label for="iDescription"><?= $this->getHtml('Description'); ?></label>
<?= $this->getData('editor')->render('department-editor'); ?>
</div>
<?= $this->getData('editor')->getData('text')->render('department-editor', 'description', 'fDepartmentCreate'); ?>
</div>
<div class="portlet-foot">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</div>
</div>
</div>
<?= $this->getData('department-selector')->getData('department-selector-popup')->render(); ?>

View File

@ -12,20 +12,24 @@
*/
declare(strict_types=1);
use Modules\Organization\Models\NullDepartment;
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Mouldes\Organization\Models $department;
*/
$department = $this->data['department'];
$department = $this->data['department'] ?? new NullDepartment();
$isNew = $department->id === 0;
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<form id="iDepartment" action="<?= UriFactory::build('{/api}organization/department?{?}&csrf={$CSRF}'); ?>" method="POST">
<form id="iDepartment"
method="<?= $isNew ? 'PUT' : 'POST'; ?>"
action="<?= UriFactory::build('{/api}organization/department?{?}&csrf={$CSRF}'); ?>"
<?= $isNew ? 'data-redirect="' . UriFactory::build('{/base}/organization/department/view') . '?id={/0/response/id}"' : ''; ?>>
<div class="portlet-head"><?= $this->getHtml('Department'); ?></div>
<div class="portlet-body">
<div class="form-group">
@ -64,7 +68,12 @@ echo $this->data['nav']->render(); ?>
); ?>
</div>
<div class="portlet-foot">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<input type="hidden" name="unit" value="<?= $this->data['unit'] ?? 1; ?>">
<?php if ($isNew) : ?>
<input id="iCreateSubmit" type="Submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
<?php else : ?>
<input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<?php endif; ?>
</div>
</form>
</div>

View File

@ -1,67 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Organization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Organization\Models\Status;
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="fPositionCreate"
method="PUT"
action="<?= UriFactory::build('{/api}{/rootPath}{/lang}/api/organization/position?csrf={$CSRF}'); ?>"
autocomplete="off">
<div class="portlet-head"><?= $this->getHtml('Position'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label>
<input type="text" name="name" id="iName" required>
</div>
<div class="form-group">
<label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<?= $this->getData('position-selector')->render('iParent', 'parent', false); ?>
</div>
<div class="form-group">
<label for="iDepartment"><?= $this->getHtml('Department'); ?></label>
<?= $this->getData('department-selector')->render('iDepartment', 'department', false); ?>
</div>
<div class="form-group">
<label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<select name="status" id="iStatus">
<option value="<?= Status::ACTIVE; ?>"><?= $this->getHtml('Active'); ?>
<option value="<?= Status::INACTIVE; ?>"><?= $this->getHtml('Inactive'); ?>
</select>
</div>
<div class="form-group">
<?= $this->getData('editor')->render('position-editor'); ?>
</div>
<?= $this->getData('editor')->getData('text')->render('position-editor', 'description', 'fPositionCreate'); ?>
</div>
<div class="portlet-foot">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</div>
</div>
</div>
<?= $this->getData('position-selector')->getData('position-selector-popup')->render(); ?>

View File

@ -12,20 +12,26 @@
*/
declare(strict_types=1);
use Modules\Organization\Models\Status;
use Modules\Organization\Models\NullPosition;
use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\Organization\Models\Position;
*/
$position = $this->data['position'];
$position = $this->data['position'] ?? new NullPosition();
$isNew = $position->id === 0;
echo $this->data['nav']->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<form id="iPosition" action="<?= UriFactory::build('{/api}organization/position?{?}&csrf={$CSRF}'); ?>" method="POST">
<form id="iPosition"
method="<?= $isNew ? 'PUT' : 'POST'; ?>"
action="<?= UriFactory::build('{/api}organization/position?{?}&csrf={$CSRF}'); ?>"
<?= $isNew ? 'data-redirect="' . UriFactory::build('{/base}/organization/position/view') . '?id={/0/response/id}"' : ''; ?>>
<div class="portlet-head"><?= $this->getHtml('Position'); ?></div>
<div class="portlet-body">
<div class="form-group">
@ -46,8 +52,8 @@ echo $this->data['nav']->render(); ?>
<div class="form-group">
<label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<select name="status" id="iStatus">
<option><?= $this->getHtml('Active'); ?>
<option><?= $this->getHtml('Inactive'); ?>
<option value="<?= Status::ACTIVE; ?>"<?= $position->status === Status::ACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?>
<option value="<?= Status::INACTIVE; ?>"<?= $position->status === Status::INACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?>
</select>
</div>
@ -64,7 +70,11 @@ echo $this->data['nav']->render(); ?>
); ?>
</div>
<div class="portlet-foot">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<?php if ($isNew) : ?>
<input id="iCreateSubmit" type="Submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
<?php else : ?>
<input id="iSaveSubmit" type="Submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
<?php endif; ?>
</div>
</form>
</div>

View File

@ -23,7 +23,10 @@ $countries = ISO3166NameEnum::getConstants();
/** @var \phpOMS\Views\View $this */
echo $this->data['nav']->render(); ?>
<form id="fUnitCreate" method="put" action="<?= UriFactory::build('{/api}organization/unit?csrf={$CSRF}'); ?>">
<form id="fUnitCreate"
method="put"
action="<?= UriFactory::build('{/api}organization/unit?csrf={$CSRF}'); ?>"
data-redirect="<?= UriFactory::build('{/base}/organization/unit/view'); ?>?id={/0/response/id}">
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">