some ko.computed() to addComputables()/addComputablesTo()

This commit is contained in:
djmaze 2021-09-03 16:37:20 +02:00
parent 099560ca6a
commit 023c8f603b
9 changed files with 110 additions and 107 deletions

View file

@ -1,5 +1,3 @@
import ko from 'ko';
import { getNotification } from 'Common/Translator';
import { DomainAdminStore } from 'Stores/Admin/Domain';
@ -22,11 +20,13 @@ class DomainAliasPopupView extends AbstractViewPopup {
alias: ''
});
this.domains = ko.computed(() => DomainAdminStore.filter(item => item && !item.alias));
this.addComputables({
domains: () => DomainAdminStore.filter(item => item && !item.alias),
this.domainsOptions = ko.computed(() => this.domains().map(item => ({ optValue: item.name, optText: item.name })));
domainsOptions: () => this.domains().map(item => ({ optValue: item.name, optText: item.name })),
this.canBeSaved = ko.computed(() => !this.saving() && this.name() && this.alias());
canBeSaved: () => !this.saving() && this.name() && this.alias()
});
decorateKoCommands(this, {
createCommand: self => self.canBeSaved()

View file

@ -23,8 +23,10 @@ class PluginPopupView extends AbstractViewPopup {
this.configures = ko.observableArray();
this.hasReadme = ko.computed(() => !!this.readme());
this.hasConfiguration = ko.computed(() => 0 < this.configures().length);
this.addComputables({
hasReadme: () => !!this.readme(),
hasConfiguration: () => 0 < this.configures().length
});
this.bDisabeCloseOnEsc = true;
this.sDefaultScope = Scope.All;

View file

@ -66,8 +66,6 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
this.allowMessageListActions = Settings.capa(Capa.MessageListActions);
this.allowDangerousActions = Settings.capa(Capa.DangerousActions);
this.popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length);
this.messageList = MessageUserStore.list;
this.sortSupported = FolderUserStore.sortSupported;
@ -78,13 +76,17 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
this.isMessageSelected = MessageUserStore.isMessageSelected;
this.messageListSearch = MessageUserStore.listSearch;
this.messageListError = MessageUserStore.listError;
this.folderMenuForMove = ko.computed(() =>
folderListOptionsBuilder(
[FolderUserStore.currentFolderFullNameRaw()],
[],
item => item ? item.localName() : ''
)
);
this.addComputables({
popupVisibility: () => 0 < popupVisibilityNames().length,
folderMenuForMove: () =>
folderListOptionsBuilder(
[FolderUserStore.currentFolderFullNameRaw()],
[],
item => item ? item.localName() : ''
)
});
this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList;