armisa-models
Version:
models of armisa!
298 lines (274 loc) • 7.61 kB
text/typescript
import { INaming } from "../NamingCaption";
import { BasePageData } from "../Page/BasePageData";
export type StackIconType =
undefined
| 'none'
| 'home'
| 'new'
| 'view'
| 'edit'
| 'delete'
| 'cut'
| 'copy'
| 'past'
| 'open'
| 'close'
| 'columns'
| 'ok'
| 'save'
| 'print'
| 'printCrystal'
| 'sortNumber'
| 'drillDown'
| 'contextMenu'
| 'exportToExcel'
| 'importFromExcel'
| 'insertRowTop'
| 'insertRowBottom'
| 'removeRow'
| 'refresh'
| 'nextPage'
| 'previousPage'
| 'next'
| 'back'
| 'nextSameLevel'
| 'backSameLevel'
| 'function'
| 'sum'
;
export abstract class StackIcon {
public name: string;
public caption?: string;
public onClick?: (e: React.MouseEvent) => void;
constructor(
public pageData: BasePageData,
public id: number,
public type: StackIconType,
public size: number,
public tabIndex?: number,
public naming?: INaming,
public role?: string,
public subRole?: string,
public disabled?: boolean
) {
this.name = `${type}_${id}`;
if (naming) {
this.caption = this.pageData.mainStateManager.getCaptionNaming(naming);
}
}
static buildNewIcon(
pageData: BasePageData,
id: number,
type: StackIconType,
onClick?: (e: React.MouseEvent) => void,
size?: number,
tabIndex?: number,
popup?: JSX.Element,
naming?: INaming,
role?: string,
subRole?: string,
disabled?: boolean,
) {
const newItem = new StackMenuItemClass(pageData, id, type, false, popup, naming, size || 2, tabIndex, role, subRole, disabled);
newItem.onClick = onClick;
return newItem;
}
static buildNewSubIcon(
parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
type: StackIconType,
naming: INaming,
onClick?: (e: React.MouseEvent) => void,
size?: number,
tabIndex?: number,
role?: string,
subRole?: string,
disabled?: boolean
) {
const newItem = new StackSubMenuItemClass(parent, pageData, id, type, naming, size || 2, tabIndex, role, subRole, disabled);
newItem.onClick = onClick;
return newItem;
}
static buildNewSubChildIcon(
parent: StackSubMenuItemClass,
pageData: BasePageData,
id: number,
type: StackIconType,
naming: INaming,
onClick?: (e: React.MouseEvent) => void,
size?: number,
tabIndex?: number,
role?: string,
subRole?: string,
disabled?: boolean
) {
const newItem = new StackSubMenuItemChildClass(parent, pageData, id, type, naming, size || 2, tabIndex, role, subRole, disabled);
newItem.onClick = onClick;
return newItem;
}
static buildNewSeparator(
pageData: BasePageData,
id: number,
) {
const newItem = new StackSeparator(pageData, id, undefined, 2, undefined, undefined, undefined, undefined);
return newItem;
}
static buildNewSeparatorPrintReportState(
parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
action: (index: number) => void,
size?: number,
tabIndex?: number,
) {
const newItem = new StackSeparatorPrintState(parent, pageData, id, action, tabIndex, size);
return newItem;
}
static buildNewFontPrintName(
parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
action: (index: number) => void,
size?: number,
tabIndex?: number,
) {
const newItem = new StackFontPrintName(parent, pageData, id, action, tabIndex, size);
return newItem;
}
}
export class StackMenuItemClass extends StackIcon {
public subMenuItems: (StackSubMenuItemClass | StackSeparatorPrintState | StackFontPrintName)[] = [];
constructor(
pageData: BasePageData,
id: number,
type: StackIconType,
public toolTip: boolean,
public popup?: JSX.Element,
naming?: INaming,
size?: number,
tabIndex?: number,
role?: string,
subRole?: string,
disabled?: boolean,
) {
super(
pageData,
id,
type,
size || 2,
tabIndex,
naming,
role,
subRole,
disabled
);
if (!pageData.stackIcons) {
pageData.stackIcons = [];
}
pageData.stackIcons.push(this);
}
}
export class StackSubMenuItemClass extends StackIcon {
public subMenuItemsChildItem: StackSubMenuItemChildClass[] = [];
constructor(
public parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
type: StackIconType,
naming: INaming,
size?: number,
tabIndex?: number,
role?: string,
subRole?: string,
disabled?: boolean
) {
super(
pageData,
id,
type,
size || 2,
tabIndex,
naming,
role,
subRole,
disabled
);
if (!parent.subMenuItems.find(i => i === this)) {
parent.subMenuItems.push(this);
}
}
}
export class StackSubMenuItemChildClass extends StackIcon {
constructor(
public parent: StackSubMenuItemClass,
pageData: BasePageData,
id: number,
type: StackIconType,
naming: INaming,
size?: number,
tabIndex?: number,
role?: string,
subRole?: string,
disabled?: boolean
) {
super(
pageData,
id,
type,
size || 2,
tabIndex,
naming,
role,
subRole,
disabled
);
if (!parent.subMenuItemsChildItem.find(i => i === this)) {
parent.subMenuItemsChildItem.push(this);
}
}
}
export class StackSeparator extends StackIcon {
}
export class StackSeparatorPrintState extends StackIcon {
constructor(
public parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
public action: (index: number) => void,
size?: number,
tabIndex?: number,
) {
super(
pageData,
id,
'none',
size || 2,
tabIndex,
);
if (!parent.subMenuItems.find(i => i === this)) {
parent.subMenuItems.push(this);
}
}
}
export class StackFontPrintName extends StackIcon {
constructor(
public parent: StackMenuItemClass,
pageData: BasePageData,
id: number,
public action: (index: number) => void,
size?: number,
tabIndex?: number,
) {
super(
pageData,
id,
'none',
size || 2,
tabIndex,
);
if (!parent.subMenuItems.find(i => i === this)) {
parent.subMenuItems.push(this);
}
}
}