@pilotdev/pilot-web-sdk 23.0.0-alpha.2 → 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 (84) hide show
  1. package/.eslintrc.json +31 -0
  2. package/README.md +24 -5
  3. package/ng-package.json +7 -0
  4. package/package.json +6 -25
  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 +2 -0
  23. package/src/lib/injectable/index.ts +4 -0
  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 +15 -0
  29. package/{lib/menu/index.d.ts → src/lib/menu/index.ts} +5 -4
  30. package/src/lib/menu/menu-item.builder.ts +45 -0
  31. package/src/lib/menu/menu.builder.ts +79 -0
  32. package/src/lib/menu/menu.ts +24 -0
  33. package/{lib/toolbar/index.d.ts → src/lib/toolbar/index.ts} +7 -6
  34. package/src/lib/toolbar/toolbar-item-submenu.handler.ts +12 -0
  35. package/src/lib/toolbar/toolbar-item.builder.ts +45 -0
  36. package/src/lib/toolbar/toolbar-menu-item.builder.ts +16 -0
  37. package/src/lib/toolbar/toolbar-toggle-item.builder.ts +15 -0
  38. package/src/lib/toolbar/toolbar.builder.ts +104 -0
  39. package/src/lib/toolbar/toolbar.ts +31 -0
  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 -0
  45. package/tsconfig.lib.json +15 -0
  46. package/tsconfig.lib.prod.json +10 -0
  47. package/esm2020/lib/context.mjs +0 -11
  48. package/esm2020/lib/idata.plugin.mjs +0 -2
  49. package/esm2020/lib/injectable/index.mjs +0 -2
  50. package/esm2020/lib/injectable/objects.repository.mjs +0 -2
  51. package/esm2020/lib/menu/checkable-menu.builder.mjs +0 -14
  52. package/esm2020/lib/menu/index.mjs +0 -5
  53. package/esm2020/lib/menu/menu-item.builder.mjs +0 -39
  54. package/esm2020/lib/menu/menu.builder.mjs +0 -68
  55. package/esm2020/lib/menu/menu.mjs +0 -22
  56. package/esm2020/lib/toolbar/index.mjs +0 -7
  57. package/esm2020/lib/toolbar/toolbar-item-submenu.handler.mjs +0 -3
  58. package/esm2020/lib/toolbar/toolbar-item.builder.mjs +0 -41
  59. package/esm2020/lib/toolbar/toolbar-menu-item.builder.mjs +0 -15
  60. package/esm2020/lib/toolbar/toolbar-toggle-item.builder.mjs +0 -14
  61. package/esm2020/lib/toolbar/toolbar.builder.mjs +0 -88
  62. package/esm2020/lib/toolbar/toolbar.mjs +0 -27
  63. package/esm2020/pilotdev-pilot-web-sdk.mjs +0 -5
  64. package/esm2020/public-api.mjs +0 -9
  65. package/fesm2015/pilotdev-pilot-web-sdk.mjs +0 -349
  66. package/fesm2015/pilotdev-pilot-web-sdk.mjs.map +0 -1
  67. package/fesm2020/pilotdev-pilot-web-sdk.mjs +0 -349
  68. package/fesm2020/pilotdev-pilot-web-sdk.mjs.map +0 -1
  69. package/index.d.ts +0 -5
  70. package/lib/context.d.ts +0 -18
  71. package/lib/idata.plugin.d.ts +0 -2
  72. package/lib/injectable/index.d.ts +0 -1
  73. package/lib/injectable/objects.repository.d.ts +0 -5
  74. package/lib/menu/checkable-menu.builder.d.ts +0 -11
  75. package/lib/menu/menu-item.builder.d.ts +0 -27
  76. package/lib/menu/menu.builder.d.ts +0 -49
  77. package/lib/menu/menu.d.ts +0 -18
  78. package/lib/toolbar/toolbar-item-submenu.handler.d.ts +0 -2
  79. package/lib/toolbar/toolbar-item.builder.d.ts +0 -28
  80. package/lib/toolbar/toolbar-menu-item.builder.d.ts +0 -13
  81. package/lib/toolbar/toolbar-toggle-item.builder.d.ts +0 -11
  82. package/lib/toolbar/toolbar.builder.d.ts +0 -65
  83. package/lib/toolbar/toolbar.d.ts +0 -19
  84. package/public-api.d.ts +0 -5
@@ -0,0 +1,74 @@
1
+ import { Observable } from "rxjs";
2
+ import { AccessLevel } from "../data/access";
3
+ import { IDataObject, IPerson, IType, IOrganizationUnit } from "../data";
4
+
5
+ /**
6
+ * Represents the repository that provides access to objects, types, organisation units and people
7
+ */
8
+ export interface IObjectsRepository {
9
+ /**
10
+ * Get objects with specified ids
11
+ *
12
+ * @param ids Ids of objects to subsribe
13
+ * @returns
14
+ */
15
+ getObjects(ids: string[]): Observable<IDataObject[]>;
16
+ /**
17
+ * Get object's access for the person
18
+ *
19
+ * @param objectId Object id
20
+ * @param personId Person Id
21
+ * @returns Cold Observable
22
+ */
23
+ getCurrentAccess(objectId: string, personId: number): Observable<AccessLevel>
24
+ /**
25
+ * Gets the person with specified id
26
+ *
27
+ * @param id Person id
28
+ * @returns Person
29
+ */
30
+ getPerson(id: number): IPerson;
31
+ /**
32
+ * Gets the current person
33
+ *
34
+ * @returns Person
35
+ */
36
+ getCurrentPerson(): IPerson
37
+ /**
38
+ * Gets all the people registred in database
39
+ *
40
+ * @returns Person[]
41
+ */
42
+ getPeople(): IPerson[]
43
+ /**
44
+ * Gets type by identifier
45
+ *
46
+ * @returns Type
47
+ */
48
+ getType(id: number): IType
49
+ /**
50
+ * Gets type by name
51
+ *
52
+ * @returns Type
53
+ */
54
+ getTypeByName(name: string): IType
55
+ /**
56
+ * Gets all the types registered in database
57
+ *
58
+ * @returns Type[]
59
+ */
60
+ getTypes(): IType[];
61
+ /**
62
+ * Gets organisation unit by identifier
63
+ *
64
+ * @returns OrganisationUnit
65
+ */
66
+ getOrganisationUnit(id: number): IOrganizationUnit;
67
+ /**
68
+ * Get all the organisation units registered in database
69
+ *
70
+ * @returns OrganisationUnit
71
+ */
72
+ getOrganisationUnits(): IOrganizationUnit[];
73
+ }
74
+
@@ -0,0 +1,11 @@
1
+ import { RenderContext } from "../contexts/render-context";
2
+
3
+ /**
4
+ * Provides render context
5
+ */
6
+ export interface IRenderContextProvider {
7
+ /**
8
+ *
9
+ */
10
+ getRenderContext(): RenderContext;
11
+ }
@@ -0,0 +1,33 @@
1
+ import { Observable } from "rxjs";
2
+ import { IDataObject, IPerson, IType, IOrganizationUnit } from "../data";
3
+
4
+
5
+ /**
6
+ * Notifies on change events
7
+ */
8
+ export interface IRepositoryEvents {
9
+ /**
10
+ * Subsribes to changes in objects with specified identifiers
11
+ *
12
+ * @returns Hot observable
13
+ */
14
+ subscribeObjects(ids: string[]): Observable<IDataObject>;
15
+ /**
16
+ * Subsribes to changes in people
17
+ *
18
+ * @returns Hot observable
19
+ */
20
+ subscribePeople(): Observable<IPerson>
21
+ /**
22
+ * Subsribes to changes in types
23
+ *
24
+ * @returns Hot observable
25
+ */
26
+ subscribeTypes(): Observable<IType>
27
+ /**
28
+ * Subsribes to changes in organisation units
29
+ *
30
+ * @returns Hot observable
31
+ */
32
+ subscribeOrganisationUnits(): Observable<IOrganizationUnit>
33
+ }
@@ -0,0 +1,15 @@
1
+ import { IMenuItemBuilder } from "./menu-item.builder";
2
+
3
+ /**
4
+ *
5
+ */
6
+ export abstract class ICheckableMenuItemBuilder extends IMenuItemBuilder {
7
+
8
+ /**
9
+ *
10
+ * @param value
11
+ */
12
+ withIsChecked(value: boolean): ICheckableMenuItemBuilder {
13
+ throw new Error("Method 'withIsChecked(value: boolean)' must be implemented.");
14
+ }
15
+ }
@@ -1,4 +1,5 @@
1
- export * from './menu';
2
- export * from './checkable-menu.builder';
3
- export * from './menu-item.builder';
4
- export * from './menu.builder';
1
+
2
+ export * from './menu';
3
+ export * from './checkable-menu.builder';
4
+ export * from './menu-item.builder';
5
+ export * from './menu.builder';
@@ -0,0 +1,45 @@
1
+ import { IMenuBuilder } from "./menu.builder";
2
+
3
+ /**
4
+ * Represents a menu item and enables to set parametres to it
5
+ */
6
+ export abstract class IMenuItemBuilder {
7
+
8
+ constructor() {
9
+ if (this.constructor == IMenuItemBuilder) {
10
+ throw new Error("Abstract classes can't be instantiated.");
11
+ }
12
+ }
13
+
14
+ /**
15
+ * Item's name to be displayed
16
+ * @param header value
17
+ */
18
+ withHeader(header: string): IMenuItemBuilder {
19
+ throw new Error("Method 'withHeader(header: string)' must be implemented.");
20
+ }
21
+
22
+ /**
23
+ * Item's icon
24
+ * @param name Icon name
25
+ * @param iconSvg Url of icon or base64 string
26
+ */
27
+ withIcon(name: string, iconSvg: string): IMenuItemBuilder {
28
+ throw new Error("Method 'withIcon(name: string, iconSvg: string)' must be implemented.");
29
+ }
30
+
31
+ /**
32
+ * Enabled the item
33
+ * @param value value
34
+ */
35
+ withIsEnabled(value: boolean): IMenuItemBuilder {
36
+ throw new Error("Method 'withIsEnabled(value: boolean)' must be implemented.");
37
+ }
38
+
39
+ /**
40
+ * Item's submenu
41
+ */
42
+ withSubmenu(): IMenuBuilder {
43
+ throw new Error("Method 'withSubmenu()' must be implemented.");
44
+ }
45
+ }
@@ -0,0 +1,79 @@
1
+ import { ICheckableMenuItemBuilder } from "./checkable-menu.builder";
2
+ import { IMenuItemBuilder } from "./menu-item.builder";
3
+
4
+ /**
5
+ * Represents a menu and enables to add new items to it
6
+ */
7
+ export abstract class IMenuBuilder {
8
+
9
+ constructor() {
10
+ if (this.constructor == IMenuBuilder) {
11
+ throw new Error("Abstract classes can't be instantiated.");
12
+ }
13
+ }
14
+
15
+ /**
16
+ * Gets the list of existing items of associated menu or subitems of an item
17
+ * @returns Existing menu item names
18
+ */
19
+ get itemNames(): string[] {
20
+ throw new Error("Getter 'itemNames()' must be implemented.");
21
+ }
22
+
23
+ /**
24
+ * Gets count of menu items
25
+ */
26
+ get count(): number {
27
+ throw new Error("Getter 'count()' must be implemented.");
28
+ }
29
+
30
+ /**
31
+ * Adds a new separator to the associated menu
32
+ * @param index The index to put the new item at
33
+ */
34
+ addSeparator(index: number): void {
35
+ throw new Error("Method 'addSeparator(index: number)' must be implemented.");
36
+ }
37
+
38
+ /**
39
+ * Adds a new item to the associated menu
40
+ * @param name Item's internal name
41
+ * @param index The index to put the new item at
42
+ */
43
+ addItem(name: string, index: number): IMenuItemBuilder {
44
+ throw new Error("Method 'addItem(name: string, index: number)' must be implemented.");
45
+ }
46
+
47
+ /**
48
+ * Adds a new checkable item to the associated menu
49
+ * @param name Item's internal name
50
+ * @param index The index to put the new item at
51
+ */
52
+ addCheckableItem(name: string, index: number): ICheckableMenuItemBuilder {
53
+ throw new Error("Method 'addCheckableItem(name: string, index: number)' must be implemented.");
54
+ }
55
+
56
+ /**
57
+ * Replaces the item to the associated menu
58
+ * @param name Item's internal name
59
+ */
60
+ replaceItem(name: string): IMenuItemBuilder {
61
+ throw new Error("Method 'replaceItem(name: string)' must be implemented.");
62
+ }
63
+
64
+ /**
65
+ * Removes the item with the specified name
66
+ * @param name Item's internal name
67
+ */
68
+ removeItem(name: string): void {
69
+ throw new Error("Method 'removeItem(name: string)' must be implemented.");
70
+ }
71
+
72
+ /**
73
+ * Gets the item
74
+ * @param name Item's internal name
75
+ */
76
+ getItem(name: string): IMenuBuilder {
77
+ throw new Error("Method 'getItem(name: string)' must be implemented.");
78
+ }
79
+ }
@@ -0,0 +1,24 @@
1
+ import { IMenuBuilder } from "./menu.builder";
2
+
3
+ /**
4
+ * Interface that allows to add new items to the menu and context menus
5
+ */
6
+ export abstract class IMenu<TMenuContext> {
7
+ /**
8
+ * The method is called just before the menu is shown
9
+ * @param builder The menu builder object of associated menu
10
+ * @param context Context
11
+ */
12
+ build(builder: IMenuBuilder, context: TMenuContext): void {
13
+ throw new Error("Method 'build(builder: IMenuBuilder, context: TMenuContext)' must be implemented.");
14
+ }
15
+
16
+ /**
17
+ *
18
+ * @param name
19
+ * @param context
20
+ */
21
+ onMenuItemClick(name: string, context: TMenuContext): void {
22
+ throw new Error("Method 'onMenuItemClick(name: string, context: TMenuContext)' must be implemented.");
23
+ }
24
+ }
@@ -1,6 +1,7 @@
1
- export * from './toolbar';
2
- export * from './toolbar-item.builder';
3
- export * from './toolbar-item-submenu.handler';
4
- export * from './toolbar-menu-item.builder';
5
- export * from './toolbar-toggle-item.builder';
6
- export * from './toolbar.builder';
1
+
2
+ export * from './toolbar';
3
+ export * from './toolbar-item.builder';
4
+ export * from './toolbar-item-submenu.handler';
5
+ export * from './toolbar-menu-item.builder';
6
+ export * from './toolbar-toggle-item.builder';
7
+ export * from './toolbar.builder';
@@ -0,0 +1,12 @@
1
+ import { IToolbarBuilder } from "./toolbar.builder";
2
+
3
+ export abstract class IToolbarItemSubmenuHandler {
4
+ /**
5
+ * Build a submenu
6
+ * @param builder - toolbar builder
7
+ * @returns
8
+ */
9
+ onSubmenuRequested(builder: IToolbarBuilder): void {
10
+ throw new Error("Method 'onSubmenuRequested(builder: IToolbarBuilder)' must be implemented.");
11
+ }
12
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Represents a toolbar button and enables to set parametres to it
3
+ */
4
+ export abstract class IToolbarButtonItemBuilder {
5
+
6
+ constructor() {
7
+ if (this.constructor == IToolbarButtonItemBuilder) {
8
+ throw new Error("Abstract classes can't be instantiated.");
9
+ }
10
+ }
11
+
12
+ /**
13
+ * Item's name to be displayed
14
+ * @param header - value
15
+ * @returns instance of IToolbarButtonItemBuilder
16
+ */
17
+ withHeader(header: string): IToolbarButtonItemBuilder {
18
+ throw new Error("Method 'withHeader(header: string)' must be implemented.");
19
+ }
20
+
21
+ /**
22
+ * Item's icon in SVG format
23
+ * @param name - icon name
24
+ * @param svg - url icon or base64 string
25
+ */
26
+ withIcon(name: string, svg: string): IToolbarButtonItemBuilder {
27
+ throw new Error("Method 'withIcon(name: string, svg: string)' must be implemented.");
28
+ }
29
+
30
+ /**
31
+ * Enabled the item
32
+ * @param value - value
33
+ */
34
+ withIsEnabled(value: boolean): IToolbarButtonItemBuilder {
35
+ throw new Error("Method 'withIsEnabled(value: boolean)' must be implemented.");
36
+ }
37
+
38
+ /**
39
+ * Item's hint
40
+ * @param hint - value
41
+ */
42
+ withHint(hint: string): IToolbarButtonItemBuilder {
43
+ throw new Error("Method 'withHint(hint: string)' must be implemented.");
44
+ }
45
+ }
@@ -0,0 +1,16 @@
1
+ import { IToolbarButtonItemBuilder } from "./toolbar-item.builder";
2
+ import { IToolbarItemSubmenuHandler } from "./toolbar-item-submenu.handler";
3
+
4
+ /**
5
+ * Represents a toolbar menu button and enables to set parametres to it
6
+ */
7
+ export abstract class IToolbarMenuButtonItemBuilder extends IToolbarButtonItemBuilder {
8
+ /**
9
+ * Build a dropdown menu
10
+ * @param itemSubmenuHandler - toolbar submenu handler
11
+ * @returns The toolbar button menu builder
12
+ */
13
+ withMenu(itemSubmenuHandler: IToolbarItemSubmenuHandler): IToolbarMenuButtonItemBuilder {
14
+ throw new Error("Method 'withMenu(itemSubmenuHandler: IToolbarItemSubmenuHandler)' must be implemented.");
15
+ }
16
+ }
@@ -0,0 +1,15 @@
1
+ import { IToolbarButtonItemBuilder } from "./toolbar-item.builder";
2
+
3
+ /**
4
+ * Represents a toolbar toggle button and enables to set parametres to it
5
+ */
6
+ export abstract class IToolbarToggleButtonItemBuilder extends IToolbarButtonItemBuilder {
7
+
8
+ /**
9
+ *
10
+ * @param value
11
+ */
12
+ withIsChecked(value: boolean): IToolbarToggleButtonItemBuilder {
13
+ throw new Error("Method 'withIsChecked(value: boolean)' must be implemented.");
14
+ }
15
+ }
@@ -0,0 +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
+ }
104
+ }
@@ -0,0 +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
+ }
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
+ }
@@ -0,0 +1,10 @@
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';