Implement group/account create+edit

This commit is contained in:
Dennis Eichhorn 2018-02-15 17:57:57 +01:00
parent 980a8f9ad6
commit 14bb7e8d1c
5 changed files with 96 additions and 21 deletions

View File

@ -496,7 +496,7 @@ class Controller extends ModuleAbstract implements WebInterface
*
* @since 1.0.0
*/
public function apiGroupSet(RequestAbstract $request, ResponseAbstract $response, $data = null) /* : void */
public function apiGroupUpdate(RequestAbstract $request, ResponseAbstract $response, $data = null) /* : void */
{
if (!$this->app->accountManager->get($request->getHeader()->getAccount())->hasPermission(
PermissionType::MODIFY, $this->app->orgId, $this->app->appName, self::MODULE_ID, PermissionState::GROUP)
@ -507,9 +507,9 @@ class Controller extends ModuleAbstract implements WebInterface
}
$group = GroupMapper::get((int) $request->getData('id'));
$group->setName((string) ($request->getData('name') ?? $group->getName()));
$group->setDescription(Markdown::parse((string) ($request->getData('description') ?? $group->getDescription())));
$group->setStatus((int) ($request->getData('status') ?? $group->getStatus()));
$group->setDescription(Markdown::parse((string) ($request->getData('description') ?? $group->getDescriptionRaw())));
$group->setDescriptionRaw((string) ($request->getData('description') ?? $group->getDescriptionRaw()));
GroupMapper::update($group);

View File

@ -21,7 +21,7 @@ echo $this->getData('nav')->render(); ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Account'); ?></h1></header>
<div class="inner">
<form id="fAccount" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="put">
<form id="fAccount" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="put" data-msg='{"title": "Some Title", "message": "My Message"}'>
<table class="layout wf-100">
<tbody>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?>
<option value="<?= $this->printHtml(\phpOMS\Account\AccountStatus::BANNED); ?>"><?= $this->getHtml('Banned'); ?>
</select>
<tr><td><label for="iUsername"><?= $this->getHtml('Username'); ?></label>
<tr><td><input id="iUsername" name="name" type="text" placeholder="&#xf007; Fred">
<tr><td><input id="iUsername" name="login" type="text" placeholder="&#xf007; Fred">
<tr><td><label for="iName1"><?= $this->getHtml('Name1'); ?></label>
<tr><td><input id="iName1" name="name1" type="text" placeholder="&#xf007; Donald" required>
<tr><td><label for="iName2"><?= $this->getHtml('Name2'); ?></label>
@ -48,7 +48,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><input id="iEmail" name="email" type="email" placeholder="&#xf0e0; d.duck@duckburg.com">
<tr><td><label for="iPassword"><?= $this->getHtml('Name3'); ?></label>
<tr><td><input id="iPassword" name="password" type="password" placeholder="&#xf023; Pa55ssw0rd?">
<tr><td><input type="submit" value="<?= $this->getHtml('Create', 0, 0); ?>">
<tr><td><input id="account-create-submit" name="createSubmit" type="submit" value="<?= $this->getHtml('Create', 0, 0); ?>">
</table>
</form>
</div>
@ -56,6 +56,16 @@ echo $this->getData('nav')->render(); ?>
</div>
<div class="col-xs-12 col-md-4">
<table class="box table red">
<caption><?= $this->getHtml('Groups') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<tbody>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
</table>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Groups'); ?></h1></header>
<div class="inner">
@ -63,7 +73,7 @@ echo $this->getData('nav')->render(); ?>
<table class="layout wf-100">
<tbody>
<tr><td><label for="iGroup"><?= $this->getHtml('Name'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input id="iGroup" name="group" type="text" placeholder="&#xf0c0; Guest" required></span>
<tr><td><input id="iGroup" name="group" type="text" placeholder="&#xf0c0; Guest">
<tr><td><input type="submit" value="<?= $this->getHtml('Add', 0, 0); ?>">
</table>
</form>
@ -72,14 +82,30 @@ echo $this->getData('nav')->render(); ?>
</div>
<div class="col-xs-12 col-md-4">
<table class="box table red">
<caption><?= $this->getHtml('Permissions') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td>Unit
<td>App
<td>Module
<td>Type
<td>Ele.
<td>Comp.
<td class="wf-100">Perm.
<tbody>
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
</table>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Permissions'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/group'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr><td><label for="iGroup"><?= $this->getHtml('Name'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input id="iGroup" name="group" type="text" placeholder="&#xf084; news_create" required></span>
<tr><td><label for="iPermission"><?= $this->getHtml('Name'); ?></label>
<tr><td><input id="iPermission" name="group" type="text" placeholder="&#xf084; news_create">
<tr><td><input type="submit" value="<?= $this->getHtml('Add', 0, 0); ?>">
</table>
</form>

View File

@ -24,7 +24,7 @@ echo $this->getData('nav')->render(); ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Account'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="post">
<form id="account-edit" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/account'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr><td><label for="iId"><?= $this->getHtml('ID', 0, 0); ?></label>
@ -53,7 +53,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><input id="iEmail" name="email" type="email" placeholder="&#xf0e0; d.duck@duckburg.com" value="<?= $this->printHtml($account->getEmail()); ?>">
<tr><td><label for="iPassword"><?= $this->getHtml('Name3'); ?></label>
<tr><td><input id="iPassword" name="password" type="text" placeholder="&#xf023; Pa55ssw0rd?">
<tr><td><input type="submit" value="<?= $this->getHtml('Save', 0, 0); ?>">
<tr><td><input id="account-edit-submit" name="editSubmit" type="submit" value="<?= $this->getHtml('Save', 0, 0); ?>">
</table>
</form>
</div>

View File

@ -17,7 +17,7 @@
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="col-xs-12 col-md-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Group'); ?></h1></header>
<div class="inner">
@ -41,7 +41,24 @@ echo $this->getData('nav')->render(); ?>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="col-xs-12 col-md-4">
<table class="box table red wf-100">
<caption><?= $this->getHtml('Parents') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100">Name
<tbody>
<?php $c = 0; foreach ([] as $key => $value) : $c++; ?>
<tr>
<td>
<td>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
<?php endif; ?>
</table>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Parent'); ?></h1></header>
<div class="inner">
@ -49,7 +66,7 @@ echo $this->getData('nav')->render(); ?>
<table class="layout wf-100">
<tbody>
<tr><td><label for="iGParentName"><?= $this->getHtml('Name'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input id="iGParentName" name="parentname" type="text" placeholder="&#xf0c0; Guest"></span>
<tr><td><input id="iGParentName" name="parentname" type="text" placeholder="&#xf0c0; Guest">
<tr><td><input type="submit" value="<?= $this->getHtml('Add', 0, 0); ?>">
</table>
</form>
@ -57,7 +74,23 @@ echo $this->getData('nav')->render(); ?>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="col-xs-12 col-md-4">
<table class="box table red wf-100">
<caption><?= $this->getHtml('Permissions') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td>Unit
<td>App
<td>Module
<td>Type
<td>Ele.
<td>Comp.
<td class="wf-100">Perm.
<tbody>
<tr><td colspan="8" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
</table>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Permissions'); ?></h1></header>
<div class="inner">
@ -65,7 +98,23 @@ echo $this->getData('nav')->render(); ?>
<table class="layout wf-100">
<tbody>
<tr><td><label for="iPermissionName"><?= $this->getHtml('Name'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input id="iPermissionName" name="permissionname" type="text" placeholder="&#xf084; Admin"></span>
<tr><td><input id="iPermissionName" name="permissionname" type="text" placeholder="&#xf084; Admin">
<tr><td><input type="submit" value="<?= $this->getHtml('Add', 0, 0); ?>">
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Accounts'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/group'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr><td><label for="iGParentName"><?= $this->getHtml('Name'); ?></label>
<tr><td><input id="iGParentName" name="parentname" type="text" placeholder="&#xf234; Donald Duck">
<tr><td><input type="submit" value="<?= $this->getHtml('Add', 0, 0); ?>">
</table>
</form>

View File

@ -25,22 +25,22 @@ echo $this->getData('nav')->render(); ?>
<section class="box wf-100">
<header><h1><?= $this->getHtml('Group'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/group'); ?>" method="post">
<form id="fGroupEdit" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/group'); ?>" method="post" data-msg='{"title": "Some Title", "message": "My Message"}'>
<table class="layout wf-100">
<tbody>
<tr><td><label for="iGid"><?= $this->getHtml('ID', 0, 0); ?></label>
<tr><td><input id="iGid" name="gid" type="text" value="<?= $this->printHtml($group->getId()); ?>" disabled>
<tr><td><input id="iGid" name="id" type="text" value="<?= $this->printHtml($group->getId()); ?>" disabled>
<tr><td><label for="iGname"><?= $this->getHtml('Name'); ?></label>
<tr><td><input id="iGname" name="gname" type="text" placeholder="&#xf0c0; Guest" value="<?= $this->printHtml($group->getName()); ?>">
<tr><td><input id="iGname" name="name" type="text" placeholder="&#xf0c0; Guest" value="<?= $this->printHtml($group->getName()); ?>">
<tr><td><label for="iGstatus"><?= $this->getHtml('Status'); ?></label>
<tr><td><select id="iGstatus" status="gname">
<tr><td><select id="iGstatus" name="status">
<?php $status = \phpOMS\Account\GroupStatus::getConstants(); foreach ($status as $stat) : ?>
<option value="<?= $stat; ?>"<?= $stat === $group->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('GroupStatus' . $stat); ?>
<?php endforeach; ?>
</select>
<tr><td><label for="iGroupDescription"><?= $this->getHtml('Description'); ?></label>
<tr><td><textarea id="iGroupDescription" name="description" placeholder="&#xf040;"><?= $this->printHtml($group->getDescription()); ?></textarea>
<tr><td><input type="submit" value="<?= $this->getHtml('Save', 0, 0); ?>">
<tr><td><input id="groupSubmit" name="groupsubmit" type="submit" value="<?= $this->getHtml('Save', 0, 0); ?>">
</table>
</form>
</div>