armisa-models
Version:
models of armisa!
81 lines (80 loc) • 3.83 kB
JavaScript
"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _SelfListItem_value;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelfListItem = void 0;
const BaseSelfControl_1 = require("./BaseSelfControl");
const enums_1 = require("../enums");
const chainOfResponsibility_1 = require("../chainOfResponsibility");
class SelfListItem extends BaseSelfControl_1.BaseSelfControl {
validateNormal(eventArgs) { }
get value() {
return __classPrivateFieldGet(this, _SelfListItem_value, "f");
}
set value(value) { }
constructor(value) {
super();
this.onlyLastLevel = false;
this.validateRequired = (eventArgs) => {
if (this.required) {
if (!this.value || this.value.length === 0) {
eventArgs.cancel = true;
eventArgs.state = enums_1.EnumValidateState.empty;
eventArgs.error = 'هیچ کدی انتخاب نشده است';
}
}
};
this.isValueEmpty = () => {
return __classPrivateFieldGet(this, _SelfListItem_value, "f").length > 0;
};
this.isValueNotEmpty = () => {
return !this.isValueEmpty();
};
this.validate = () => {
var validationChain = new chainOfResponsibility_1.ValidationChain();
validationChain.validators.add(this.validateNormal);
validationChain.validators.add(this.validateRequired);
this.validation = validationChain.validate();
};
this.cleaningClassInitializer = () => {
this.hasChange = false;
this.defaultValue = undefined;
this.initializeListener = false;
this.initializeProperties = false;
this.validation = true;
};
this.refreshHasChange = () => {
if (this.showHasChangeFlag) {
this.hasChange = this.defaultValue !== __classPrivateFieldGet(this, _SelfListItem_value, "f").toString();
}
};
this.restartDefaultValue = () => {
this.defaultValue = this.value.toString();
this.refreshHasChange();
};
_SelfListItem_value.set(this, void 0);
this.setValue = (ids) => {
__classPrivateFieldSet(this, _SelfListItem_value, ids, "f");
this.refreshHasChange();
};
this.deserialize = (json) => {
};
__classPrivateFieldSet(this, _SelfListItem_value, value, "f");
this.restartDefaultValue();
}
static empty(value) {
return new SelfListItem(value || '');
}
}
exports.SelfListItem = SelfListItem;
_SelfListItem_value = new WeakMap();