Further implementations after using the app

This commit is contained in:
Dennis Eichhorn 2018-09-15 17:14:24 +02:00
parent df181b3a8d
commit 376aae7f88
2 changed files with 18 additions and 13 deletions

View File

@ -22,6 +22,7 @@ use Modules\Admin\Models\AccountMapper;
use phpOMS\Account\PermissionType;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Message\NotificationLevel;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
@ -236,7 +237,12 @@ final class Controller extends ModuleAbstract implements WebInterface
$created[] = $profile->jsonSerialize();
}
$response->set($request->getUri()->__toString(), $created);
$response->set($request->getUri()->__toString(), [
'status' => NotificationLevel::OK,
'title' => 'Profile(s)',
'message' => 'Profile(s) successfully created.',
'response' => $created
]);
}
/**
@ -251,19 +257,18 @@ final class Controller extends ModuleAbstract implements WebInterface
private function createProfilesFromRequest(RequestAbstract $request) : array
{
$profiles = [];
$accounts = \json_decode($request->getData('iaccount-idlist') ?? '[]', true);
if ($accounts === false) {
return $profiles;
}
if (\is_int($accounts)) {
$accounts = [$accounts];
}
$accounts = $request->getDataList('iaccount-idlist');
foreach ($accounts as $account) {
$account = AccountMapper::get((int) $account);
$profiles[] = new Profile(AccountMapper::get((int) $account));
$account = (int) \trim($account);
$isInDb = ProfileMapper::getFor($account, 'account');
if ($isInDb->getId() !== 0) {
$profiles[] = $isInDb;
continue;
}
$profiles[] = new Profile(AccountMapper::get($account));
}
return $profiles;

View File

@ -4,7 +4,7 @@ echo $this->getData('nav')->render();
?>
<div class="row">
<div class="col-xs-12 col-md-4">
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('CreateProfile'); ?></h1></header>