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
|
|
|
|
2021-01-25 05:58:06 +08:00
|
|
|
import { SetSystemFoldersNotification } 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';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { initOnStartOrLangChange, 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';
|
|
|
|
|
|
|
|
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.sChooseOnText = '';
|
|
|
|
this.sUnuseText = '';
|
|
|
|
|
|
|
|
initOnStartOrLangChange(() => {
|
|
|
|
this.sChooseOnText = i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
|
|
|
this.sUnuseText = i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
|
|
|
});
|
|
|
|
|
|
|
|
this.notification = ko.observable('');
|
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
this.folderSelectList = koComputable(() =>
|
2019-07-05 03:19:24 +08:00
|
|
|
folderListOptionsBuilder(
|
2021-03-11 05:41:35 +08:00
|
|
|
FolderUserStore.folderListSystemNames(),
|
2019-12-25 03:05:46 +08:00
|
|
|
[
|
|
|
|
['', this.sChooseOnText],
|
|
|
|
[UNUSED_OPTION_VALUE, this.sUnuseText]
|
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
|
|
|
/**
|
|
|
|
* @param {number=} notificationType = SetSystemFoldersNotification.None
|
|
|
|
*/
|
|
|
|
onShow(notificationType = SetSystemFoldersNotification.None) {
|
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) {
|
2016-08-17 06:01:20 +08:00
|
|
|
case SetSystemFoldersNotification.Sent:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'SENT');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
case SetSystemFoldersNotification.Draft:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'DRAFTS');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
case SetSystemFoldersNotification.Spam:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'SPAM');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
case SetSystemFoldersNotification.Trash:
|
2021-01-26 18:46:30 +08:00
|
|
|
notification = i18n(prefix + 'TRASH');
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
case SetSystemFoldersNotification.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);
|
|
|
|
}
|
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { FolderSystemPopupView, FolderSystemPopupView as default };
|