* [MOD] Improved account actions bar

This commit is contained in:
nuxsmin
2018-04-03 00:49:24 +02:00
parent 56b8608610
commit b5a25cd3e9
10 changed files with 218 additions and 164 deletions

View File

@@ -79,7 +79,7 @@ class AccountActionsHelper extends HelperBase
*/
public function getActionsForAccount(AccountAcl $accountAcl, AccountActionsDto $accountActionsDto)
{
$actionsEnabled = [];
$actions = [];
$actionBack = $this->getBackAction();
@@ -92,10 +92,172 @@ class AccountActionsHelper extends HelperBase
$actionBack->setClasses(['btn-back']);
}
$actionsEnabled[] = $actionBack;
$actions[] = $actionBack;
if ($accountAcl->isShowEditPass()) {
$actions[] = $this->getEditPassAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->isShowEdit()) {
$actions[] = $this->getEditAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->getActionId() === ActionsInterface::ACCOUNT_VIEW
&& !$accountAcl->isShowEdit()
&& $this->configData->isMailRequestsEnabled()
) {
$actions[] = $this->getRequestAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->isShowRestore()) {
$actionRestore = $this->getRestoreAction();
$actionRestore->addData('item-id', $accountActionsDto->getAccountId());
$actionRestore->addData('history-id', $accountActionsDto->getAccountHistoryId());
$actions[] = $actionRestore;
}
if ($accountAcl->isShowSave()) {
$actions[] = $this->getSaveAction()->addAttribute('form', 'frmAccount');
}
return $actions;
}
/**
* @return DataGridAction
*/
public function getBackAction()
{
$action = new DataGridAction();
$action->setId('btnBack');
$action->setName(__('Atrás'));
$action->setTitle(__('Atrás'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconBack());
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getEditPassAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT_PASS);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Modificar Clave de Cuenta'));
$action->setTitle(__('Modificar Clave de Cuenta'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEditPass());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowViewPass');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS));
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getEditAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT);
$action->setType(DataGridActionType::EDIT_ITEM);
$action->setName(__('Editar Cuenta'));
$action->setTitle(__('Editar Cuenta'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEdit());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowEdit');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT));
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getRequestAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_REQUEST);
$action->setName(__('Solicitar Modificación'));
$action->setTitle(__('Solicitar Modificación'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEmail());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowRequest');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_REQUEST));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addAttribute('type', 'submit');
return $action;
}
/**
* @return DataGridAction
*/
public function getRestoreAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT_RESTORE);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Restaurar cuenta desde este punto'));
$action->setTitle(__('Restaurar cuenta desde este punto'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconRestore());
$action->addData('action-route', 'account/saveEditRestore');
$action->addData('action-sk', $this->sk);
$action->addData('onclick', 'account/saveEditRestore');
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getSaveAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Guardar'));
$action->setTitle(__('Guardar'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconSave());
$action->addData('action-route', 'account/save');
$action->addData('action-sk', $this->sk);
$action->addData('onclick', 'account/save');
$action->addAttribute('type', 'submit');
return $action;
}
/**
* Set icons for view
*
* @param AccountAcl $accountAcl
* @param AccountActionsDto $accountActionsDto
* @return DataGridAction[]
*/
public function getActionsGrouppedForAccount(AccountAcl $accountAcl, AccountActionsDto $accountActionsDto)
{
$actions = [];
if ($accountAcl->isShowDelete()) {
$actionsEnabled[] = $this->getDeleteAction()->addData('item-id', $accountActionsDto->getAccountId());
$actions[] = $this->getDeleteAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountActionsDto->isHistory() === false
@@ -107,7 +269,7 @@ class AccountActionsHelper extends HelperBase
$action = $accountActionsDto->getPublicLinkId() ? $this->getPublicLinkRefreshAction() : $this->getPublicLinkAction();
$itemId = $accountActionsDto->getPublicLinkId() ?: $accountActionsDto->getAccountId();
$actionsEnabled[] = $action->addData('item-id', $itemId);
$actions[] = $action->addData('item-id', $itemId);
}
if ($accountAcl->isShowViewPass()) {
@@ -128,61 +290,15 @@ class AccountActionsHelper extends HelperBase
$actionCopy->addData('item-id', $accountActionsDto->getAccountId());
}
$actionsEnabled[] = $actionViewPass;
$actionsEnabled[] = $actionCopy;
$actions[] = $actionViewPass;
$actions[] = $actionCopy;
}
if ($accountAcl->isShowCopy()) {
$actionsEnabled[] = $this->getCopyAction()->addData('item-id', $accountActionsDto->getAccountId());
$actions[] = $this->getCopyAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->isShowEditPass()) {
$actionsEnabled[] = $this->getEditPassAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->isShowEdit()) {
$actionsEnabled[] = $this->getEditAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->getActionId() === ActionsInterface::ACCOUNT_VIEW
&& !$accountAcl->isShowEdit()
&& $this->configData->isMailRequestsEnabled()
) {
$actionsEnabled[] = $this->getRequestAction()->addData('item-id', $accountActionsDto->getAccountId());
}
if ($accountAcl->isShowRestore()) {
$actionRestore = $this->getRestoreAction();
$actionRestore->addData('item-id', $accountActionsDto->getAccountId());
$actionRestore->addData('history-id', $accountActionsDto->getAccountHistoryId());
$actionsEnabled[] = $actionRestore;
}
if ($accountAcl->isShowSave()) {
$actionsEnabled[] = $this->getSaveAction()->addAttribute('form', 'frmAccount');
}
return $actionsEnabled;
}
/**
* @return DataGridAction
*/
public function getBackAction()
{
$action = new DataGridAction();
$action->setId('btnBack');
$action->setName(__('Atrás'));
$action->setTitle(__('Atrás'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconBack());
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addAttribute('type', 'button');
return $action;
return $actions;
}
/**
@@ -314,108 +430,6 @@ class AccountActionsHelper extends HelperBase
return $action;
}
/**
* @return DataGridAction
*/
public function getEditPassAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT_PASS);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Modificar Clave de Cuenta'));
$action->setTitle(__('Modificar Clave de Cuenta'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEditPass());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowViewPass');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT_PASS));
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getEditAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT);
$action->setType(DataGridActionType::EDIT_ITEM);
$action->setName(__('Editar Cuenta'));
$action->setTitle(__('Editar Cuenta'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEdit());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowEdit');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_EDIT));
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getRequestAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_REQUEST);
$action->setName(__('Solicitar Modificación'));
$action->setTitle(__('Solicitar Modificación'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconEmail());
$action->setRuntimeFilter(AccountSearchItem::class, 'isShowRequest');
$action->addData('action-route', Acl::getActionRoute(ActionsInterface::ACCOUNT_REQUEST));
$action->addData('action-sk', $this->sk);
$action->addData('onclick', Acl::getActionRoute(ActionsInterface::ACCOUNT_VIEW));
$action->addAttribute('type', 'submit');
return $action;
}
/**
* @return DataGridAction
*/
public function getRestoreAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT_EDIT_RESTORE);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Restaurar cuenta desde este punto'));
$action->setTitle(__('Restaurar cuenta desde este punto'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconRestore());
$action->addData('action-route', 'account/saveEditRestore');
$action->addData('action-sk', $this->sk);
$action->addData('onclick', 'account/saveEditRestore');
$action->addAttribute('type', 'button');
return $action;
}
/**
* @return DataGridAction
*/
public function getSaveAction()
{
$action = new DataGridAction();
$action->setId(ActionsInterface::ACCOUNT);
$action->setType(DataGridActionType::VIEW_ITEM);
$action->setName(__('Guardar'));
$action->setTitle(__('Guardar'));
$action->addClass('btn-action');
$action->setIcon($this->icons->getIconSave());
$action->addData('action-route', 'account/save');
$action->addData('action-sk', $this->sk);
$action->addData('onclick', 'account/save');
$action->addAttribute('type', 'submit');
return $action;
}
/**
* Initialize class
*/

View File

@@ -122,7 +122,7 @@ class AccountHelper extends HelperBase
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUsers(), function ($value) {
return (int)$value->isEdit === 0;
})), $accountData->getUserId()));
$this->view->assign('otherUsersEdit', $selectUsers->getItemsFromModelSelected(
SelectItemAdapter::getIdFromArrayOfObjects(array_filter($accountDetailsResponse->getUsers(), function ($value) {
return (int)$value->isEdit === 1;
@@ -180,7 +180,10 @@ class AccountHelper extends HelperBase
$this->view->assign('accountData', $accountData);
$this->view->assign('gotData', true);
$this->view->assign('accountActions', $this->dic->get(AccountActionsHelper::class)->getActionsForAccount($this->accountAcl, $accountActionsDto));
$accountActionsHelper = $this->dic->get(AccountActionsHelper::class);
$this->view->assign('accountActions', $accountActionsHelper->getActionsForAccount($this->accountAcl, $accountActionsDto));
$this->view->assign('accountActionsMenu', $accountActionsHelper->getActionsGrouppedForAccount($this->accountAcl, $accountActionsDto));
$this->setViewCommon();
}
@@ -320,7 +323,7 @@ class AccountHelper extends HelperBase
$this->view->assign('accountId', 0);
$this->view->assign('gotData', false);
$this->view->assign('accountActions', $this->dic->get(AccountActionsHelper::class)->getActionsForAccount($this->accountAcl, new AccountActionsDto($this->accountId)));
$this->view->assign('accountActions', $this->dic->get(AccountActionsHelper::class)->getActionsForAccount($this->accountAcl, new AccountActionsDto($this->accountId)));
$this->setViewCommon();
}

View File

@@ -105,9 +105,10 @@ class AccountHistoryHelper extends HelperBase
$this->view->assign('clients', SelectItemAdapter::factory(ClientService::getItemsBasic())->getItemsFromModelSelected([$accountHistoryData->getClientId()]));
$this->view->assign('isModified', strtotime($accountHistoryData->getDateEdit()) !== false);
$actions = $this->dic->get(AccountActionsHelper::class);
$accountActionsHelper = $this->dic->get(AccountActionsHelper::class);
$this->view->assign('accountActions', $actions->getActionsForAccount($this->accountAcl, new AccountActionsDto($this->accountId, $this->accountHistoryId)));
$this->view->assign('accountActions', $accountActionsHelper->getActionsForAccount($this->accountAcl, new AccountActionsDto($this->accountId, $this->accountHistoryId)));
$this->view->assign('accountActionsMenu', $accountActionsHelper->getActionsGrouppedForAccount($this->accountAcl, new AccountActionsDto($this->accountId, $this->accountHistoryId)));
}
/**

View File

@@ -851,7 +851,12 @@ footer {
width: 75%; }
.item-actions {
display: flex;
justify-content: flex-end;
position: relative;
margin: 1em auto; }
.item-actions > div {
display: inline-block; }
.tab-actions {
margin: 2em 0; }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -815,7 +815,13 @@ footer {
}
.item-actions {
display: flex;
justify-content: flex-end;
position: relative;
margin: 1em auto;
> div {
display: inline-block;
}
}
.tab-actions {

View File

@@ -2,6 +2,7 @@
/**
* @var \SP\Core\UI\ThemeIcons $icons
* @var \SP\Html\DataGrid\DataGridActionInterface[] $accountActions
* @var \SP\Html\DataGrid\DataGridActionInterface[] $accountActionsMenu
*/
?>
<div class="item-actions">
@@ -18,4 +19,25 @@
</li>
<?php endforeach; ?>
</ul>
<?php if (isset($accountActionsMenu) && count($accountActionsMenu) > 0): ?>
<div>
<button id="actions-menu-account"
class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">more_vert</i>
</button>
<ul class="mdl-menu mdl-menu--top-left mdl-js-menu mdl-js-ripple-effect"
for="actions-menu-account">
<?php foreach ($accountActionsMenu as $action): ?>
<li class="btn-action mdl-menu__item"
id="<?php echo $action->getId(); ?>"
<?php foreach ($action->getData() as $key => $value): echo 'data-', $key, '="', $value, '"'; endforeach; ?>
<?php foreach ($action->getAttributes() as $key => $value): echo $key, '="', $value, '"'; endforeach; ?>
title="<?php echo $action->getTitle(); ?>">
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
<?php echo $action->getName(); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>

View File

@@ -56,7 +56,7 @@ class Installer extends Service
*/
const VERSION = [3, 0, 0];
const VERSION_TEXT = '3.0-beta';
const BUILD = 18040201;
const BUILD = 18040301;
/**
* @var ConfigService

View File

@@ -144,6 +144,7 @@ DROP TABLE IF EXISTS `AccountToUser`;
CREATE TABLE `AccountToUser` (
`accountId` mediumint(8) unsigned NOT NULL,
`userId` smallint(5) unsigned NOT NULL,
`isEdit` tinyint(1) unsigned DEFAULT 0 NULL,
PRIMARY KEY (`accountId`,`userId`),
KEY `idx_AccountToUser_01` (`accountId`),
KEY `fk_AccountToUser_userId` (`userId`),
@@ -157,6 +158,7 @@ DROP TABLE IF EXISTS `AccountToUserGroup`;
CREATE TABLE `AccountToUserGroup` (
`accountId` mediumint(8) unsigned NOT NULL,
`userGroupId` smallint(5) unsigned NOT NULL,
`isEdit` tinyint(1) unsigned DEFAULT 0 NULL,
PRIMARY KEY (`accountId`,`userGroupId`),
KEY `idx_AccountToUserGroup_01` (`accountId`),
KEY `fk_AccountToUserGroup_userGroupId` (`userGroupId`),
@@ -247,6 +249,7 @@ CREATE TABLE `CustomFieldDefinition` (
`help` varchar(255) DEFAULT NULL,
`showInList` tinyint(1) unsigned DEFAULT NULL,
`typeId` tinyint(3) unsigned NOT NULL,
`isEncrypted` tinyint(1) unsigned DEFAULT 1 NULL,
PRIMARY KEY (`id`),
KEY `fk_CustomFieldDefinition_typeId` (`typeId`),
CONSTRAINT `fk_CustomFieldDefinition_typeId` FOREIGN KEY (`typeId`) REFERENCES `CustomFieldType` (`id`) ON UPDATE CASCADE