diff --git a/dev/Common/Translator.js b/dev/Common/Translator.js index 554771901..f8201b412 100644 --- a/dev/Common/Translator.js +++ b/dev/Common/Translator.js @@ -2,6 +2,7 @@ import ko from 'ko'; import { Notification, UploadErrorCode } from 'Common/Enums'; import { langLink } from 'Common/Links'; import { doc, createElement } from 'Common/Globals'; +import { getKeyByValue } from 'Common/Utils'; let I18N_DATA = {}; @@ -39,8 +40,6 @@ const i18nKey = key => key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase(), - getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v), - getNotificationMessage = code => { let key = getKeyByValue(Notification, code); if (key) { diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 2688eaf3b..4fdeefc9d 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -93,4 +93,6 @@ export const }) .then(clearTimer, clearTimer); } - }; + }, + + getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v); diff --git a/dev/Model/FolderCollection.js b/dev/Model/FolderCollection.js index 73681b096..f31be3849 100644 --- a/dev/Model/FolderCollection.js +++ b/dev/Model/FolderCollection.js @@ -1,7 +1,7 @@ import { AbstractCollectionModel } from 'Model/AbstractCollection'; import { UNUSED_OPTION_VALUE } from 'Common/Consts'; -import { isArray, pInt } from 'Common/Utils'; +import { isArray, pInt, getKeyByValue } from 'Common/Utils'; import { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser'; import * as Cache from 'Common/Cache'; import { Settings, SettingsGet } from 'Common/Globals'; @@ -161,21 +161,31 @@ export class FolderCollectionModel extends AbstractCollectionModel } +function getKolabFolderName(type) +{ + const types = { + configuration: 'CONFIGURATION', + event: 'CALENDAR', + contact: 'CONTACTS', + task: 'TASKS', + note: 'NOTES', + file: 'FILES', + journal: 'JOURNAL' + }; + return types[type] ? 'Kolab ' + i18n('SETTINGS_FOLDERS/TYPE_' + types[type]) : ''; +} + function getSystemFolderName(type, def) { switch (type) { case FolderType.Inbox: - return i18n('FOLDER_LIST/INBOX_NAME'); case FolderType.Sent: - return i18n('FOLDER_LIST/SENT_NAME'); case FolderType.Drafts: - return i18n('FOLDER_LIST/DRAFTS_NAME'); + case FolderType.Trash: + case FolderType.Archive: + return i18n('FOLDER_LIST/' + getKeyByValue(FolderType, type).toUpperCase() + '_NAME'); case FolderType.Spam: return i18n('GLOBAL/SPAM'); - case FolderType.Trash: - return i18n('FOLDER_LIST/TRASH_NAME'); - case FolderType.Archive: - return i18n('FOLDER_LIST/ARCHIVE_NAME'); // no default } return def; @@ -287,7 +297,7 @@ export class FolderModel extends AbstractModel { visible: () => folder.hasSubscriptions() | !SettingsUserStore.hideUnsubscribed(), - isSystemFolder: () => FolderType.User !== folder.type(), + isSystemFolder: () => FolderType.User !== folder.type() || !!folder.kolabType(), hidden: () => { let hasSubFolders = folder.hasSubscribedSubfolders(); @@ -335,12 +345,11 @@ export class FolderModel extends AbstractModel { manageFolderSystemName: () => { if (folder.isSystemFolder()) { translatorTrigger(); - let suffix = getSystemFolderName(folder.type(), ''); + let suffix = getSystemFolderName(folder.type(), getKolabFolderName(folder.kolabType())); if (folder.name() !== suffix && 'inbox' !== suffix.toLowerCase()) { return '(' + suffix + ')'; } } - return ''; },