mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Drop ko.extenders.limitedList
This commit is contained in:
parent
deeb86bd5f
commit
d1d820da73
8 changed files with 14 additions and 77 deletions
|
|
@ -28,22 +28,6 @@ export const FolderMetadataKeys = {
|
||||||
KolabFolderTypeShared: '/shared/vendor/kolab/folder-type'
|
KolabFolderTypeShared: '/shared/vendor/kolab/folder-type'
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export const FolderSortMode = {
|
|
||||||
DateDesc: '', // default 'REVERSE DATE'
|
|
||||||
DateAsc: 'DATE',
|
|
||||||
FromDesc: 'REVERSE FROM',
|
|
||||||
FromAsc: 'FROM',
|
|
||||||
SizeDesc: 'REVERSE SIZE',
|
|
||||||
SizeAsc: 'SIZE',
|
|
||||||
SubjectDesc: 'REVERSE SUBJECT',
|
|
||||||
SubjectAsc: 'SUBJECT'
|
|
||||||
// ToDesc: 'REVERSE TO',
|
|
||||||
// ToAsc: 'TO',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
24
dev/External/ko.js
vendored
24
dev/External/ko.js
vendored
|
|
@ -2,7 +2,7 @@ import ko from 'ko';
|
||||||
import { i18nToNodes } from 'Common/Translator';
|
import { i18nToNodes } from 'Common/Translator';
|
||||||
import { doc, createElement } from 'Common/Globals';
|
import { doc, createElement } from 'Common/Globals';
|
||||||
import { SaveSettingsStep } from 'Common/Enums';
|
import { SaveSettingsStep } from 'Common/Enums';
|
||||||
import { arrayLength, isFunction, forEachObjectEntry } from 'Common/Utils';
|
import { isFunction, forEachObjectEntry } from 'Common/Utils';
|
||||||
|
|
||||||
export const
|
export const
|
||||||
errorTip = (element, value) => value
|
errorTip = (element, value) => value
|
||||||
|
|
@ -146,28 +146,6 @@ Object.assign(ko.bindingHandlers, {
|
||||||
|
|
||||||
// extenders
|
// extenders
|
||||||
|
|
||||||
ko.extenders.limitedList = (target, limitedList) => {
|
|
||||||
const result = ko
|
|
||||||
.computed({
|
|
||||||
read: target,
|
|
||||||
write: newValue => {
|
|
||||||
let currentValue = target(),
|
|
||||||
list = ko.unwrap(limitedList);
|
|
||||||
list = arrayLength(list) ? list : [''];
|
|
||||||
if (!list.includes(newValue)) {
|
|
||||||
newValue = list.includes(currentValue, list) ? currentValue : list[0];
|
|
||||||
target(newValue + ' ');
|
|
||||||
}
|
|
||||||
target(newValue);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.extend({ notify: 'always' });
|
|
||||||
|
|
||||||
result(target());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.toggleSubscribeProperty = (target, options) => {
|
ko.extenders.toggleSubscribeProperty = (target, options) => {
|
||||||
const prop = options[1];
|
const prop = options[1];
|
||||||
if (prop) {
|
if (prop) {
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,7 @@ export class AdminSettingsGeneral extends AbstractViewSettings {
|
||||||
|
|
||||||
const aLanguagesAdmin = Settings.app('languagesAdmin');
|
const aLanguagesAdmin = Settings.app('languagesAdmin');
|
||||||
this.languagesAdmin = ko.observableArray(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
this.languagesAdmin = ko.observableArray(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
||||||
this.languageAdmin = ko
|
this.languageAdmin = ko.observable(SettingsGet('LanguageAdmin'));
|
||||||
.observable(SettingsGet('LanguageAdmin'))
|
|
||||||
.extend({ limitedList: this.languagesAdmin });
|
|
||||||
|
|
||||||
this.theme = ThemeStore.theme;
|
this.theme = ThemeStore.theme;
|
||||||
this.themes = ThemeStore.themes;
|
this.themes = ThemeStore.themes;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { Settings, SettingsGet } from 'Common/Globals';
|
||||||
import { isArray } from 'Common/Utils';
|
import { isArray } from 'Common/Utils';
|
||||||
|
|
||||||
export const LanguageStore = {
|
export const LanguageStore = {
|
||||||
|
language: ko.observable(''),
|
||||||
languages: ko.observableArray(),
|
languages: ko.observableArray(),
|
||||||
userLanguage: ko.observable(''),
|
userLanguage: ko.observable(''),
|
||||||
|
|
||||||
|
|
@ -13,6 +14,3 @@ export const LanguageStore = {
|
||||||
this.userLanguage(SettingsGet('UserLanguage'));
|
this.userLanguage(SettingsGet('UserLanguage'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageStore.language = ko.observable('')
|
|
||||||
.extend({ limitedList: LanguageStore.languages });
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { isArray } from 'Common/Utils';
|
||||||
import { serverRequestRaw } from 'Common/Links';
|
import { serverRequestRaw } from 'Common/Links';
|
||||||
|
|
||||||
export const ThemeStore = {
|
export const ThemeStore = {
|
||||||
|
theme: ko.observable(''),
|
||||||
themes: ko.observableArray(),
|
themes: ko.observableArray(),
|
||||||
userBackgroundName: ko.observable(''),
|
userBackgroundName: ko.observable(''),
|
||||||
userBackgroundHash: ko.observable(''),
|
userBackgroundHash: ko.observable(''),
|
||||||
|
|
@ -23,8 +24,6 @@ export const ThemeStore = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ThemeStore.theme = ko.observable('').extend({ limitedList: ThemeStore.themes });
|
|
||||||
|
|
||||||
ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
|
ThemeStore.isMobile.subscribe(value => $htmlCL.toggle('rl-mobile', value));
|
||||||
|
|
||||||
ThemeStore.userBackgroundHash.subscribe(value => {
|
ThemeStore.userBackgroundHash.subscribe(value => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { koComputable } from 'External/ko';
|
import { koComputable } from 'External/ko';
|
||||||
|
|
||||||
import { FolderType, FolderSortMode } from 'Common/EnumsUser';
|
import { FolderType } from 'Common/EnumsUser';
|
||||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||||
import { forEachObjectEntry } from 'Common/Utils';
|
import { forEachObjectEntry } from 'Common/Utils';
|
||||||
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
|
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||||
|
|
@ -44,7 +44,7 @@ export const FolderUserStore = new class {
|
||||||
foldersInboxUnreadCount: 0
|
foldersInboxUnreadCount: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
self.sortMode = ko.observable('').extend({ limitedList: Object.values(FolderSortMode) });
|
self.sortMode = ko.observable('');
|
||||||
|
|
||||||
self.namespace = '';
|
self.namespace = '';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { koComputable } from 'External/ko';
|
import { koComputable } from 'External/ko';
|
||||||
|
|
||||||
import { Layout, EditorDefaultType, ComposeType } from 'Common/EnumsUser';
|
import { Layout } from 'Common/EnumsUser';
|
||||||
import { pInt } from 'Common/Utils';
|
import { pInt } from 'Common/Utils';
|
||||||
import { addObservablesTo } from 'External/ko';
|
import { addObservablesTo } from 'External/ko';
|
||||||
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
|
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
|
||||||
|
|
@ -11,24 +11,6 @@ export const SettingsUserStore = new class {
|
||||||
constructor() {
|
constructor() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
self.layout = ko
|
|
||||||
.observable(1)
|
|
||||||
.extend({ limitedList: Object.values(Layout) });
|
|
||||||
|
|
||||||
self.editorDefaultType = ko.observable('Html').extend({
|
|
||||||
limitedList: [
|
|
||||||
EditorDefaultType.Html,
|
|
||||||
EditorDefaultType.Plain
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
self.msgDefaultAction = ko.observable(1).extend({
|
|
||||||
limitedList: [
|
|
||||||
ComposeType.Reply,
|
|
||||||
ComposeType.ReplyAll
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
self.messagesPerPage = ko.observable(25).extend({ debounce: 999 });
|
self.messagesPerPage = ko.observable(25).extend({ debounce: 999 });
|
||||||
|
|
||||||
self.messageReadDelay = ko.observable(5).extend({ debounce: 999 });
|
self.messageReadDelay = ko.observable(5).extend({ debounce: 999 });
|
||||||
|
|
@ -48,7 +30,11 @@ export const SettingsUserStore = new class {
|
||||||
requestReadReceipt: 0,
|
requestReadReceipt: 0,
|
||||||
requestDsn: 0,
|
requestDsn: 0,
|
||||||
pgpSign: 0,
|
pgpSign: 0,
|
||||||
pgpEncrypt: 0
|
pgpEncrypt: 0,
|
||||||
|
|
||||||
|
layout: 1,
|
||||||
|
editorDefaultType: 'Html',
|
||||||
|
msgDefaultAction: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
self.init();
|
self.init();
|
||||||
|
|
|
||||||
|
|
@ -126,10 +126,7 @@ const
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isPlainEditor = () => {
|
isPlainEditor = () => EditorDefaultType.Plain === SettingsUserStore.editorDefaultType(),
|
||||||
let type = SettingsUserStore.editorDefaultType();
|
|
||||||
return EditorDefaultType.Html !== type;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} prefix
|
* @param {string} prefix
|
||||||
|
|
@ -966,10 +963,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
this.editor(editor => {
|
this.editor(editor => {
|
||||||
encrypted || editor.setHtml(sText);
|
encrypted || editor.setHtml(sText);
|
||||||
|
|
||||||
if (encrypted
|
if (encrypted || this.isPlainEditor() || !message.isHtml()) {
|
||||||
|| EditorDefaultType.Plain === SettingsUserStore.editorDefaultType()
|
|
||||||
|| !message.isHtml()
|
|
||||||
) {
|
|
||||||
editor.modePlain();
|
editor.modePlain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue