armisa-models
Version:
models of armisa!
68 lines (55 loc) • 1.93 kB
text/typescript
import { ElementFactory } from "../Page/ElementsOfFormFactory/ElementFactory";
import { IMainStateFactory } from "../Types";
import { Cach } from "./Cach";
export class SidbarFactory extends ElementFactory {
public restartDefaultValue = () => { };
public refreshHasChange = () => { };
public validate = () => { };
public deseriallize = (jsonValue: any) => { };
public clearData = () => { };
public isActiveItem = (slidItemFactory: SidItemFactory) => {
return this.#value === slidItemFactory;
}
public forceUpdate = () => { };
public items: SidItemFactory[] = [];
public addNewItem = (caption: string, value: number, icon?: string) => {
this.items.push(new SidItemFactory(this, caption, value, icon));
}
#value: SidItemFactory | null = null;
public get value() {
return this.#value?.value || null;
}
public setValue = (value: SidItemFactory) => {
this.#value = value;
Cach.setValue(this, this.#value);
this.forceUpdate();
};
#defaultValue: SidItemFactory | null = null;
public get defaultValue() {
return this.#defaultValue;
}
constructor(
_mainStateFactory: IMainStateFactory,
_fieldName: string,
_dispose: () => void,
public tabIndex?: number,
payLoadKey?: string,
) {
super(_mainStateFactory, _fieldName, _dispose, payLoadKey);
if (Cach.isCached(this)) {
const cach = Cach.getCached(this);
this.#value = cach.value;
this.validation = cach.validation;
this._hasChange = cach.hasChange;
}
}
}
export class SidItemFactory {
constructor(
public SlidbarFactory: SidbarFactory,
public caption: string,
public value: number,
public icon?: string,
) {
}
}