2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2022-02-17 16:36:29 +08:00
|
|
|
import { koComputable, addSubscribablesTo } from 'External/ko';
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2022-12-15 20:49:39 +08:00
|
|
|
import { FolderType } from 'Common/EnumsUser';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
2022-02-17 16:36:29 +08:00
|
|
|
import { defaultOptionsAfterRender } from 'Common/Utils';
|
2022-02-24 02:26:52 +08:00
|
|
|
import { folderListOptionsBuilder } from 'Common/Folders';
|
2022-02-24 21:01:41 +08:00
|
|
|
import { i18n } from 'Common/Translator';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
import { FolderUserStore } from 'Stores/User/Folder';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-01-24 17:25:23 +08:00
|
|
|
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|
|
|
|
2022-02-24 21:01:41 +08:00
|
|
|
export class FolderSystemPopupView extends AbstractViewPopup {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-24 17:25:23 +08:00
|
|
|
super('FolderSystem');
|
2016-08-17 06:01:20 +08:00
|
|
|
|
|
|
|
this.notification = ko.observable('');
|
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
this.folderSelectList = koComputable(() =>
|
2019-07-05 03:19:24 +08:00
|
|
|
folderListOptionsBuilder(
|
2022-08-03 17:06:09 +08:00
|
|
|
FolderUserStore.systemFoldersNames(),
|
2019-12-25 03:05:46 +08:00
|
|
|
[
|
2022-02-24 21:01:41 +08:00
|
|
|
['', i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE')],
|
|
|
|
[UNUSED_OPTION_VALUE, i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME')]
|
2021-08-19 21:14:47 +08:00
|
|
|
]
|
2019-07-05 03:19:24 +08:00
|
|
|
)
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.sentFolder = FolderUserStore.sentFolder;
|
2021-12-01 20:54:35 +08:00
|
|
|
this.draftsFolder = FolderUserStore.draftsFolder;
|
2021-03-11 05:41:35 +08:00
|
|
|
this.spamFolder = FolderUserStore.spamFolder;
|
|
|
|
this.trashFolder = FolderUserStore.trashFolder;
|
|
|
|
this.archiveFolder = FolderUserStore.archiveFolder;
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2021-08-24 21:53:39 +08:00
|
|
|
const fSaveSystemFolders = (()=>FolderUserStore.saveSystemFolders()).debounce(1000);
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2021-03-16 17:59:47 +08:00
|
|
|
addSubscribablesTo(FolderUserStore, {
|
2021-08-24 21:53:39 +08:00
|
|
|
sentFolder: fSaveSystemFolders,
|
2021-12-01 20:54:35 +08:00
|
|
|
draftsFolder: fSaveSystemFolders,
|
2021-08-24 21:53:39 +08:00
|
|
|
spamFolder: fSaveSystemFolders,
|
|
|
|
trashFolder: fSaveSystemFolders,
|
|
|
|
archiveFolder: fSaveSystemFolders
|
2020-10-26 19:54:03 +08:00
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-10-15 01:16:37 +08:00
|
|
|
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
2022-12-15 20:49:39 +08:00
|
|
|
* @param {number=} notificationType = 0
|
2016-08-17 06:01:20 +08:00
|
|
|
*/
|
2022-12-15 20:49:39 +08:00
|
|
|
onShow(notificationType = 0) {
|
2021-01-26 18:46:30 +08:00
|
|
|
let notification = '', prefix = 'POPUPS_SYSTEM_FOLDERS/NOTIFICATION_';
|
2019-07-05 03:19:24 +08:00
|
|
|
switch (notificationType) {
|
2022-12-15 20:49:39 +08:00
|
|
|
case FolderType.Sent:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'SENT');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
2022-12-15 20:49:39 +08:00
|
|
|
case FolderType.Drafts:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'DRAFTS');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
2022-12-15 20:49:39 +08:00
|
|
|
case FolderType.Junk:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'SPAM');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
2022-12-15 20:49:39 +08:00
|
|
|
case FolderType.Trash:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'TRASH');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
2022-12-15 20:49:39 +08:00
|
|
|
case FolderType.Archive:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'ARCHIVE');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
// no default
|
|
|
|
}
|
|
|
|
|
|
|
|
this.notification(notification);
|
|
|
|
}
|
|
|
|
}
|