Essential part for issue #64

Real drag & drop needs to be created.
This commit is contained in:
djmaze 2021-03-22 15:44:48 +01:00
parent 28d09c1a5d
commit 612aff4b27
3 changed files with 43 additions and 15 deletions

View file

@ -800,6 +800,13 @@ class RemoteUserFetch extends AbstractFetchRemote {
});
}
folderMove(sPrevFolderFullNameRaw, sNewFolderFullName) {
return this.postRequest('FolderMove', FolderUserStore.foldersRenaming, {
Folder: sPrevFolderFullNameRaw,
NewFolder: sNewFolderFullName
});
}
folderRename(sPrevFolderFullNameRaw, sNewFolderName) {
return this.postRequest('FolderRename', FolderUserStore.foldersRenaming, {
Folder: sPrevFolderFullNameRaw,

View file

@ -2088,7 +2088,7 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRenameOrMove, bool $bSubscribeOnModify) : self
protected function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self
{
if (0 === \strlen($sPrevFolderFullNameRaw) || 0 === \strlen($sNextFolderNameInUtf))
{
@ -2099,7 +2099,7 @@ class MailClient
if (!$aFolders)
{
// TODO
throw new \MailSo\Mail\Exceptions\RuntimeException('Cannot rename non-existen folder');
throw new \MailSo\Mail\Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existen folder');
}
$sDelimiter = $aFolders[0]->Delimiter();
@ -2119,7 +2119,7 @@ class MailClient
\MailSo\Base\Enumerations\Charset::UTF_8,
\MailSo\Base\Enumerations\Charset::UTF_7_IMAP);
if ($bRenameOrMove)
if ($bRename)
{
if (0 < \strlen($sDelimiter) && false !== \strpos($sNewFolderFullNameRaw, $sDelimiter))
{

View file

@ -239,6 +239,29 @@ trait Folders
$this->SettingsProvider(true)->Save($oAccount, $oSettingsLocal));
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoFolderMove() : array
{
$oAccount = $this->initMailClientConnection();
try
{
$this->MailClient()->FolderMove(
$this->GetActionParam('Folder', ''),
$this->GetActionParam('NewFolder', ''),
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
);
}
catch (\Throwable $oException)
{
throw new ClientException(Notifications::CantRenameFolder, $oException);
}
return $this->TrueResponse(__FUNCTION__);
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
@ -246,13 +269,13 @@ trait Folders
{
$oAccount = $this->initMailClientConnection();
$sPrevFolderFullNameRaw = $this->GetActionParam('Folder', '');
$sNewTopFolderNameInUtf = $this->GetActionParam('NewFolderName', '');
try
{
$this->MailClient()->FolderRename($sPrevFolderFullNameRaw, $sNewTopFolderNameInUtf,
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true));
$this->MailClient()->FolderRename(
$this->GetActionParam('Folder', ''),
$this->GetActionParam('NewFolderName', ''),
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
);
}
catch (\Throwable $oException)
{
@ -269,12 +292,12 @@ trait Folders
{
$oAccount = $this->initMailClientConnection();
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
try
{
$this->MailClient()->FolderDelete($sFolderFullNameRaw,
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true));
$this->MailClient()->FolderDelete(
$this->GetActionParam('Folder', ''),
!!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)
);
}
catch (\MailSo\Mail\Exceptions\NonEmptyFolder $oException)
{
@ -295,11 +318,9 @@ trait Folders
{
$this->initMailClientConnection();
$sFolderFullNameRaw = $this->GetActionParam('Folder', '');
try
{
$this->MailClient()->FolderClear($sFolderFullNameRaw);
$this->MailClient()->FolderClear($this->GetActionParam('Folder', ''));
}
catch (\Throwable $oException)
{