scheduler-models 1.3.110 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,3 +2,4 @@ export * from './general';
2
2
  export * from './viewstate';
3
3
  export * from './logs';
4
4
  export * from './notices';
5
+ export * from './menu';
package/general/index.js CHANGED
@@ -18,4 +18,5 @@ __exportStar(require("./general"), exports);
18
18
  __exportStar(require("./viewstate"), exports);
19
19
  __exportStar(require("./logs"), exports);
20
20
  __exportStar(require("./notices"), exports);
21
+ __exportStar(require("./menu"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/general/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/general/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB"}
@@ -0,0 +1,33 @@
1
+ import { IUser } from "../users";
2
+ export interface IMenuItem {
3
+ id: number;
4
+ name: string;
5
+ link: string;
6
+ showMenu: boolean;
7
+ application: string;
8
+ groups: string[];
9
+ }
10
+ export declare class MenuItem implements IMenuItem {
11
+ id: number;
12
+ name: string;
13
+ link: string;
14
+ showMenu: boolean;
15
+ application: string;
16
+ groups: string[];
17
+ constructor(item?: IMenuItem);
18
+ compareTo(other?: MenuItem): number;
19
+ use(iuser: IUser): boolean;
20
+ }
21
+ export interface IMenuGroup {
22
+ id: number;
23
+ name: string;
24
+ items?: IMenuItem[];
25
+ }
26
+ export declare class MenuGroup implements IMenuGroup {
27
+ id: number;
28
+ name: string;
29
+ items: MenuItem[];
30
+ constructor(group?: IMenuGroup);
31
+ compareTo(other?: MenuGroup): number;
32
+ useGroup(iuser: IUser): boolean;
33
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MenuGroup = exports.MenuItem = void 0;
4
+ const users_1 = require("../users");
5
+ class MenuItem {
6
+ id;
7
+ name;
8
+ link;
9
+ showMenu;
10
+ application;
11
+ groups;
12
+ constructor(item) {
13
+ this.id = (item) ? item.id : 0;
14
+ this.name = (item) ? item.name : '';
15
+ this.link = (item) ? item.link : '';
16
+ this.showMenu = (item) ? item.showMenu : false;
17
+ this.application = (item) ? item.application : 'scheduler';
18
+ this.groups = [];
19
+ if (item && item.groups && item.groups.length > 0) {
20
+ item.groups.forEach(gp => {
21
+ this.groups.push(gp);
22
+ });
23
+ }
24
+ }
25
+ compareTo(other) {
26
+ if (other) {
27
+ return (this.id < other.id) ? -1 : 1;
28
+ }
29
+ return -1;
30
+ }
31
+ use(iuser) {
32
+ const user = new users_1.User(iuser);
33
+ let answer = false;
34
+ this.groups.forEach(grp => {
35
+ if (user.hasPermission(this.application, grp)) {
36
+ answer = true;
37
+ }
38
+ });
39
+ return answer;
40
+ }
41
+ }
42
+ exports.MenuItem = MenuItem;
43
+ class MenuGroup {
44
+ id;
45
+ name;
46
+ items;
47
+ constructor(group) {
48
+ this.id = (group) ? group.id : 0;
49
+ this.name = (group) ? group.name : '';
50
+ this.items = [];
51
+ if (group && group.items && group.items.length > 0) {
52
+ group.items?.forEach(item => {
53
+ this.items.push(new MenuItem(item));
54
+ });
55
+ this.items.sort((a, b) => a.compareTo(b));
56
+ }
57
+ }
58
+ compareTo(other) {
59
+ if (other) {
60
+ return (this.id < other.id) ? -1 : 1;
61
+ }
62
+ return -1;
63
+ }
64
+ useGroup(iuser) {
65
+ let answer = false;
66
+ this.items.forEach(item => {
67
+ if (item.use(iuser)) {
68
+ answer = true;
69
+ }
70
+ });
71
+ return answer;
72
+ }
73
+ }
74
+ exports.MenuGroup = MenuGroup;
75
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1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AAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,SAAS,CAAC,KAAiB;QACzB,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,QAAQ,CAAC,KAAY;QACnB,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjCD,8BAiCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler-models",
3
- "version": "1.3.110",
3
+ "version": "1.4.2",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -1,8 +1,10 @@
1
+ import { IMenuGroup } from "../../general";
1
2
  import { ISecurityQuestion } from "../../users";
2
3
  import { IEmployee } from "../employees";
3
4
  import { ISite } from "../sites";
4
5
  import { ITeam } from "../teams";
5
6
  export interface InitialResponse {
7
+ menu: IMenuGroup[];
6
8
  team?: ITeam;
7
9
  site?: ISite;
8
10
  employee?: IEmployee;