mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Sortable accounts list
This commit is contained in:
parent
965ea317e4
commit
b563528be7
10 changed files with 150 additions and 28 deletions
|
|
@ -1891,6 +1891,21 @@ class Actions
|
|||
if (1 === \count($aAccounts))
|
||||
{
|
||||
$this->SetAccounts($oAccount, array());
|
||||
|
||||
}
|
||||
else if (1 < \count($aAccounts))
|
||||
{
|
||||
$sOrder = $this->StorageProvider()->Get(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
\RainLoop\KeyPathHelper::WebmailAccountsOrder($sParentEmail),
|
||||
null
|
||||
);
|
||||
|
||||
$aOrder = empty($sOrder) ? array() : @\json_decode($sOrder, true);
|
||||
if (\is_array($aAccounts) && \is_array($aOrder) && 0 < \count($aOrder))
|
||||
{
|
||||
$aAccounts = \array_merge(\array_flip($aOrder), $aAccounts);
|
||||
}
|
||||
}
|
||||
|
||||
return $aAccounts;
|
||||
|
|
@ -2276,6 +2291,28 @@ class Actions
|
|||
return $this->DefaultResponse(__FUNCTION__, $this->SetIdentities($oAccount, $aNew));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\Exception
|
||||
*/
|
||||
public function DoAccountSortOrder()
|
||||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
$aList = $this->GetActionParam('Accounts', null);
|
||||
if (!\is_array($aList) || 2 > \count($aList))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__, $this->StorageProvider()->Put(null,
|
||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
||||
\RainLoop\KeyPathHelper::WebmailAccountsOrder($oAccount->ParentEmailHelper()),
|
||||
\json_encode($aList)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,6 +24,16 @@ class KeyPathHelper
|
|||
return 'Webmail/Accounts/'.$sEmail.'/Array';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function WebmailAccountsOrder($sEmail)
|
||||
{
|
||||
return 'Webmail/AccountsSortOrder/'.$sEmail.'/Array';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHash
|
||||
*
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<col style="width: 150px" />
|
||||
<col style="width: 1%" />
|
||||
</colgroup>
|
||||
<tbody data-bind="foreach: accounts">
|
||||
<tbody data-bind="sortable: {data: accounts, options: scrollableOptions()}">
|
||||
<tr class="account-item">
|
||||
<td class="e-action" data-bind="css: {'e-action': canBeEdit}">
|
||||
<span class="account-img icon-user"></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue