2019-07-05 03:19:24 +08:00
|
|
|
import { SaveSettingsStep } from 'Common/Enums';
|
2021-01-27 17:59:15 +08:00
|
|
|
import { AbstractComponent } from 'Component/Abstract';
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2021-01-27 17:59:15 +08:00
|
|
|
export class SaveTriggerComponent extends AbstractComponent {
|
2015-11-15 08:23:16 +08:00
|
|
|
/**
|
|
|
|
* @param {Object} params
|
|
|
|
*/
|
|
|
|
constructor(params) {
|
|
|
|
super();
|
|
|
|
|
2020-08-31 18:45:43 +08:00
|
|
|
const el = params.element;
|
|
|
|
this.element = el || null;
|
2015-11-15 08:23:16 +08:00
|
|
|
this.value = params.value && params.value.subscribe ? params.value : null;
|
|
|
|
|
2020-08-31 18:45:43 +08:00
|
|
|
if (el) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (this.value) {
|
2020-08-31 18:45:43 +08:00
|
|
|
el.style.display = 'inline-block';
|
2015-11-15 08:23:16 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (params.verticalAlign) {
|
2020-08-31 18:45:43 +08:00
|
|
|
el.style.verticalAlign = params.verticalAlign;
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
this.setState(this.value());
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.disposable.push(this.value.subscribe(this.setState, this));
|
|
|
|
} else {
|
2020-08-31 18:45:43 +08:00
|
|
|
el.style.display = 'none';
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(value) {
|
2020-08-31 18:45:43 +08:00
|
|
|
value = parseInt(value,10);
|
2021-02-05 05:47:38 +08:00
|
|
|
this.element.querySelector('.icon-spinner').hidden = value !== SaveSettingsStep.Animate;
|
2020-08-31 18:45:43 +08:00
|
|
|
this.element.querySelector('.success').hidden = value !== SaveSettingsStep.TrueResult;
|
|
|
|
this.element.querySelector('.error').hidden = value !== SaveSettingsStep.FalseResult;
|
2016-04-21 01:12:51 +08:00
|
|
|
}
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|