Started to implement org selectors

This commit is contained in:
Dennis Eichhorn 2018-04-13 22:18:10 +02:00
parent e3944157b3
commit cecdfe6b4d
19 changed files with 751 additions and 12 deletions

View File

@ -148,6 +148,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/unit-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004702001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app, $request, $response);
$view->addData('unit-selector', $selectorView);
$view->addData('unit', UnitMapper::get((int) $request->getData('id')));
return $view;
@ -178,6 +181,9 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/unit-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004702001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app, $request, $response);
$view->addData('unit-selector', $selectorView);
return $view;
}
@ -236,6 +242,12 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/department-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app, $request, $response);
$view->addData('department-selector', $selectorView);
$unitSelectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\UnitTagSelectorView($this->app, $request, $response);
$view->addData('unit-selector', $unitSelectorView);
$view->addData('department', DepartmentMapper::get((int) $request->getData('id')));
return $view;
@ -266,6 +278,12 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/department-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app, $request, $response);
$view->addData('department-selector', $selectorView);
$unitSelectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app, $request, $response);
$view->addData('unit-selector', $unitSelectorView);
return $view;
}
@ -324,6 +342,12 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/position-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\PositionTagSelector\PositionTagSelectorView($this->app, $request, $response);
$view->addData('position-selector', $selectorView);
$departmentSelectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app, $request, $response);
$view->addData('department-selector', $departmentSelectorView);
$view->addData('position', PositionMapper::get((int) $request->getData('id')));
return $view;
@ -354,6 +378,12 @@ class Controller extends ModuleAbstract implements WebInterface
$view->setTemplate('/Modules/Organization/Theme/Backend/position-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response));
$selectorView = new \Modules\Organization\Theme\Backend\Components\PositionTagSelector\PositionTagSelectorView($this->app, $request, $response);
$view->addData('position-selector', $selectorView);
$departmentSelectorView = new \Modules\Organization\Theme\Backend\Components\DepartmentTagSelector\DepartmentTagSelectorView($this->app, $request, $response);
$view->addData('department-selector', $departmentSelectorView);
return $view;
}

View File

@ -0,0 +1,47 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\DepartmentTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class DepartmentTagSelectorPopupView extends View
{
private $id = '';
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/DepartmentTagSelector/department-selector-popup');
}
public function setId(string $id)
{
$this->id = $id;
}
public function getId() : string
{
return $this->id;
}
public function render(...$data) : string
{
$this->id = $data[0] ?? $this->id;
return parent::render();
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\DepartmentTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class DepartmentTagSelectorView extends View
{
private $id = '';
private $isRequired = false;
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/DepartmentTagSelector/department-selector');
$view = new DepartmentTagSelectorPopupView($app, $request, $response);
$this->addData('department-selector-popup', $view);
}
public function getId() : string
{
return $this->id;
}
public function isRequired() : bool
{
return $this->isRequired;
}
public function render(...$data) : string
{
$this->id = $data[0];
$this->isRequired = $data[1] ?? false;
$this->getData('department-selector-popup')->setId($this->id);
return parent::render();
}
}

View File

@ -0,0 +1,90 @@
<template id="acc-grp-tpl">
<section id="acc-grp" class="box w-50" style="z-index: 9; position: absolute; margin: 0 auto; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<header><h1><?= $this->getHtml('Account/Group', 'Admin') ?></h1></header>
<div class="inner">
<div class="tabular-2">
<div class="box wf-100">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Account', 'Admin') ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Group', 'Admin') ?></label>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<label for="iSearchAcc">Search</label>
<input type="text" id="iSearchAcc" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchAcc", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "acc-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchAcc}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="acc-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="address">Address
<th data-name="city">City
<th data-name="zip">Zip
<th data-name="country">Country
<!-- todo: get data from tr in action and pass it to next actions, or make new request based on table cell? -->
<tbody data-action='[
{
"key": 1, "listener": "click", "selector": "#acc-table tbody tr", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self", "selector": ""},
{"key": 2, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-idlist", "value": "{0/id}", "data": ""},
{"key": 3, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-taglist", "value": "<span id=\"{$id}-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}<span>", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#{$id}", "value": "", "data": ""}
]
}
]'>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<label for="iSearchGrp">Search</label>
<input type="text" id="iSearchGrp" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchGrp", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "grp-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchGrp}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="grp-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="parent">Parent
<tbody>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
</div>
</div>
</section>
</template>

View File

@ -0,0 +1,47 @@
<div class="ipt-wrap">
<div class="ipt-first">
<span class="input">
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->printHtml($this->getId()); ?>"},
{"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<input type="text" list="<?= $this->printHtml($this->getId()); ?>-datalist" id="<?= $this->printHtml($this->getId()); ?>" name="receiver" placeholder="&#xf007; Guest" data-action='[
{
"key": 1, "listener": "keyup", "action": [
{"key": 1, "type": "validate.keypress", "pressed": "!13!37!38!39!40"},
{"key": 2, "type": "utils.timer", "id": "<?= $this->printHtml($this->getId()); ?>", "delay": 500, "resets": true},
{"key": 3, "type": "dom.datalist.clear", "id": "<?= $this->printHtml($this->getId()); ?>-datalist"},
{"key": 4, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 5, "type": "dom.datalist.append", "id": "<?= $this->printHtml($this->getId()); ?>-datalist", "value": "id", "text": "name"}
]
},
{
"key": 2, "listener": "keydown", "action" : [
{"key": 1, "type": "validate.keypress", "pressed": "13|9"},
{"key": 2, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "value": "{0/id}", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist", "value": "<span id=\"<?= $this->printHtml($this->getId()); ?>-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}</span>", "data": ""},
{"key": 5, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>", "value": "", "data": ""}
]
}
]'>
<datalist id="<?= $this->printHtml($this->getId()); ?>-datalist"></datalist>
<input type="hidden" id="<?= $this->printHtml($this->getId()); ?>-idlist"<?= $this->isRequired() ? ' required' : ''; ?>>
</span>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Add', 0, 0); ?></button></div>
</div>
<div class="box taglist" id="<?= $this->printHtml($this->getId()); ?>-taglist" data-action='[
{
"key": 1, "listener": "click", "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist span fa", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self"},
{"key": 2, "type": "dom.removevalue", "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "data": ""},
{"key": 3, "type": "dom.remove", "base": "self"}
]
}
]'></div>

View File

@ -0,0 +1,47 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\PositionTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class PositionTagSelectorPopupView extends View
{
private $id = '';
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/PositionTagSelector/position-selector-popup');
}
public function setId(string $id)
{
$this->id = $id;
}
public function getId() : string
{
return $this->id;
}
public function render(...$data) : string
{
$this->id = $data[0] ?? $this->id;
return parent::render();
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\PositionTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class PositionTagSelectorView extends View
{
private $id = '';
private $isRequired = false;
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/PositionTagSelector/position-selector');
$view = new PositionTagSelectorPopupView($app, $request, $response);
$this->addData('position-selector-popup', $view);
}
public function getId() : string
{
return $this->id;
}
public function isRequired() : bool
{
return $this->isRequired;
}
public function render(...$data) : string
{
$this->id = $data[0];
$this->isRequired = $data[1] ?? false;
$this->getData('position-selector-popup')->setId($this->id);
return parent::render();
}
}

View File

@ -0,0 +1,90 @@
<template id="acc-grp-tpl">
<section id="acc-grp" class="box w-50" style="z-index: 9; position: absolute; margin: 0 auto; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<header><h1><?= $this->getHtml('Account/Group', 'Admin') ?></h1></header>
<div class="inner">
<div class="tabular-2">
<div class="box wf-100">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Account', 'Admin') ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Group', 'Admin') ?></label>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<label for="iSearchAcc">Search</label>
<input type="text" id="iSearchAcc" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchAcc", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "acc-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchAcc}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="acc-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="address">Address
<th data-name="city">City
<th data-name="zip">Zip
<th data-name="country">Country
<!-- todo: get data from tr in action and pass it to next actions, or make new request based on table cell? -->
<tbody data-action='[
{
"key": 1, "listener": "click", "selector": "#acc-table tbody tr", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self", "selector": ""},
{"key": 2, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-idlist", "value": "{0/id}", "data": ""},
{"key": 3, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-taglist", "value": "<span id=\"{$id}-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}<span>", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#{$id}", "value": "", "data": ""}
]
}
]'>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<label for="iSearchGrp">Search</label>
<input type="text" id="iSearchGrp" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchGrp", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "grp-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchGrp}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="grp-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="parent">Parent
<tbody>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
</div>
</div>
</section>
</template>

View File

@ -0,0 +1,47 @@
<div class="ipt-wrap">
<div class="ipt-first">
<span class="input">
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->printHtml($this->getId()); ?>"},
{"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<input type="text" list="<?= $this->printHtml($this->getId()); ?>-datalist" id="<?= $this->printHtml($this->getId()); ?>" name="receiver" placeholder="&#xf007; Guest" data-action='[
{
"key": 1, "listener": "keyup", "action": [
{"key": 1, "type": "validate.keypress", "pressed": "!13!37!38!39!40"},
{"key": 2, "type": "utils.timer", "id": "<?= $this->printHtml($this->getId()); ?>", "delay": 500, "resets": true},
{"key": 3, "type": "dom.datalist.clear", "id": "<?= $this->printHtml($this->getId()); ?>-datalist"},
{"key": 4, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 5, "type": "dom.datalist.append", "id": "<?= $this->printHtml($this->getId()); ?>-datalist", "value": "id", "text": "name"}
]
},
{
"key": 2, "listener": "keydown", "action" : [
{"key": 1, "type": "validate.keypress", "pressed": "13|9"},
{"key": 2, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "value": "{0/id}", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist", "value": "<span id=\"<?= $this->printHtml($this->getId()); ?>-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}</span>", "data": ""},
{"key": 5, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>", "value": "", "data": ""}
]
}
]'>
<datalist id="<?= $this->printHtml($this->getId()); ?>-datalist"></datalist>
<input type="hidden" id="<?= $this->printHtml($this->getId()); ?>-idlist"<?= $this->isRequired() ? ' required' : ''; ?>>
</span>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Add', 0, 0); ?></button></div>
</div>
<div class="box taglist" id="<?= $this->printHtml($this->getId()); ?>-taglist" data-action='[
{
"key": 1, "listener": "click", "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist span fa", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self"},
{"key": 2, "type": "dom.removevalue", "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "data": ""},
{"key": 3, "type": "dom.remove", "base": "self"}
]
}
]'></div>

View File

@ -0,0 +1,47 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\UnitTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class UnitTagSelectorPopupView extends View
{
private $id = '';
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/UnitTagSelector/unit-selector-popup');
}
public function setId(string $id)
{
$this->id = $id;
}
public function getId() : string
{
return $this->id;
}
public function render(...$data) : string
{
$this->id = $data[0] ?? $this->id;
return parent::render();
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Organization\Theme\Backend\Components\UnitTagSelector;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class UnitTagSelectorView extends View
{
private $id = '';
private $isRequired = false;
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Organization/Theme/Backend/Components/UnitTagSelector/unit-selector');
$view = new UnitTagSelectorPopupView($app, $request, $response);
$this->addData('unit-selector-popup', $view);
}
public function getId() : string
{
return $this->id;
}
public function isRequired() : bool
{
return $this->isRequired;
}
public function render(...$data) : string
{
$this->id = $data[0];
$this->isRequired = $data[1] ?? false;
$this->getData('unit-selector-popup')->setId($this->id);
return parent::render();
}
}

View File

@ -0,0 +1,90 @@
<template id="acc-grp-tpl">
<section id="acc-grp" class="box w-50" style="z-index: 9; position: absolute; margin: 0 auto; left: 50%; top: 50%; transform: translate(-50%, -50%);">
<header><h1><?= $this->getHtml('Account/Group', 'Admin') ?></h1></header>
<div class="inner">
<div class="tabular-2">
<div class="box wf-100">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Account', 'Admin') ?></label>
<li><label for="c-tab-2"><?= $this->getHtml('Group', 'Admin') ?></label>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<label for="iSearchAcc">Search</label>
<input type="text" id="iSearchAcc" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchAcc", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "acc-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchAcc}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="acc-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="address">Address
<th data-name="city">City
<th data-name="zip">Zip
<th data-name="country">Country
<!-- todo: get data from tr in action and pass it to next actions, or make new request based on table cell? -->
<tbody data-action='[
{
"key": 1, "listener": "click", "selector": "#acc-table tbody tr", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self", "selector": ""},
{"key": 2, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-idlist", "value": "{0/id}", "data": ""},
{"key": 3, "type": "dom.setvalue", "overwrite": false, "selector": "#{$id}-taglist", "value": "<span id=\"{$id}-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}<span>", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#{$id}", "value": "", "data": ""}
]
}
]'>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<label for="iSearchGrp">Search</label>
<input type="text" id="iSearchGrp" name="receiver-search" data-action='[
{
"listener": "keyup", "action": [
{"key": 1, "type": "utils.timer", "id": "iSearchGrp", "delay": 500, "resets": true},
{"key": 2, "type": "dom.table.clear", "id": "grp-table"},
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#iSearchGrp}", "method": "GET", "request_type": "json"},
{"key": 4, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' autocomplete="off">
<table id="grp-table" class="table">
<thead>
<tr>
<th data-name="id">ID
<th data-name="name">Name
<th data-name="parent">Parent
<tbody>
<tfoot>
</table>
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.remove", "selector": "#acc-grp", "aniOut": "fadeOut"}
]
}
]'><?= $this->getHtml('Close', 'Admin') ?></button>
</div>
</div>
</div>
</section>
</template>

View File

@ -0,0 +1,47 @@
<div class="ipt-wrap">
<div class="ipt-first">
<span class="input">
<button type="button" data-action='[
{
"listener": "click", "action": [
{"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->printHtml($this->getId()); ?>"},
{"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<input type="text" list="<?= $this->printHtml($this->getId()); ?>-datalist" id="<?= $this->printHtml($this->getId()); ?>" name="receiver" placeholder="&#xf007; Guest" data-action='[
{
"key": 1, "listener": "keyup", "action": [
{"key": 1, "type": "validate.keypress", "pressed": "!13!37!38!39!40"},
{"key": 2, "type": "utils.timer", "id": "<?= $this->printHtml($this->getId()); ?>", "delay": 500, "resets": true},
{"key": 3, "type": "dom.datalist.clear", "id": "<?= $this->printHtml($this->getId()); ?>-datalist"},
{"key": 4, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 5, "type": "dom.datalist.append", "id": "<?= $this->printHtml($this->getId()); ?>-datalist", "value": "id", "text": "name"}
]
},
{
"key": 2, "listener": "keydown", "action" : [
{"key": 1, "type": "validate.keypress", "pressed": "13|9"},
{"key": 2, "type": "message.request", "uri": "{/base}/{/lang}/api/admin/find/account?search={#<?= $this->printHtml($this->getId()); ?>}", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "value": "{0/id}", "data": ""},
{"key": 4, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist", "value": "<span id=\"<?= $this->printHtml($this->getId()); ?>-taglist-{0/id}\" class=\"tag red\" data-id=\"{0/id}\"><i class=\"fa fa-times\"></i> {0/name/0}, {0/name/1}</span>", "data": ""},
{"key": 5, "type": "dom.setvalue", "overwrite": true, "selector": "#<?= $this->printHtml($this->getId()); ?>", "value": "", "data": ""}
]
}
]'>
<datalist id="<?= $this->printHtml($this->getId()); ?>-datalist"></datalist>
<input type="hidden" id="<?= $this->printHtml($this->getId()); ?>-idlist"<?= $this->isRequired() ? ' required' : ''; ?>>
</span>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Add', 0, 0); ?></button></div>
</div>
<div class="box taglist" id="<?= $this->printHtml($this->getId()); ?>-taglist" data-action='[
{
"key": 1, "listener": "click", "selector": "#<?= $this->printHtml($this->getId()); ?>-taglist span fa", "action": [
{"key": 1, "type": "dom.getvalue", "base": "self"},
{"key": 2, "type": "dom.removevalue", "selector": "#<?= $this->printHtml($this->getId()); ?>-idlist", "data": ""},
{"key": 3, "type": "dom.remove", "base": "self"}
]
}
]'></div>

View File

@ -26,10 +26,9 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" placeholder="&#xf040; R&D" required>
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent"></span>
<tr><td><?= $this->getData('department-selector')->render('iParent', false); ?>
<tr><td><label for="iUnit"><?= $this->getHtml('Unit') ?></label>
<tr><td><select name="unit" id="iUnit">
</select>
<tr><td><?= $this->getData('unit-selector')->render('iUnit', false); ?>
<tr><td><label for="iDescription"><?= $this->getHtml('Description') ?></label>
<tr><td><textarea name="description" id="iDescription" placeholder="&#xf040;"></textarea>
<tr><td><input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Create', 0, 0); ?>">

View File

@ -28,10 +28,9 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($department->getName()); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent" value="<?= $this->printHtml($department->getParent()->getName()); ?>"></span>
<tr><td><?= $this->getData('department-selector')->render('iParent', false); ?>
<tr><td><label for="iUnit"><?= $this->getHtml('Unit') ?></label>
<tr><td><select name="unit" id="iUnit">
</select>
<tr><td><?= $this->getData('unit-selector')->render('iUnit', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option><?= $this->getHtml('Active') ?>

View File

@ -26,9 +26,9 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" placeholder="&#xf040; Orange Management" required>
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent"></span>
<tr><td><?= $this->getData('position-selector')->render('iParent', false); ?>
<tr><td><label for="iDepartment"><?= $this->getHtml('Department') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="department" id="iDepartment"></span>
<tr><td><?= $this->getData('department-selector')->render('iDepartment', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option value="<?= $this->printHtml(\Modules\Organization\Models\Status::ACTIVE); ?>"><?= $this->getHtml('Active') ?>

View File

@ -28,9 +28,9 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($position->getName()); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent" value="<?= $this->printHtml($position->getParent()->getName()); ?>"></span>
<tr><td><?= $this->getData('position-selector')->render('iParent', false); ?>
<tr><td><label for="iDepartment"><?= $this->getHtml('Department') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="department" id="iDepartment"></span>
<tr><td><?= $this->getData('department-selector')->render('iDepartment', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option><?= $this->getHtml('Active') ?>

View File

@ -26,7 +26,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" placeholder="&#xf040; Orange Management" required>
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent"></span>
<tr><td><?= $this->getData('unit-selector')->render('iParent', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option value="<?= $this->printHtml(\Modules\Organization\Models\Status::ACTIVE); ?>"><?= $this->getHtml('Active') ?>

View File

@ -28,7 +28,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($unit->getName()); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent" value="<?= $this->printHtml($unit->getParent()->getName()); ?>" required></span>
<tr><td><?= $this->getData('unit-selector')->render('iParent', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option value="<?= $this->printHtml(\Modules\Organization\Models\Status::ACTIVE); ?>"<?= \Modules\Organization\Models\Status::ACTIVE === $unit->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('Active') ?>