diff --git a/client/res/templates/email-folder/modals/select-folder.tpl b/client/res/templates/email-folder/modals/select-folder.tpl
index 82a6c7444e..9c07c13dd4 100644
--- a/client/res/templates/email-folder/modals/select-folder.tpl
+++ b/client/res/templates/email-folder/modals/select-folder.tpl
@@ -7,7 +7,7 @@
data-action="selectFolder"
data-id="{{id}}"
data-name="{{name}}"
- class="side-link text-bold"
+ class="side-link text-bold {{#if disabled}} disabled text-muted {{/if}}"
>{{name}}
{{/each}}
diff --git a/client/src/views/email-folder/modals/select-folder.js b/client/src/views/email-folder/modals/select-folder.js
index 4bbc3c878a..5ca6ad228c 100644
--- a/client/src/views/email-folder/modals/select-folder.js
+++ b/client/src/views/email-folder/modals/select-folder.js
@@ -56,6 +56,12 @@ export default class extends ModalView {
};
}
+ /**
+ * @private
+ * @type {string|undefined}
+ */
+ currentFolderId
+
setup() {
this.addActionHandler('selectFolder', (e, target) => {
const id = target.dataset.id;
@@ -68,6 +74,7 @@ export default class extends ModalView {
this.headerText = this.options.headerText || '';
this.isGroup = this.options.isGroup || false;
this.noArchive = this.options.noArchive || false;
+ this.currentFolderId = this.options.currentFolderId;
if (this.headerText === '') {
this.buttonList.push({
@@ -112,6 +119,7 @@ export default class extends ModalView {
const isGroup = item.id.startsWith('group:');
return {
+ disabled: item.id === this.currentFolderId,
id: item.id,
name: item.name,
isGroup: isGroup,
@@ -134,6 +142,7 @@ export default class extends ModalView {
id: this.FOLDER_ARCHIVE,
name: this.translate('archive', 'presetFilters', 'Email'),
iconClass: iconMap[this.FOLDER_ARCHIVE],
+ disabled: this.currentFolderId === this.FOLDER_ARCHIVE,
});
}
})
diff --git a/client/src/views/email/record/detail.js b/client/src/views/email/record/detail.js
index 128a4038bf..76dd0730f3 100644
--- a/client/src/views/email/record/detail.js
+++ b/client/src/views/email/record/detail.js
@@ -361,10 +361,23 @@ class EmailDetailRecordView extends DetailRecordView {
}
actionMoveToFolder() {
+ let currentFolderId = undefined;
+
+ if (!this.isInArchive() && !this.isInTrash()) {
+ if (this.model.attributes.groupFolderId) {
+ currentFolderId = 'group:' + this.model.attributes.groupFolderId;
+ } else if (this.model.attributes.folderId) {
+ currentFolderId = this.model.attributes.folderId;
+ }
+ } else if (this.isInArchive()) {
+ currentFolderId = 'archive';
+ }
+
this.createView('dialog', 'views/email-folder/modals/select-folder', {
headerText: this.translate('Move to Folder', 'labels', 'Email'),
isGroup: !!this.model.attributes.groupFolderId || !this.model.attributes.isUsers,
noArchive: !this.model.attributes.groupFolderId && !this.model.attributes.isUsers,
+ currentFolderId: currentFolderId,
}, view => {
view.render();
diff --git a/client/src/views/email/record/list.js b/client/src/views/email/record/list.js
index 666e7705cb..bfa94873b4 100644
--- a/client/src/views/email/record/list.js
+++ b/client/src/views/email/record/list.js
@@ -344,6 +344,7 @@ class EmailListRecordView extends ListRecordView {
headerText: this.translate('Move to Folder', 'labels', 'Email'),
isGroup: selectedFolderId && (selectedFolderId.startsWith('group:') || selectedFolderId === 'all'),
noArchive: selectedFolderId === 'all',
+ currentFolderId: this.rootData.selectedFolderId,
}, view => {
view.render();
@@ -531,10 +532,13 @@ class EmailListRecordView extends ListRecordView {
return;
}
+ const currentFolderId = this.rootData.selectedFolderId;
+
this.createView('dialog', 'views/email-folder/modals/select-folder', {
headerText: this.translate('Move to Folder', 'labels', 'Email'),
isGroup: !!model.attributes.groupFolderId || !model.attributes.isUsers,
noArchive: !model.attributes.groupFolderId && !model.attributes.isUsers,
+ currentFolderId: currentFolderId,
}, view => {
view.render();