@pilotdev/pilot-web-sdk 23.0.0-alpha.1 → 24.4.0

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.
Files changed (48) hide show
  1. package/.eslintrc.json +31 -0
  2. package/README.md +24 -5
  3. package/ng-package.json +6 -6
  4. package/package.json +13 -13
  5. package/src/lib/contexts/context.ts +38 -0
  6. package/src/lib/contexts/document-annotations-list-context.ts +21 -0
  7. package/src/lib/contexts/index.ts +3 -0
  8. package/src/lib/contexts/render-context.ts +28 -0
  9. package/src/lib/data/access.ts +40 -0
  10. package/src/lib/data/annotations.ts +20 -0
  11. package/src/lib/data/attribute.ts +33 -0
  12. package/src/lib/data/data-object.ts +78 -0
  13. package/src/lib/data/file.ts +25 -0
  14. package/src/lib/data/files-snapshot.ts +9 -0
  15. package/src/lib/data/index.ts +12 -0
  16. package/src/lib/data/modifier.ts +31 -0
  17. package/src/lib/data/object-builder.ts +111 -0
  18. package/src/lib/data/organisation-unit.ts +20 -0
  19. package/src/lib/data/person.ts +17 -0
  20. package/src/lib/data/relation.ts +10 -0
  21. package/src/lib/data/subscriptionType.ts +5 -0
  22. package/src/lib/idata.plugin.ts +1 -1
  23. package/src/lib/injectable/index.ts +4 -1
  24. package/src/lib/injectable/modifier-provider.ts +11 -0
  25. package/src/lib/injectable/objects-repository.ts +74 -0
  26. package/src/lib/injectable/render-context-provider.ts +11 -0
  27. package/src/lib/injectable/repository-events.ts +33 -0
  28. package/src/lib/menu/checkable-menu.builder.ts +14 -14
  29. package/src/lib/menu/index.ts +4 -4
  30. package/src/lib/menu/menu-item.builder.ts +44 -44
  31. package/src/lib/menu/menu.builder.ts +78 -78
  32. package/src/lib/menu/menu.ts +23 -23
  33. package/src/lib/toolbar/index.ts +6 -6
  34. package/src/lib/toolbar/toolbar-item-submenu.handler.ts +11 -3
  35. package/src/lib/toolbar/toolbar-item.builder.ts +44 -44
  36. package/src/lib/toolbar/toolbar-menu-item.builder.ts +15 -15
  37. package/src/lib/toolbar/toolbar-toggle-item.builder.ts +14 -14
  38. package/src/lib/toolbar/toolbar.builder.ts +103 -103
  39. package/src/lib/toolbar/toolbar.ts +30 -30
  40. package/src/lib/tools/attribute-permission.info.ts +51 -0
  41. package/src/lib/tools/guid.ts +63 -0
  42. package/src/lib/tools/index.ts +3 -0
  43. package/src/lib/tools/utils.ts +8 -0
  44. package/src/public-api.ts +10 -8
  45. package/tsconfig.lib.json +15 -14
  46. package/tsconfig.lib.prod.json +10 -10
  47. package/src/lib/context.ts +0 -25
  48. package/src/lib/injectable/objects.repository.ts +0 -7
@@ -1,104 +1,104 @@
1
- import { IToolbarButtonItemBuilder } from "./toolbar-item.builder";
2
- import { IToolbarItemSubmenuHandler } from "./toolbar-item-submenu.handler";
3
- import { IToolbarMenuButtonItemBuilder } from "./toolbar-menu-item.builder";
4
- import { IToolbarToggleButtonItemBuilder } from "./toolbar-toggle-item.builder";
5
-
6
- export abstract class IToolbarBuilder {
7
-
8
- constructor() {
9
- if (this.constructor == IToolbarBuilder) {
10
- throw new Error("Abstract classes can't be instantiated.");
11
- }
12
- }
13
-
14
- /**
15
- * Adds a new separator to the associated toolbar
16
- * @param index - The index to put the new item at
17
- */
18
- addSeparator(index: number): void {
19
- throw new Error("Method 'addSeparator(index: number)' must be implemented.");
20
- }
21
-
22
- /**
23
- * Adds a new button to the associated toolbar
24
- * @param name - Internal item's name
25
- * @param index - The index to put the new item at
26
- */
27
- addButtonItem(name: string, index: number): IToolbarButtonItemBuilder {
28
- throw new Error("Method 'addButtonItem(name: string, index: number)' must be implemented.");
29
- }
30
-
31
- /**
32
- * Adds a new menu button to the associated toolbar
33
- * @param name - Internal item's name
34
- * @param index - The index to put the new item at
35
- */
36
- addMenuButtonItem(name: string, index: number): IToolbarMenuButtonItemBuilder {
37
- throw new Error("Method 'addMenuButtonItem(name: string, index: number)' must be implemented.");
38
- }
39
-
40
- /**
41
- * Adds a new toggle button to the associated toolbar
42
- * @param name - Internal item's name
43
- * @param index - The index to put the new item at
44
- */
45
- addToggleButtonItem(name: string, index: number): IToolbarToggleButtonItemBuilder {
46
- throw new Error("Method 'addToggleButtonItem(name: string, index: number)' must be implemented.");
47
- }
48
-
49
- /**
50
- * Replaces the item from the associated toolbar on button
51
- * @param name - The name of toolbar button to replace
52
- */
53
- replaceButtonItem(name: string): IToolbarButtonItemBuilder {
54
- throw new Error("Method 'replaceButtonItem(name: string)' must be implemented.");
55
- }
56
-
57
- /**
58
- * Replace the item from the associated toolbar on menu button
59
- * @param name - The name of toolbar menu button to replace
60
- */
61
- replaceMenuButtonItem(name: string): IToolbarMenuButtonItemBuilder {
62
- throw new Error("Method 'replaceMenuButtonItem(name: string)' must be implemented.");
63
- }
64
-
65
- /**
66
- * Enables to set parametres to menu button item submenu
67
- * @param name - Item's internal name
68
- * @param itemSubmenuHandler - The toolbar button menu builder
69
- */
70
- handleMenuButtonItemSubmenu(name: string, itemSubmenuHandler: IToolbarItemSubmenuHandler): void {
71
- throw new Error("Method 'handleMenuButtonItemSubmenu(name: string, itemSubmenuHandler: IToolbarItemSubmenuHandler)' must be implemented.");
72
- }
73
-
74
- /**
75
- * Replaces the item from the associated toolbar on toggle button
76
- * @param name - The name of toolbar toggle button to replace
77
- */
78
- replaceToggleButtonItem(name: string): IToolbarToggleButtonItemBuilder {
79
- throw new Error("Method 'replaceToggleButtonItem(name: string)' must be implemented.");
80
- }
81
-
82
- /**
83
- * Gets the list of existing item names of associated toolbar
84
- * @returns - Existing toolbar item names
85
- */
86
- get itemNames(): string[] {
87
- throw new Error("Getter 'itemNames()' must be implemented.");
88
- }
89
-
90
- /**
91
- * Gets count of toolbar items
92
- */
93
- get count(): number {
94
- throw new Error("Getter 'count()' must be implemented.");
95
- }
96
-
97
- /**
98
- * Removes specified item
99
- * @param itemName - Item's internal name
100
- */
101
- removeItem(itemName: string): void {
102
- throw new Error("Method 'removeItem(name: string)' must be implemented.");
103
- }
1
+ import { IToolbarButtonItemBuilder } from "./toolbar-item.builder";
2
+ import { IToolbarItemSubmenuHandler } from "./toolbar-item-submenu.handler";
3
+ import { IToolbarMenuButtonItemBuilder } from "./toolbar-menu-item.builder";
4
+ import { IToolbarToggleButtonItemBuilder } from "./toolbar-toggle-item.builder";
5
+
6
+ export abstract class IToolbarBuilder {
7
+
8
+ constructor() {
9
+ if (this.constructor == IToolbarBuilder) {
10
+ throw new Error("Abstract classes can't be instantiated.");
11
+ }
12
+ }
13
+
14
+ /**
15
+ * Adds a new separator to the associated toolbar
16
+ * @param index - The index to put the new item at
17
+ */
18
+ addSeparator(index: number): void {
19
+ throw new Error("Method 'addSeparator(index: number)' must be implemented.");
20
+ }
21
+
22
+ /**
23
+ * Adds a new button to the associated toolbar
24
+ * @param name - Internal item's name
25
+ * @param index - The index to put the new item at
26
+ */
27
+ addButtonItem(name: string, index: number): IToolbarButtonItemBuilder {
28
+ throw new Error("Method 'addButtonItem(name: string, index: number)' must be implemented.");
29
+ }
30
+
31
+ /**
32
+ * Adds a new menu button to the associated toolbar
33
+ * @param name - Internal item's name
34
+ * @param index - The index to put the new item at
35
+ */
36
+ addMenuButtonItem(name: string, index: number): IToolbarMenuButtonItemBuilder {
37
+ throw new Error("Method 'addMenuButtonItem(name: string, index: number)' must be implemented.");
38
+ }
39
+
40
+ /**
41
+ * Adds a new toggle button to the associated toolbar
42
+ * @param name - Internal item's name
43
+ * @param index - The index to put the new item at
44
+ */
45
+ addToggleButtonItem(name: string, index: number): IToolbarToggleButtonItemBuilder {
46
+ throw new Error("Method 'addToggleButtonItem(name: string, index: number)' must be implemented.");
47
+ }
48
+
49
+ /**
50
+ * Replaces the item from the associated toolbar on button
51
+ * @param name - The name of toolbar button to replace
52
+ */
53
+ replaceButtonItem(name: string): IToolbarButtonItemBuilder {
54
+ throw new Error("Method 'replaceButtonItem(name: string)' must be implemented.");
55
+ }
56
+
57
+ /**
58
+ * Replace the item from the associated toolbar on menu button
59
+ * @param name - The name of toolbar menu button to replace
60
+ */
61
+ replaceMenuButtonItem(name: string): IToolbarMenuButtonItemBuilder {
62
+ throw new Error("Method 'replaceMenuButtonItem(name: string)' must be implemented.");
63
+ }
64
+
65
+ /**
66
+ * Enables to set parametres to menu button item submenu
67
+ * @param name - Item's internal name
68
+ * @param itemSubmenuHandler - The toolbar button menu builder
69
+ */
70
+ handleMenuButtonItemSubmenu(name: string, itemSubmenuHandler: IToolbarItemSubmenuHandler): void {
71
+ throw new Error("Method 'handleMenuButtonItemSubmenu(name: string, itemSubmenuHandler: IToolbarItemSubmenuHandler)' must be implemented.");
72
+ }
73
+
74
+ /**
75
+ * Replaces the item from the associated toolbar on toggle button
76
+ * @param name - The name of toolbar toggle button to replace
77
+ */
78
+ replaceToggleButtonItem(name: string): IToolbarToggleButtonItemBuilder {
79
+ throw new Error("Method 'replaceToggleButtonItem(name: string)' must be implemented.");
80
+ }
81
+
82
+ /**
83
+ * Gets the list of existing item names of associated toolbar
84
+ * @returns - Existing toolbar item names
85
+ */
86
+ get itemNames(): string[] {
87
+ throw new Error("Getter 'itemNames()' must be implemented.");
88
+ }
89
+
90
+ /**
91
+ * Gets count of toolbar items
92
+ */
93
+ get count(): number {
94
+ throw new Error("Getter 'count()' must be implemented.");
95
+ }
96
+
97
+ /**
98
+ * Removes specified item
99
+ * @param itemName - Item's internal name
100
+ */
101
+ removeItem(itemName: string): void {
102
+ throw new Error("Method 'removeItem(name: string)' must be implemented.");
103
+ }
104
104
  }
@@ -1,31 +1,31 @@
1
- import { IToolbarBuilder } from "./toolbar.builder";
2
-
3
- /**
4
- * Interface that allows to add new items to the toolbar
5
- */
6
- export abstract class IToolbar<TToolbarContext> {
7
-
8
- constructor() {
9
- if (this.constructor == IToolbar<TToolbarContext>) {
10
- throw new Error("Abstract classes can't be instantiated.");
11
- }
12
- }
13
-
14
- /**
15
- * The method is called just before the toolbar is created
16
- * @param builder - the toolbar builder object of associated toolbar
17
- * @param context - context
18
- */
19
- build(builder: IToolbarBuilder, context: TToolbarContext): void {
20
- throw new Error("Method 'build(builder: IToolbarBuilder, context: TToolbarContext)' must be implemented.");
21
- }
22
-
23
- /**
24
- *
25
- * @param name
26
- * @param context
27
- */
28
- onToolbarItemClick(name: string, context: TToolbarContext): void {
29
- throw new Error("Method 'onToolbarItemClick(name: string, context: TToolbarContext)' must be implemented.");
30
- }
1
+ import { IToolbarBuilder } from "./toolbar.builder";
2
+
3
+ /**
4
+ * Interface that allows to add new items to the toolbar
5
+ */
6
+ export abstract class IToolbar<TToolbarContext> {
7
+
8
+ constructor() {
9
+ if (this.constructor == IToolbar<TToolbarContext>) {
10
+ throw new Error("Abstract classes can't be instantiated.");
11
+ }
12
+ }
13
+
14
+ /**
15
+ * The method is called just before the toolbar is created
16
+ * @param builder - the toolbar builder object of associated toolbar
17
+ * @param context - context
18
+ */
19
+ build(builder: IToolbarBuilder, context: TToolbarContext): void {
20
+ throw new Error("Method 'build(builder: IToolbarBuilder, context: TToolbarContext)' must be implemented.");
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param name
26
+ * @param context
27
+ */
28
+ onToolbarItemClick(name: string, context: TToolbarContext): void {
29
+ throw new Error("Method 'onToolbarItemClick(name: string, context: TToolbarContext)' must be implemented.");
30
+ }
31
31
  }
@@ -0,0 +1,51 @@
1
+ import { objectToMap } from "./utils";
2
+
3
+ export class AttributePermissionInfo {
4
+ private ATTRIBUTE_NAME_MARKER = '&';
5
+
6
+ orgUnits: number[];
7
+ orgUnitAttributes: string[];
8
+
9
+ constructor(editableForPositionsSource: string[]) {
10
+ this.orgUnits = new Array<number>();
11
+ this.orgUnitAttributes = new Array<string>();
12
+
13
+ if (!editableForPositionsSource)
14
+ return;
15
+
16
+ editableForPositionsSource.forEach(str => {
17
+ if (str.length > 0 && str[0] === this.ATTRIBUTE_NAME_MARKER) {
18
+ this.orgUnitAttributes.push(str.substring(1));
19
+ }
20
+ else {
21
+ const num = Number(str);
22
+ if (!isNaN(num))
23
+ this.orgUnits.push(num);
24
+ }
25
+ });
26
+ }
27
+
28
+ extractAllOrgUnits(obj: any): number[] {
29
+ const attrMap = objectToMap<any>(obj.attributes);
30
+ return this.extractAllOrgUnitsByAttributes(attrMap);
31
+ }
32
+
33
+ extractAllOrgUnitsByAttributes(attributes: Map<string, any>) : number[] {
34
+ let result = new Array<number>();
35
+ if (!this.orgUnitAttributes || !attributes )
36
+ return result;
37
+
38
+ this.orgUnitAttributes.forEach(permissionAttributeName => {
39
+ if (attributes.has(permissionAttributeName)){
40
+ const value = attributes.get(permissionAttributeName);
41
+ if (value && Array.isArray(value)){
42
+ value.forEach(intValue => {
43
+ result.push(intValue);
44
+ });
45
+ }
46
+ }
47
+ });
48
+
49
+ return result;
50
+ }
51
+ }
@@ -0,0 +1,63 @@
1
+ const byteToHex = Array();
2
+ for (let i = 0; i < 256; ++i) {
3
+ byteToHex.push((i + 0x100).toString(16).slice(1));
4
+ }
5
+
6
+ export class Guid {
7
+ private static readonly regex = "(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})";
8
+
9
+ static readonly EMPTY = "00000000-0000-0000-0000-000000000000";
10
+
11
+ static newGuid(): string {
12
+
13
+ if (window.isSecureContext) {
14
+ // If crypto.getRandomValues is available try to use it.
15
+ return window.crypto.randomUUID();
16
+ }
17
+
18
+ // Fall back to Math.random if a higher quality random number generator is not available.
19
+ const uuid = new Array(16);
20
+ var d = new Date().getTime();
21
+ for (var i = 0; i < 16; i++) {
22
+ var r = ((d + Math.random() * 256) % 256) | 0;
23
+ d = Math.trunc(d / 256);
24
+ uuid[i] = r;
25
+ }
26
+
27
+ // Makes uuid compliant to RFC-4122
28
+ uuid[6] = (uuid[6] & 0x0F) | 0x40; // uuid version
29
+ uuid[8] = (uuid[8] & 0x3F) | 0x80; // uuid variant
30
+
31
+ return this.stringify(uuid);
32
+ }
33
+
34
+ static isGuid(str: string) {
35
+ const regex = new RegExp(this.regex);
36
+ return regex.test(str) && str.length === 36;
37
+ }
38
+
39
+ private static stringify(arr: Array<number>) {
40
+ return (
41
+ byteToHex[arr[0]] +
42
+ byteToHex[arr[1]] +
43
+ byteToHex[arr[2]] +
44
+ byteToHex[arr[3]] +
45
+ '-' +
46
+ byteToHex[arr[4]] +
47
+ byteToHex[arr[5]] +
48
+ '-' +
49
+ byteToHex[arr[6]] +
50
+ byteToHex[arr[7]] +
51
+ '-' +
52
+ byteToHex[arr[8]] +
53
+ byteToHex[arr[9]] +
54
+ '-' +
55
+ byteToHex[arr[10]] +
56
+ byteToHex[arr[11]] +
57
+ byteToHex[arr[12]] +
58
+ byteToHex[arr[13]] +
59
+ byteToHex[arr[14]] +
60
+ byteToHex[arr[15]]
61
+ ).toLowerCase();
62
+ }
63
+ }
@@ -0,0 +1,3 @@
1
+ export * from './attribute-permission.info';
2
+ export * from './utils'
3
+ export * from './guid'
@@ -0,0 +1,8 @@
1
+
2
+ export function objectToMap<T>(objectMap: { [key: string]: any; }): Map<string, T> {
3
+ const map = new Map<string, T>();
4
+ Object.keys(objectMap).forEach(key => {
5
+ map.set(key, objectMap[key]);
6
+ });
7
+ return map;
8
+ }
package/src/public-api.ts CHANGED
@@ -1,8 +1,10 @@
1
- /*
2
- * Public API Surface of pilot-web-sdk
3
- */
4
- export * from './lib/context';
5
- export * from './lib/idata.plugin';
6
- export * from './lib/injectable/index';
7
- export * from './lib/toolbar/index';
8
- export * from './lib/menu/index';
1
+ /*
2
+ * Public API Surface of pilot-web-sdk
3
+ */
4
+ export * from './lib/idata.plugin';
5
+ export * from './lib/injectable/index';
6
+ export * from './lib/toolbar/index';
7
+ export * from './lib/menu/index';
8
+ export * from './lib/contexts/index';
9
+ export * from './lib/tools/index';
10
+ export * from './lib/data/index';
package/tsconfig.lib.json CHANGED
@@ -1,14 +1,15 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/lib",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "inlineSources": true,
9
- "types": []
10
- },
11
- "exclude": [
12
- "**/*.spec.ts"
13
- ]
14
- }
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/lib",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "inlineSources": true,
9
+ "types": [],
10
+ "strict": true
11
+ },
12
+ "exclude": [
13
+ "**/*.spec.ts"
14
+ ]
15
+ }
@@ -1,10 +1,10 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.lib.json",
4
+ "compilerOptions": {
5
+ "declarationMap": false
6
+ },
7
+ "angularCompilerOptions": {
8
+ "compilationMode": "partial"
9
+ }
10
+ }
@@ -1,25 +0,0 @@
1
- /**
2
- * Contex for objects view
3
- */
4
- export class ObjectsViewContext {
5
-
6
- constructor(selectedObjects: any[], isContext: boolean, shortcuts?: any[]) {
7
- this.selectedObjects = selectedObjects;
8
- this.isContext = isContext;
9
- this.shortcuts = shortcuts;
10
- }
11
-
12
- /**
13
- *
14
- */
15
- readonly selectedObjects: any[]; // IDataObject[]
16
-
17
- /**
18
- *
19
- */
20
- readonly isContext: boolean;
21
- /**
22
- *
23
- */
24
- readonly shortcuts: any[]; // IDataObject[]
25
- }
@@ -1,7 +0,0 @@
1
- import { Observable } from "rxjs";
2
-
3
- export interface IObjectsRepository {
4
- subscribeObjects(ids: string[]): Observable<any>;
5
- getPerson(id: number): any;
6
- }
7
-