mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-30 05:28:39 +00:00
Draft basic button action
This commit is contained in:
parent
2143098e66
commit
a2a105c167
|
|
@ -366,14 +366,31 @@ final class ApiController extends Controller
|
|||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Account', 'Account successfully created', $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create profile for account
|
||||
*
|
||||
* @param Account $account Account to create profile for
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createProfileForAccount(Account $account, RequestAbstract $request) : void
|
||||
{
|
||||
if (((string) ($request->getData('password') ?? '')) !== ''
|
||||
&& ((string) ($request->getData('login') ?? '')) !== ''
|
||||
) {
|
||||
$this->app->moduleManager->get('Profile')->apiProfileCreateDbEntry(new \Modules\Profile\Models\Profile($account), $request);
|
||||
$old = clone $account;
|
||||
|
||||
$this->updateModel($request, $account, $account, function() use($account) : void {
|
||||
$this->app->moduleManager->get('Profile')->apiProfileCreateDbEntry(
|
||||
new \Modules\Profile\Models\Profile($account),
|
||||
$request
|
||||
);
|
||||
|
||||
$this->updateModel($request, $old, $account, function() use($account) : void {
|
||||
$account->setLoginTries((int) $this->app->appSettings->get(Settings::LOGIN_TRIES));
|
||||
AccountMapper::update($account);
|
||||
}, 'account');
|
||||
|
|
@ -442,6 +459,11 @@ final class ApiController extends Controller
|
|||
$old = clone AccountMapper::get((int) $request->getData('id'));
|
||||
$new = $this->updateAccountFromRequest($request);
|
||||
$this->updateModel($request, $old, $new, AccountMapper::class, 'account');
|
||||
|
||||
if (\Modules\Profile\Models\ProfileMapper::getFor($new->getId(), 'account') instanceof \Modules\Profile\Models\NullProfile) {
|
||||
$this->createProfileForAccount($new, $request);
|
||||
}
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Account', 'Account successfully updated', $new);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ return [
|
|||
'Component' => 'Component',
|
||||
'Country' => 'Country',
|
||||
'Create' => 'Create',
|
||||
'CreateProfile' => 'Create Profile',
|
||||
'Created' => 'Created',
|
||||
'CreatedBy' => 'Created By',
|
||||
'Currency' => 'Currency',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<table class="layout wf-100">
|
||||
<tbody>
|
||||
<tr><td><label for="iId"><?= $this->getHtml('ID', 0, 0); ?></label>
|
||||
<tr><td><input id="iId" name="id" type="text" value="<?= $this->printHtml($account->getId()); ?>" disabled>
|
||||
<tr><td><input id="iId" name="iaccount-idlist" type="text" value="<?= $this->printHtml($account->getId()); ?>" disabled>
|
||||
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
|
||||
<tr><td><select id="iType" name="type">
|
||||
<option value="<?= $this->printHtml(AccountType::USER); ?>"<?= $this->printHtml($account->getType() === AccountType::USER ? ' selected' : ''); ?>><?= $this->getHtml('Person'); ?>
|
||||
|
|
@ -49,7 +49,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<tr><td>
|
||||
<span class="input">
|
||||
<button type="button"><i class="fa fa-user"></i></button>
|
||||
<input id="iUsername" name="name" type="text" value="<?= $this->printHtml($account->getName()); ?>" disabled>
|
||||
<input id="iUsername" name="name" type="text" value="<?= $this->printHtml($account->getName()); ?>">
|
||||
</span>
|
||||
<tr><td><label for="iName1"><?= $this->getHtml('Name1'); ?></label>
|
||||
<tr><td>
|
||||
|
|
@ -86,7 +86,17 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
<div class="ipt-second"> or <button><?= $this->getHtml('Reset'); ?></button></div>
|
||||
</div>
|
||||
<tr><td><input id="account-edit-submit" name="editSubmit" 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); ?>">
|
||||
<button id="account-profile-create" data-action='[
|
||||
{
|
||||
"key": 1, "listener": "click", "action": [
|
||||
{"key": 1, "type": "event.prevent"},
|
||||
{"key": 2, "type": "dom.getvalue", "base": "", "selector": "#iId"},
|
||||
{"key": 3, "type": "message.request", "uri": "{/base}/{/lang}/api/profile", "method": "PUT", "request_type": "json"}
|
||||
]
|
||||
}
|
||||
]'><?= $this->getHtml('CreateProfile'); ?></button>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ $temperatures = \phpOMS\Utils\Converter\TemperatureType::getConstants();
|
|||
?>
|
||||
|
||||
<div class="tabview tab-2">
|
||||
<div class="box wf-100">
|
||||
<div class="box wf-100 col-xs-12">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $this->getHtml('General'); ?></label></li>
|
||||
<li><label for="c-tab-2"><?= $this->getHtml('Localization'); ?></label></li>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user