mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Drop the mostly unused InputComponent and use normal <input>
This commit is contained in:
parent
b28d818c86
commit
8ea778a8d4
12 changed files with 67 additions and 130 deletions
|
|
@ -1,13 +1,55 @@
|
|||
import { i18n } from 'Common/Translator';
|
||||
import { pInt } from 'Common/Utils';
|
||||
import { SaveSettingStatus } from 'Common/Enums';
|
||||
import { koComputable } from 'External/ko';
|
||||
import { dispose } from 'External/ko';
|
||||
import { defaultOptionsAfterRender } from 'Common/Utils';
|
||||
import { AbstractInput } from 'Component/AbstractInput';
|
||||
|
||||
export class SelectComponent extends AbstractInput {
|
||||
export class SelectComponent {
|
||||
/**
|
||||
* @param {Object} params
|
||||
*/
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this.value = params.value || '';
|
||||
this.label = params.label || '';
|
||||
this.enable = null == params.enable ? true : params.enable;
|
||||
this.trigger = params.trigger?.subscribe ? params.trigger : null;
|
||||
this.placeholder = params.placeholder || '';
|
||||
|
||||
this.labeled = null != params.label;
|
||||
|
||||
let size = 0 < params.size ? 'span' + params.size : '';
|
||||
if (this.trigger) {
|
||||
const
|
||||
classForTrigger = ko.observable(''),
|
||||
setTriggerState = value => {
|
||||
switch (pInt(value)) {
|
||||
case SaveSettingStatus.Success:
|
||||
classForTrigger('success');
|
||||
break;
|
||||
case SaveSettingStatus.Failed:
|
||||
classForTrigger('error');
|
||||
break;
|
||||
default:
|
||||
classForTrigger('');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
setTriggerState(this.trigger());
|
||||
|
||||
this.className = koComputable(() =>
|
||||
(size + ' settings-save-trigger-input ' + classForTrigger()).trim()
|
||||
);
|
||||
|
||||
this.disposables = [
|
||||
this.trigger.subscribe(setTriggerState, this),
|
||||
this.className
|
||||
];
|
||||
} else {
|
||||
this.className = size;
|
||||
this.disposables = [];
|
||||
}
|
||||
|
||||
this.options = params.options || '';
|
||||
|
||||
|
|
@ -17,4 +59,8 @@ export class SelectComponent extends AbstractInput {
|
|||
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.disposables.forEach(dispose);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue