armisa-models
Version:
models of armisa!
267 lines (266 loc) • 10.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasePageData = exports.StackHeaderFields = exports.PropsOfPage = void 0;
const Events_1 = require("./Events");
const NamingCaption_1 = require("../NamingCaption");
class PropsOfPage {
static buildNewTag(tag, listOfUserOptions) {
const result = new PropsOfPage();
result.tag = tag;
result.listOfUserOptionsLoadBeforStart = listOfUserOptions;
return result;
}
static buildNewCode(code) {
const result = new PropsOfPage();
result.code = code;
return result;
}
static buildNewHeadId(id) {
const result = new PropsOfPage();
result.headId = id;
return result;
}
static buildNewArticleId(id) {
const result = new PropsOfPage();
result.articleId = id;
return result;
}
}
exports.PropsOfPage = PropsOfPage;
class StackHeaderFields {
constructor(index, fieldName, caption) {
this.index = index;
this.fieldName = fieldName;
this.caption = caption;
}
static buildNew(index, fieldName, caption) {
return new StackHeaderFields(index, fieldName, caption);
}
}
exports.StackHeaderFields = StackHeaderFields;
;
class BasePageData {
get any() {
return this;
}
get pageKey() {
return this._pageKey;
}
set pageKey(value) {
this._pageKey = value;
// this._userOptions = this.mainStateManager.Usering.userOptions?.filter((i: any) => i.form === this._pageKey);
}
get userOptions() {
return this._userOptions;
}
set userOptions(value) {
this._userOptions = value;
}
constructor(mainStateManager) {
this.mainStateManager = mainStateManager;
this.accessOfAcceptKeyIsAccepted = true;
this.accessOfNewKeyIsAccepted = true;
this.accessOfViewKeyIsAccepted = true;
this.accessOfEditKeyIsAccepted = true;
this.accessOfDeleteKeyIsAccepted = true;
this.accessOfF9KeyIsAccepted = true;
this.Eventing = new Events_1.Events();
this.initializeFieldSetListener = false;
this.initializeFormListener = false;
this.initializeHook = false;
this.isInitializeHookForFirstTime = false;
this.initializeStackMenuContainer = false;
this.formType = 'modifing';
this.isActive = true;
this.activeElementIndex = 0;
this.dontHandleActiveElementBySelef = false;
this.stackHeaderFields = undefined;
this.addStackHeadersField = (data) => {
if (!this.stackHeaderFields || data.index === 1) {
this.stackHeaderFields = [];
}
const result = [...this.stackHeaderFields, data];
this.stackHeaderFields = result.sort((i, j) => i < j ? -1 : i === j ? 0 : 1);
};
this._pageKey = undefined;
this.addUserOption = (userOption) => {
if (!this._userOptions) {
this._userOptions = [];
this._userOptions.push(userOption);
}
else {
const finded = this._userOptions.find(i => i.form === userOption.form && i.key === userOption.key);
if (finded) {
finded.value = userOption.value;
userOption = finded;
}
else {
this._userOptions.push(userOption);
}
}
};
this.getNaming = (value) => {
if (typeof value === 'string') {
return value;
}
if (value instanceof NamingCaption_1.CaptionNaming) {
// return (value as any)[this.mainStateManager.Languaging.languageSuffix];
}
if (Array.isArray(value) && value.length == 2) {
return value[1];
}
const typeOfValue = typeof value === 'object';
const fa = 'FA' in value;
const en = 'EN' in value;
if (typeOfValue && fa && en) {
// return (value as any)[this.mainStateManager.Languaging.languageSuffix];
}
};
this.getUserOption = (key) => {
return this._userOptions && this._userOptions.find(i => i.key === key)?.value;
};
this.setUserOption = (key, value, defaultValue, columnOfReports, isSave) => {
if (!this._userOptions) {
this._userOptions = [];
}
const finded = this._userOptions.find(i => i.key === key);
const valueString = value.toString();
if (finded) {
const defaultValueString = defaultValue.toString();
if (valueString === defaultValueString) {
// this.mainStateManager.Usering.removeUserOption(finded.key, [finded.form, ...columnOfReports], true);
}
else {
finded.value = valueString;
if (isSave) {
// this.mainStateManager.Usering.saveUserOption(finded.key, [finded.form, ...columnOfReports], valueString);
}
}
}
else {
// this.mainStateManager.Usering.addUserOption(key, [this.pageKey, ...columnOfReports], valueString, isSave);
}
};
this.updateFocuseState = (controlIndex) => {
};
this.updateFocuseStateOld = (controlIndex) => {
if (this.dontHandleActiveElementBySelef) {
return;
}
if (typeof controlIndex === 'number') {
this.activeElementIndex = controlIndex;
}
if (this.isActive) {
if (this.activeElementIndex === this.gridViewTabIndex) {
if (this.gridViewCurrentCellRef &&
this.gridViewCurrentCellRef.current) {
this.gridViewCurrentCellRef.current.focus();
}
else {
this.TabbingControl.focuseToThisElement(this.activeElementIndex);
}
}
else {
this.TabbingControl.focuseToThisElement(this.activeElementIndex);
}
}
};
this.id = Math.random().toString() + '-' + new Date().getMilliseconds().toString();
this.caption = '';
this.component = undefined;
// this.mainStateManager.Eventing.on(this.id, 'addNewModal', (parentPage: BasePageData, modalPage: BasePageData) => {
// this.isActive = modalPage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// } else {
// this.Eventing.trigger('form.disabled');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'addNewModalPage', (parentPage: BasePageData, modalPage: BasePageData) => {
// this.isActive = modalPage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// } else {
// this.Eventing.trigger('form.disabled');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'addNewPopup', (parentPage: BasePageData, popupPage: BasePageData) => {
// this.isActive = popupPage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// } else {
// this.Eventing.trigger('form.disabled');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'addNewPopupPage', (parentPage: BasePageData, popupPage: BasePageData) => {
// this.isActive = popupPage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// } else {
// this.Eventing.trigger('form.disabled');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'closeModal', (activePage?: BasePageData) => {
// this.isActive = activePage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'closePopup', (activePage?: BasePageData) => {
// this.isActive = activePage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'showWaitingModal', () => {
// if (this.isActive) {
// this.isActive = false;
// this.Eventing.trigger('form.disabled');
// }
// });
// this.mainStateManager.Eventing.on(this.id, 'closeWaitingModal', (activePage?: BasePageData) => {
// if (!this.modal) {
// this.isActive = activePage === this;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// }
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'addNewTab', (activePage: BasePageData) => {
// this.isActive = this === activePage;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// } else {
// this.Eventing.trigger('form.disabled');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'closeTab', (activePage?: BasePageData) => {
// this.isActive = this === activePage;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// }
// }
// );
// this.mainStateManager.Eventing.on(this.id, 'selectTab', (activePage: BasePageData) => {
// if (this.mainStateManager.Tabing.tabs.find(i => i.id === this.id)) {
// this.isActive = this === activePage;
// if (this.isActive) {
// this.Eventing.trigger('form.getActive');
// }
// }
// }
// );
}
onClickCancelButton() { }
onClickHelpButton() { }
setHelpElementRef() { }
}
exports.BasePageData = BasePageData;