armisa-models
Version:
models of armisa!
67 lines (56 loc) • 1.46 kB
text/typescript
import { BaseSelfControl } from './BaseSelfControl';
export class SelfBoolean extends BaseSelfControl<
boolean,
boolean,
boolean,
HTMLDivElement
> {
isValueEmpty = () => {
return typeof this.value !== 'boolean';
}
isValueNotEmpty = () => {
return !this.isValueEmpty();
}
public validate = () => {
this.validation = true;
};
public cleaningClassInitializer = () => {
this.hasChange = false;
this.defaultValue = undefined;
this.initializeListener = false;
this.validation = true;
};
public refreshHasChange = () => {
if (this.showHasChangeFlag) {
this.hasChange = this.defaultValue !== this.#value;
}
};
public restartDefaultValue = () => {
this.defaultValue = this.value;
this.refreshHasChange();
};
#value: boolean;
public get value() {
return this.#value;
}
public set value(value: boolean) { }
public setValue = (value: boolean) => {
this.#value = value;
this.refreshHasChange();
};
public deserialize = (value: boolean) => {
this.#value = value;
this.restartDefaultValue();
};
constructor(value: boolean) {
super();
this.#value = value;
this.restartDefaultValue();
}
static empty(): SelfBoolean {
return new SelfBoolean(false);
}
static deserialize(value?: boolean): SelfBoolean {
return new SelfBoolean(value || false);
}
}