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;