@equinor/echo-framework 0.21.0 → 0.21.1-beta-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/echo-framework",
3
- "version": "0.21.0",
3
+ "version": "0.21.1-beta-0",
4
4
  "peerDependencies": {
5
5
  "@equinor/echo-base": ">= 0.7.0 < 0.8.0",
6
6
  "@equinor/echo-components": ">= 0.12.0 < 0.13.0",
@@ -48,24 +48,25 @@ export declare const globalSelectionApi: Readonly<{
48
48
  }>;
49
49
  add: Readonly<{
50
50
  /**
51
- * Adds tags to a specified list in the selection menu panel.
51
+ * Adds tags to a selection and updates the state accordingly.
52
+ * Creates a group if label and sublabel are passed and the group doesn't exist.
52
53
  *
53
- * @param {Object} args - The arguments for adding tags.
54
- * @param {Guid} args.groupId - Optional - The ID of the group to which the tags should be added. If not provided, it will be added to the "Local Selection".
55
- * @param {Readonly<GlobalSelectionTypes.TagId[]>} args.itemIds - An array of TagId objects representing the tags to be added.
54
+ * @param {AddTagsArgs} args - The arguments for adding tags.
55
+ * @param {Array<string>} args.itemIds - The IDs of the items to add tags to.
56
+ * @param {boolean} [args.replaceItems=false] - Whether to replace existing items with the new tags.
57
+ * @param {boolean} [args.getActionResult] - Optional, temporary. Will be removed. When passed the function will return with the actionResult as well.
58
+ * Otherwise it just returns with ResultArray<TagSummaryDto>[]>.
59
+ * @returns {Promise<AddTagsResponse>} response The response of the add tags action.
60
+ * @returns {Array<Object>} response.tagFetchResults - The results of the tag fetch operation.
61
+ * @returns {string} response.actionResult - The result of the action, if 'getActionResult' is set to true. It can be the following:
62
+ * - 'NoChanges': No new tags were added.
63
+ * - 'NewGroupCreated': A new group was created.
64
+ * - 'ItemsUpdated': Existing items were replaced with new tags.
65
+ * - 'ItemsAdded': New tags were added to the existing items.
56
66
  */
57
- tags: (args: {
58
- groupId? /**
59
- * Removes items from a specified list in the selection menu panel by their IDs.
60
- *
61
- * @param {Object} args - The arguments for removing items.
62
- * @param {Readonly<GlobalSelectionTypes.ItemId[]>} args.itemIds - An array of item IDs representing the items to be removed.
63
- * @param {Guid} args.groupId - Optional. The ID of the list where the subList of the items are located.
64
- * Local selection will be used by default.
65
- * @param {GlobalSelectionCategoryId} args.category - The ID of the list where the items to be removed are located.
66
- */: import("dist/libs/echo-utils/src").Guid;
67
- itemIds: Readonly<GlobalSelectionTypes.TagId[]>;
68
- }) => Promise<import("dist/libs/echo-search/src").ResultArray<import("dist/libs/echo-search/src").TagSummaryDto>[]>;
67
+ tags: <T extends boolean | undefined>(args: import("./selectionMenu/selectionTreeStore/actions/addTag.action.types").AddTagsArgs & {
68
+ getActionResult?: T;
69
+ }) => Promise<import("./selectionMenu/selectionTreeStore/selectionTree.store.types").AddTagsReturnType<T>>;
69
70
  /**
70
71
  * Adds work orders to a specified list in the selection menu panel.
71
72
  *
@@ -86,7 +87,16 @@ export declare const globalSelectionApi: Readonly<{
86
87
  *
87
88
  */
88
89
  addItems: (args: {
89
- groupId?: import("dist/libs/echo-utils/src").Guid;
90
+ groupId? /**
91
+ * Removes a group or category by ID from the selection store.
92
+ *
93
+ * If a categoryId is provided, it removes all items from the specified category within the group.
94
+ * If no categoryId is provided, it removes the entire group and all its items.
95
+ *
96
+ * @param {Object} args - The function arguments.
97
+ * @param {Guid} args.groupId - The ID of the group to remove.
98
+ * @param {GlobalSelectionCategoryId} [args.categoryId] - The ID of the category to remove (optional).
99
+ */: import("dist/libs/echo-utils/src").Guid;
90
100
  itemIds: (GlobalSelectionTypes.TagId | import("./globalSelectionStore/globalSelectionStore.types").OptimizedWorkOrderDto)[];
91
101
  }) => void;
92
102
  }>;
@@ -179,6 +189,6 @@ export declare const globalSelectionApi: Readonly<{
179
189
  clearSelection: () => void;
180
190
  createGroup: (args: {
181
191
  label: string;
182
- subLabel?: string;
183
- }) => import("dist/libs/echo-utils/src").Guid | undefined;
192
+ subLabel: string;
193
+ }) => import("dist/libs/echo-utils/src").Guid;
184
194
  }>;
@@ -47,7 +47,7 @@ export interface GlobalSelectionStore {
47
47
  }) => void;
48
48
  addTagsToSelection: (args: {
49
49
  tagIds: Readonly<GlobalSelectionTypes.TagId[]>;
50
- }) => Promise<ResultArray<TagSummaryDto>[]>;
50
+ }) => Promise<AddTagActionResult>;
51
51
  removeItemsFromSelection: (args: {
52
52
  itemIds: ReadonlyArray<GlobalSelectionTypes.ItemId>;
53
53
  }) => void;
@@ -64,6 +64,11 @@ export interface GlobalSelectionStore {
64
64
  itemIds: Readonly<GlobalSelectionTypes.ItemId[]>;
65
65
  }) => void;
66
66
  }
67
+ type GlobalSelectionActionResult = 'NoChanges' | 'ItemsAdded';
68
+ type AddTagActionResult = {
69
+ fetchResult: ResultArray<TagSummaryDto>[];
70
+ actionResult: GlobalSelectionActionResult;
71
+ };
67
72
  export declare namespace GlobalSelectionTypes {
68
73
  type WorkOrderId = Pick<OptimizedWorkOrderDto, 'workOrderId'>;
69
74
  type EquipmentId = Pick<Equipment, 'equipmentId'>;
@@ -83,6 +88,7 @@ export declare namespace GlobalSelectionTypes {
83
88
  type EquipmentList = EquipmentGlobalSelectionList;
84
89
  type ListUnion = GlobalSelectionListUnion;
85
90
  type ItemTypeToDataMap = GlobalSelectionItemTypeToDataMap;
91
+ type AddTagResult = AddTagActionResult;
86
92
  }
87
93
  export interface OptimizedWorkOrderDto {
88
94
  workOrderId: string;
@@ -0,0 +1,13 @@
1
+ import { ResultArray, TagSummaryDto } from '@equinor/echo-search';
2
+ import { WritableDraft } from 'immer';
3
+ import { StoreApi } from 'zustand';
4
+ import { SelectionTreeStore } from '../selectionTree.store.types';
5
+ import { AddTagsArgs, AddTagsResponse } from './addTag.action.types';
6
+ type SetFunction = (set: (state: WritableDraft<SelectionTreeStore>) => void, shouldReplace?: boolean | undefined, action?: string) => void;
7
+ export declare function addTagsAction(set: SetFunction, get: StoreApi<SelectionTreeStore>['getState'], args: AddTagsArgs & {
8
+ getActionResult: true;
9
+ }): Promise<AddTagsResponse>;
10
+ export declare function addTagsAction(set: SetFunction, get: StoreApi<SelectionTreeStore>['getState'], args: AddTagsArgs & {
11
+ getActionResult?: false;
12
+ }): Promise<ResultArray<TagSummaryDto>[]>;
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ResultArray, TagSummaryDto } from '@equinor/echo-search';
2
+ import { GlobalSelectionTypes } from '../../../globalSelectionStore/globalSelectionStore.types';
3
+ export type AddTagsArgs = {
4
+ itemIds: Readonly<GlobalSelectionTypes.TagId[]>;
5
+ replaceItems?: boolean;
6
+ getActionResult?: boolean;
7
+ } & ({
8
+ label: string;
9
+ subLabel: string;
10
+ } | {
11
+ label?: undefined;
12
+ subLabel?: undefined;
13
+ });
14
+ export type AddTagsResponse = {
15
+ fetchResults: ResultArray<TagSummaryDto>[];
16
+ actionResult: SelectionTreeActionResult;
17
+ };
18
+ export type SelectionTreeActionResult = 'ItemsUpdated' | 'ItemsAdded' | 'NewGroupCreated' | 'NoChanges';
@@ -0,0 +1,10 @@
1
+ import { SelectionCategory, SelectionGroup } from './selectionTree.store.types';
2
+ export declare const selectionTreeInitialData: Readonly<{
3
+ localSelectionGroup: SelectionGroup;
4
+ categoryOrder: {
5
+ tagIndex: number;
6
+ workOrderIndex: number;
7
+ };
8
+ localSelectionGroupIndex: 0;
9
+ getInitialCategories: () => SelectionCategory[];
10
+ }>;
@@ -1,19 +1,4 @@
1
1
  import { SelectionTreeStore } from './selectionTree.store.types';
2
- /**
3
- * Store for the selection menu, in a left panel.
4
- *
5
- * Stores the hierachry, tree structure of the items in Global Selection.
6
- * With this, it is in charge of:
7
- * - tracking which item belongs to which list
8
- * - adding items to global selection
9
- * - remove items from global selection
10
- * - update items (visibility, removal etc.) via list ids
11
- * - maintaining the global selection store based on the changes in the items, in the selection menu panel
12
- *
13
- * You shouldn't use this store directly in any code, unless you have very special reason to do so.
14
- *
15
- * For accessing and using global selection features, use the globalSelectionApi from echo-framework.
16
- */
17
2
  export declare const useSelectionTreeStore: import("zustand").UseBoundStore<Omit<Omit<Omit<import("zustand").StoreApi<SelectionTreeStore>, "setState"> & {
18
3
  setState<A extends string | {
19
4
  type: string;
@@ -1,7 +1,8 @@
1
1
  import { ResultArray, TagSummaryDto } from '@equinor/echo-search';
2
2
  import { Guid } from '@equinor/echo-utils';
3
3
  import { GlobalSelectionItemType, GlobalSelectionTypes, OptimizedWorkOrderDto } from '../../globalSelectionStore/globalSelectionStore.types';
4
- type SelectionItem = SelectionItemTag | SelectionItemWorkOrder | SelectionItemEquipment;
4
+ import { AddTagsArgs, AddTagsResponse, SelectionTreeActionResult } from './actions/addTag.action.types';
5
+ type SelectionItem = SelectionMenuTag | SelectionMenuWorkOrder | SelectionMenuEquipment;
5
6
  export declare enum GlobalSelectionCategoryId {
6
7
  Tags = "DEFAULT_TAG_LIST_ID",
7
8
  WorkOrders = "DEFAULT_WORK_ORDER_LIST_ID"
@@ -12,15 +13,15 @@ export declare enum SelectionMenuDefaultListIds {
12
13
  TagList = "DEFAULT_TAG_LIST_ID",
13
14
  WorkOrderList = "DEFAULT_WORK_ORDER_LIST_ID"
14
15
  }
15
- interface SelectionItemTag {
16
+ export interface SelectionMenuTag {
16
17
  id: GlobalSelectionTypes.TagId;
17
18
  type: GlobalSelectionItemType.Tag;
18
19
  }
19
- interface SelectionItemWorkOrder {
20
+ export interface SelectionMenuWorkOrder {
20
21
  id: GlobalSelectionTypes.WorkOrderId;
21
22
  type: GlobalSelectionItemType.WorkOrder;
22
23
  }
23
- interface SelectionItemEquipment {
24
+ export interface SelectionMenuEquipment {
24
25
  id: GlobalSelectionTypes.EquipmentId;
25
26
  type: GlobalSelectionItemType.Equipment;
26
27
  }
@@ -28,20 +29,19 @@ interface SelectionBase {
28
29
  label: string;
29
30
  subLabel?: string;
30
31
  }
31
- interface SelectionCategory extends SelectionBase {
32
+ export interface SelectionCategory extends SelectionBase {
32
33
  id: GlobalSelectionCategoryId;
33
34
  items: SelectionItem[];
34
35
  }
35
- interface SelectionGroup extends SelectionBase {
36
+ export interface SelectionGroup extends SelectionBase {
36
37
  id: Guid;
37
38
  categories: SelectionCategory[];
38
39
  }
39
40
  export interface SelectionTreeStore {
40
41
  groups: SelectionGroup[];
41
- addTags: (args: {
42
- groupId?: Guid;
43
- itemIds: Readonly<GlobalSelectionTypes.TagId[]>;
44
- }) => Promise<ResultArray<TagSummaryDto>[]>;
42
+ addTags: <T extends boolean | undefined>(args: AddTagsArgs & {
43
+ getActionResult?: T;
44
+ }) => Promise<AddTagsReturnType<T>>;
45
45
  addWorkOrders: (args: {
46
46
  groupId?: Guid;
47
47
  items: Readonly<Readonly<OptimizedWorkOrderDto>[]>;
@@ -52,8 +52,8 @@ export interface SelectionTreeStore {
52
52
  }) => void;
53
53
  createGroup: (args: {
54
54
  label: string;
55
- subLabel?: string;
56
- }) => Guid | undefined;
55
+ subLabel: string;
56
+ }) => Guid;
57
57
  removeGroupById: (args: {
58
58
  groupId: Guid;
59
59
  categoryId?: GlobalSelectionCategoryId;
@@ -77,8 +77,7 @@ export declare namespace SelectionTreeTypes {
77
77
  type Category = SelectionCategory;
78
78
  type Group = SelectionGroup;
79
79
  type Item = SelectionItem;
80
- type TagItem = SelectionItemTag;
81
- type WorkOrderItem = SelectionItemWorkOrder;
82
- type EquipmentItem = SelectionItemEquipment;
80
+ type ActionResult = SelectionTreeActionResult;
83
81
  }
82
+ export type AddTagsReturnType<T extends boolean | undefined> = T extends true ? Promise<AddTagsResponse> : Promise<ResultArray<TagSummaryDto>[]>;
84
83
  export {};
@@ -1,5 +1,6 @@
1
+ import { Guid } from '@equinor/echo-utils';
1
2
  import { GlobalSelectionTypes } from '../../globalSelectionStore/globalSelectionStore.types';
2
- import { SelectionTreeTypes } from './selectionTree.store.types';
3
+ import { GlobalSelectionCategoryId, SelectionTreeTypes } from './selectionTree.store.types';
3
4
  /**
4
5
  * Check if an item ID is present in the selection tree.
5
6
  *
@@ -51,3 +52,19 @@ export declare function itemsNotFoundInSelectionTree(args: {
51
52
  groups: SelectionTreeTypes.Group[];
52
53
  itemIds: GlobalSelectionTypes.ItemId[];
53
54
  }): GlobalSelectionTypes.ItemId[];
55
+ /**
56
+ * Checks if the items in a given group's category are the same as the provided item IDs.
57
+ *
58
+ * @param args - The arguments object.
59
+ * @param args.itemIds - An array of item IDs to compare.
60
+ * @param args.groups - An array of groups to search within.
61
+ * @param args.groupId - The ID of the group to check.
62
+ * @param args.categoryId - The ID of the category within the group to check.
63
+ * @returns `true` if the items in the group are the same as the provided item IDs, otherwise `false`.
64
+ */
65
+ export declare function areItemsTheSameInGroup(args: {
66
+ itemIds: GlobalSelectionTypes.TagId[];
67
+ groups: SelectionTreeTypes.Group[];
68
+ groupId: Guid;
69
+ categoryId: GlobalSelectionCategoryId;
70
+ }): boolean;