From 948663519e8184e2b91c3575337d57e5d14a7d5d Mon Sep 17 00:00:00 2001 From: djmaze Date: Tue, 3 Nov 2020 16:11:04 +0100 Subject: [PATCH] Cleanup js components --- dev/Component/AbstractCheckbox.js | 12 +++---- dev/Component/AbstractRadio.js | 35 ------------------- dev/Component/Date.js | 6 ---- dev/Component/Radio.js | 6 ---- dev/Component/TextArea.js | 2 +- .../Views/User/SettingsAccounts.html | 2 -- 6 files changed, 7 insertions(+), 56 deletions(-) delete mode 100644 dev/Component/AbstractRadio.js delete mode 100644 dev/Component/Date.js delete mode 100644 dev/Component/Radio.js diff --git a/dev/Component/AbstractCheckbox.js b/dev/Component/AbstractCheckbox.js index 95fa0af95..1cf3e7e13 100644 --- a/dev/Component/AbstractCheckbox.js +++ b/dev/Component/AbstractCheckbox.js @@ -10,24 +10,24 @@ class AbstractCheckbox extends AbstractComponent { this.value = params.value; if (undefined === this.value || !this.value.subscribe) { - this.value = ko.observable(undefined === this.value ? false : !!this.value); + this.value = ko.observable(!!this.value); } this.enable = params.enable; if (undefined === this.enable || !this.enable.subscribe) { - this.enable = ko.observable(undefined === this.enable ? true : !!this.enable); + this.enable = ko.observable(undefined === this.enable || !!this.enable); } this.disable = params.disable; if (undefined === this.disable || !this.disable.subscribe) { - this.disable = ko.observable(undefined === this.disable ? false : !!this.disable); + this.disable = ko.observable(!!this.disable); } this.label = params.label || ''; - this.inline = undefined === params.inline ? false : params.inline; + this.inline = !!params.inline; - this.readOnly = undefined === params.readOnly ? false : !!params.readOnly; - this.inverted = undefined === params.inverted ? false : !!params.inverted; + this.readOnly = !!params.readOnly; + this.inverted = !!params.inverted; this.labeled = undefined !== params.label; this.labelAnimated = !!params.labelAnimated; diff --git a/dev/Component/AbstractRadio.js b/dev/Component/AbstractRadio.js deleted file mode 100644 index 8a70034b3..000000000 --- a/dev/Component/AbstractRadio.js +++ /dev/null @@ -1,35 +0,0 @@ -import ko from 'ko'; -import { AbstractComponent } from 'Component/Abstract'; - -class AbstractRadio extends AbstractComponent { - /** - * @param {Object} params - */ - constructor(params) { - super(); - - this.values = ko.observableArray([]); - - this.value = params.value; - if (undefined === this.value || !this.value.subscribe) { - this.value = ko.observable(''); - } - - this.inline = undefined === params.inline ? false : params.inline; - this.readOnly = undefined === params.readOnly ? false : !!params.readOnly; - - if (params.values) { - this.values(Object.entries(params.values).map((label, value) => ({ label: label, value: value }))); - } - - this.click = this.click.bind(this); - } - - click(value) { - if (!this.readOnly && value) { - this.value(value.value); - } - } -} - -export { AbstractRadio, AbstractRadio as default }; diff --git a/dev/Component/Date.js b/dev/Component/Date.js deleted file mode 100644 index fe1a60e4a..000000000 --- a/dev/Component/Date.js +++ /dev/null @@ -1,6 +0,0 @@ -import { componentExportHelper } from 'Component/Abstract'; -import { AbstractInput } from 'Component/AbstractInput'; - -class DateComponent extends AbstractInput {} - -export default componentExportHelper(DateComponent, 'DateComponent'); diff --git a/dev/Component/Radio.js b/dev/Component/Radio.js deleted file mode 100644 index 8eed4b283..000000000 --- a/dev/Component/Radio.js +++ /dev/null @@ -1,6 +0,0 @@ -import { componentExportHelper } from 'Component/Abstract'; -import { AbstractRadio } from 'Component/AbstractRadio'; - -class RadioComponent extends AbstractRadio {} - -export default componentExportHelper(RadioComponent, 'RadioComponent'); diff --git a/dev/Component/TextArea.js b/dev/Component/TextArea.js index 0fe89399d..97d05d6b4 100644 --- a/dev/Component/TextArea.js +++ b/dev/Component/TextArea.js @@ -11,7 +11,7 @@ class TextAreaComponent extends AbstractInput { super(params); this.rows = params.rows || DEFAULT_ROWS; - this.spellcheck = undefined === params.spellcheck ? false : !!params.spellcheck; + this.spellcheck = !!params.spellcheck; } } diff --git a/snappymail/v/0.0.0/app/templates/Views/User/SettingsAccounts.html b/snappymail/v/0.0.0/app/templates/Views/User/SettingsAccounts.html index d283bf94d..e1ed63f13 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/SettingsAccounts.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/SettingsAccounts.html @@ -32,7 +32,6 @@ - @@ -83,7 +82,6 @@ -