mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Enable AbstractViewSettings
This commit is contained in:
parent
92cec80b73
commit
97bc3ef585
20 changed files with 149 additions and 212 deletions
|
|
@ -1,33 +1,30 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import {
|
||||
settingsSaveHelperSimpleFunction,
|
||||
defaultOptionsAfterRender
|
||||
} from 'Common/Utils';
|
||||
import { defaultOptionsAfterRender } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
||||
export class ContactsAdminSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
this.addSetting('ContactsPdoDsn');
|
||||
this.addSetting('ContactsPdoUser');
|
||||
this.addSetting('ContactsPdoPassword');
|
||||
this.addSetting('ContactsPdoType', () => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
});
|
||||
|
||||
addObservablesTo(this, {
|
||||
enableContacts: !!SettingsGet('ContactsEnable'),
|
||||
contactsSync: !!SettingsGet('ContactsSync'),
|
||||
contactsType: SettingsGet('ContactsPdoType'),
|
||||
|
||||
pdoDsn: SettingsGet('ContactsPdoDsn'),
|
||||
pdoUser: SettingsGet('ContactsPdoUser'),
|
||||
pdoPassword: SettingsGet('ContactsPdoPassword'),
|
||||
|
||||
pdoDsnTrigger: SaveSettingsStep.Idle,
|
||||
pdoUserTrigger: SaveSettingsStep.Idle,
|
||||
pdoPasswordTrigger: SaveSettingsStep.Idle,
|
||||
contactsTypeTrigger: SaveSettingsStep.Idle,
|
||||
|
||||
testing: false,
|
||||
testContactsSuccess: false,
|
||||
|
|
@ -53,16 +50,16 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.mainContactsType = ko
|
||||
.computed({
|
||||
read: this.contactsType,
|
||||
read: this.contactsPdoType,
|
||||
write: value => {
|
||||
if (value !== this.contactsType()) {
|
||||
if (value !== this.contactsPdoType()) {
|
||||
if (supportedTypes.includes(value)) {
|
||||
this.contactsType(value);
|
||||
this.contactsPdoType(value);
|
||||
} else if (types.length) {
|
||||
this.contactsType('');
|
||||
this.contactsPdoType('');
|
||||
}
|
||||
} else {
|
||||
this.contactsType.valueHasMutated();
|
||||
this.contactsPdoType.valueHasMutated();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -77,35 +74,11 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
contactsSync: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsSync: value ? 1 : 0
|
||||
}),
|
||||
|
||||
contactsType: value => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
Remote.saveConfig({
|
||||
ContactsPdoType: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this))
|
||||
},
|
||||
|
||||
pdoDsn: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoDsn: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this)),
|
||||
|
||||
pdoUser: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoUser: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this)),
|
||||
|
||||
pdoPassword: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoPassword: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this))
|
||||
})
|
||||
})
|
||||
|
||||
decorateKoCommands(this, {
|
||||
testContactsCommand: self => self.pdoDsn() && self.pdoUser()
|
||||
testContactsCommand: self => self.contactsPdoDsn() && self.contactsPdoUser()
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -134,10 +107,10 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.testing(false);
|
||||
}, {
|
||||
ContactsPdoType: this.contactsType(),
|
||||
ContactsPdoDsn: this.pdoDsn(),
|
||||
ContactsPdoUser: this.pdoUser(),
|
||||
ContactsPdoPassword: this.pdoPassword()
|
||||
ContactsPdoType: this.contactsPdoType(),
|
||||
ContactsPdoDsn: this.contactsPdoDsn(),
|
||||
ContactsPdoUser: this.contactsPdo(),
|
||||
ContactsPdoPassword: this.contactsPdoPassword()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue