mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
Cleanup function folderListOptionsBuilder()
This commit is contained in:
parent
36b66c3ec5
commit
650e962fdf
4 changed files with 37 additions and 55 deletions
|
@ -216,9 +216,7 @@ rl.Utils = {
|
|||
* @param {Array} aList
|
||||
* @param {Array=} aDisabled
|
||||
* @param {Array=} aHeaderLines
|
||||
* @param {?number=} iUnDeep
|
||||
* @param {Function=} fDisableCallback
|
||||
* @param {Function=} fVisibleCallback
|
||||
* @param {Function=} fRenameCallback
|
||||
* @param {boolean=} bSystem
|
||||
* @param {boolean=} bBuildUnvisible
|
||||
|
@ -229,9 +227,7 @@ export function folderListOptionsBuilder(
|
|||
aList,
|
||||
aDisabled,
|
||||
aHeaderLines,
|
||||
iUnDeep,
|
||||
fDisableCallback,
|
||||
fVisibleCallback,
|
||||
fRenameCallback,
|
||||
bSystem,
|
||||
bBuildUnvisible
|
||||
|
@ -246,9 +242,7 @@ export function folderListOptionsBuilder(
|
|||
|
||||
bBuildUnvisible = undefined === bBuildUnvisible ? false : !!bBuildUnvisible;
|
||||
bSystem = null == bSystem ? 0 < aSystem.length : bSystem;
|
||||
iUnDeep = null == iUnDeep ? 0 : iUnDeep;
|
||||
fDisableCallback = null != fDisableCallback ? fDisableCallback : null;
|
||||
fVisibleCallback = null != fVisibleCallback ? fVisibleCallback : null;
|
||||
fRenameCallback = null != fRenameCallback ? fRenameCallback : null;
|
||||
|
||||
if (!isArray(aDisabled)) {
|
||||
|
@ -271,19 +265,17 @@ export function folderListOptionsBuilder(
|
|||
|
||||
bSep = true;
|
||||
aSystem.forEach(oItem => {
|
||||
if (fVisibleCallback ? fVisibleCallback(oItem) : true) {
|
||||
aResult.push({
|
||||
id: oItem.fullNameRaw,
|
||||
name: fRenameCallback ? fRenameCallback(oItem) : oItem.name(),
|
||||
system: true,
|
||||
dividerbar: bSep,
|
||||
disabled:
|
||||
!oItem.selectable ||
|
||||
aDisabled.includes(oItem.fullNameRaw) ||
|
||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||
});
|
||||
bSep = false;
|
||||
}
|
||||
aResult.push({
|
||||
id: oItem.fullNameRaw,
|
||||
name: fRenameCallback ? fRenameCallback(oItem) : oItem.name(),
|
||||
system: true,
|
||||
dividerbar: bSep,
|
||||
disabled:
|
||||
!oItem.selectable ||
|
||||
aDisabled.includes(oItem.fullNameRaw) ||
|
||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||
});
|
||||
bSep = false;
|
||||
});
|
||||
|
||||
bSep = true;
|
||||
|
@ -293,22 +285,20 @@ export function folderListOptionsBuilder(
|
|||
(oItem.subscribed() || !oItem.exists || bBuildUnvisible) &&
|
||||
(oItem.selectable || oItem.hasSubscribedSubfolders())
|
||||
) {
|
||||
if (fVisibleCallback ? fVisibleCallback(oItem) : true) {
|
||||
if (FolderType.User === oItem.type() || !bSystem || oItem.hasSubscribedSubfolders()) {
|
||||
aResult.push({
|
||||
id: oItem.fullNameRaw,
|
||||
name:
|
||||
new Array(oItem.deep + 1 - iUnDeep).join(sDeepPrefix) +
|
||||
(fRenameCallback ? fRenameCallback(oItem) : oItem.name()),
|
||||
system: false,
|
||||
dividerbar: bSep,
|
||||
disabled:
|
||||
!oItem.selectable ||
|
||||
aDisabled.includes(oItem.fullNameRaw) ||
|
||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||
});
|
||||
bSep = false;
|
||||
}
|
||||
if (FolderType.User === oItem.type() || !bSystem || oItem.hasSubscribedSubfolders()) {
|
||||
aResult.push({
|
||||
id: oItem.fullNameRaw,
|
||||
name:
|
||||
sDeepPrefix.repeat(oItem.deep + 1) +
|
||||
(fRenameCallback ? fRenameCallback(oItem) : oItem.name()),
|
||||
system: false,
|
||||
dividerbar: bSep,
|
||||
disabled:
|
||||
!oItem.selectable ||
|
||||
aDisabled.includes(oItem.fullNameRaw) ||
|
||||
(fDisableCallback ? fDisableCallback(oItem) : false)
|
||||
});
|
||||
bSep = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,9 +309,7 @@ export function folderListOptionsBuilder(
|
|||
oItem.subFolders(),
|
||||
aDisabled,
|
||||
[],
|
||||
iUnDeep,
|
||||
fDisableCallback,
|
||||
fVisibleCallback,
|
||||
fRenameCallback,
|
||||
bSystem,
|
||||
bBuildUnvisible
|
||||
|
|
|
@ -104,9 +104,7 @@ export const FolderUserStore = new class {
|
|||
this.folderListSystem(),
|
||||
this.folderList(),
|
||||
[this.currentFolderFullNameRaw()],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
null,
|
||||
(item) => (item ? item.localName() : '')
|
||||
)
|
||||
|
@ -119,8 +117,6 @@ export const FolderUserStore = new class {
|
|||
[this.sieveAllowFileintoInbox ? '' : 'INBOX'],
|
||||
[['', '']],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(item) => (item ? item.localName() : '')
|
||||
)
|
||||
);
|
||||
|
|
|
@ -23,19 +23,19 @@ class FolderCreatePopupView extends AbstractViewPopup {
|
|||
selectedParentValue: UNUSED_OPTION_VALUE
|
||||
});
|
||||
|
||||
this.parentFolderSelectList = ko.computed(() => {
|
||||
const top = [],
|
||||
list = FolderUserStore.folderList(),
|
||||
fDisableCallback = FolderUserStore.namespace
|
||||
this.parentFolderSelectList = ko.computed(() =>
|
||||
folderListOptionsBuilder(
|
||||
[],
|
||||
FolderUserStore.folderList(),
|
||||
[],
|
||||
[['', '']],
|
||||
FolderUserStore.namespace
|
||||
? item => FolderUserStore.namespace !== item.fullNameRaw.substr(0, FolderUserStore.namespace.length)
|
||||
: null,
|
||||
fRenameCallback = oItem =>
|
||||
oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
|
||||
top.push(['', '']);
|
||||
|
||||
return folderListOptionsBuilder([], list, [], top, null, fDisableCallback, null, fRenameCallback);
|
||||
});
|
||||
oItem =>
|
||||
oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : ''
|
||||
)
|
||||
);
|
||||
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ class FolderSystemPopupView extends AbstractViewPopup {
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue