awing-library 2.1.2-dev.547 → 2.1.2-dev.548

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.
@@ -9,7 +9,7 @@ var __webpack_modules__ = {
9
9
  "AWING/DataInput": function(module) {
10
10
  module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
11
11
  },
12
- "../helper": function(module) {
12
+ "AWING/helper": function(module) {
13
13
  module.exports = __WEBPACK_EXTERNAL_MODULE__helper_js_663c9e82__;
14
14
  }
15
15
  };
@@ -92,9 +92,9 @@ jest.mock('@mui/material', ()=>({
92
92
  })
93
93
  }));
94
94
  const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
95
- const mockCalculateValue = __webpack_require__("../helper").calculateValue;
96
- const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
97
- const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
95
+ const mockCalculateValue = __webpack_require__("AWING/helper").calculateValue;
96
+ const mockConvertFormulaToBinaryTree = __webpack_require__("AWING/helper").convertFormulaToBinaryTree;
97
+ const mockReplaceFieldsValue = __webpack_require__("AWING/helper").replaceFieldsValue;
98
98
  describe('DataForm Component', ()=>{
99
99
  const mockFields = [
100
100
  {
@@ -1 +1 @@
1
- {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Directory/Container.tsx"],"names":[],"mappings":"AAmBA,iBAAS,SAAS,4CAoVjB;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../src/Features/SYSTEM/Directory/Container.tsx"],"names":[],"mappings":"AAmBA,iBAAS,SAAS,4CA6UjB;AAED,eAAe,SAAS,CAAC"}
@@ -6,7 +6,7 @@ import { Direction } from "../../types.js";
6
6
  import { FilterOperationType, convertArrayFiltersToCondition } from "../../../Helpers/index.js";
7
7
  import { useAtom } from "jotai";
8
8
  import { includes, isUndefined, unionWith } from "lodash";
9
- import { useCallback, useEffect, useLayoutEffect, useState } from "react";
9
+ import { useCallback, useEffect, useRef, useState } from "react";
10
10
  import { Route, Routes } from "react-router";
11
11
  import { handleSagaMessage } from "../../../Utils/helper.js";
12
12
  import { directoriesState } from "./Atoms.js";
@@ -33,28 +33,17 @@ function Container_Container() {
33
33
  searchKey: '',
34
34
  advancedObject: void 0
35
35
  });
36
+ const servicesRef = useRef(services);
36
37
  useEffect(()=>{
37
- const workspaceId = currentWorkspace?.id || 0;
38
- const workspace = directories.find((dir)=>dir.id === workspaceId);
39
- const take = workspace?.childCount;
40
- queryData(workspaceId, 1, void 0, 0, take);
41
- }, [
42
- currentWorkspace?.id
43
- ]);
44
- useEffect(()=>{
45
- if (parentDirectoryId) {
46
- const parentDir = directories.find((dir)=>dir.id === parentDirectoryId);
47
- const take = parentDir?.childCount;
48
- queryData(parentDirectoryId, 1, void 0, 0, take);
49
- }
38
+ servicesRef.current = services;
50
39
  }, [
51
- parentDirectoryId
40
+ services
52
41
  ]);
53
- const queryData = async (directoryId, depthFromRoot = 1, deleteId, skipCount = 0, take = 999)=>{
42
+ const queryData = useCallback(async (directoryId, depthFromRoot = 1, deleteId, skipCount = 0, take = 999)=>{
54
43
  const queryDepthFromRoot = -1 === depthFromRoot ? {} : {
55
44
  depthFromRoot
56
45
  };
57
- await services?.getDirectories({
46
+ await servicesRef.current?.getDirectories({
58
47
  input: {
59
48
  where: {
60
49
  ...convertArrayFiltersToCondition([
@@ -79,10 +68,10 @@ function Container_Container() {
79
68
  ...queryDepthFromRoot
80
69
  }).then((data)=>{
81
70
  setLoadingDirectories(false);
82
- if (!directoryIdQueried.includes(directoryId)) setDirectoryIdQueried([
83
- ...directoryIdQueried,
84
- directoryId
85
- ]);
71
+ setDirectoryIdQueried((prev)=>prev.includes(directoryId) ? prev : [
72
+ ...prev,
73
+ directoryId
74
+ ]);
86
75
  setDirectoryPagination((prev)=>({
87
76
  ...prev,
88
77
  [directoryId]: {
@@ -90,17 +79,19 @@ function Container_Container() {
90
79
  hasMore: 10 === data.items.length
91
80
  }
92
81
  }));
93
- const result = unionWith(getFormatDirectoriesData(data.items), directories.filter((item)=>item.id !== deleteId), (a, b)=>a.id === b.id);
94
- setDirectories(result);
82
+ setDirectories((oldDirectories)=>unionWith(getFormatDirectoriesData(data.items), oldDirectories.filter((item)=>item.id !== deleteId), (a, b)=>a.id === b.id));
95
83
  });
96
- };
84
+ }, [
85
+ currentWorkspace?.id,
86
+ setDirectories
87
+ ]);
97
88
  const queryChildDirectoriesData = useCallback(async (newFocusDirectoryId, newPageIndex, newPageSize, depthFromRoot = 1, searchKey = '', objectTypeCode)=>{
98
89
  setLoadingChildDirectories(true);
99
90
  setLoadingDirectoryId(newFocusDirectoryId);
100
91
  const queryDepthFromRoot = -1 === depthFromRoot ? {} : {
101
92
  depthFromRoot
102
93
  };
103
- await services?.getDirectories({
94
+ await servicesRef.current?.getDirectories({
104
95
  input: {
105
96
  where: {
106
97
  ...convertArrayFiltersToCondition([
@@ -139,6 +130,17 @@ function Container_Container() {
139
130
  setChildDirectoriesTotal(data.total);
140
131
  });
141
132
  }, []);
133
+ useEffect(()=>{
134
+ const workspaceId = currentWorkspace?.id || 0;
135
+ const effectiveId = parentDirectoryId || workspaceId;
136
+ if (effectiveId) {
137
+ setDirectories([]);
138
+ queryData(effectiveId);
139
+ }
140
+ }, [
141
+ currentWorkspace?.id,
142
+ parentDirectoryId
143
+ ]);
142
144
  const handleChildrenSearch = (data)=>{
143
145
  if (!data) return;
144
146
  const { searchKey = '', advancedObject } = data;
@@ -201,9 +203,15 @@ function Container_Container() {
201
203
  setPageSize(newPageSize);
202
204
  isSearch(searchValue) ? queryChildDirectoriesData(focusDirectoryId, 0, newPageSize, -1, searchValue.searchKey, searchValue?.advancedObject?.objectTypeCode?.value.value) : queryChildDirectoriesData(focusDirectoryId, 0, newPageSize);
203
205
  };
204
- useLayoutEffect(()=>{
205
- setDirectories([]);
206
- }, []);
206
+ const handleUpdateDirectories = useCallback((parentDirId)=>{
207
+ if (!isUndefined(parentDirId)) {
208
+ queryData(parentDirId);
209
+ queryChildDirectoriesData(parentDirId, 0, Constants.PAGE_SIZE_DEFAULT);
210
+ }
211
+ }, [
212
+ queryData,
213
+ queryChildDirectoriesData
214
+ ]);
207
215
  return /*#__PURE__*/ jsxs(Fragment, {
208
216
  children: [
209
217
  /*#__PURE__*/ jsx(TreeView, {
@@ -240,12 +248,7 @@ function Container_Container() {
240
248
  createDirectory: services.createDirectory,
241
249
  getDirectoryById: services.getDirectoryById,
242
250
  updateDirectory: services.updateDirectory,
243
- onUpdateDirectories: (parentDirectoryId)=>{
244
- if (!isUndefined(parentDirectoryId)) {
245
- queryData(parentDirectoryId);
246
- queryChildDirectoriesData(parentDirectoryId ?? 0, 0, Constants.PAGE_SIZE_DEFAULT);
247
- }
248
- }
251
+ onUpdateDirectories: handleUpdateDirectories
249
252
  })
250
253
  }, external_constants_js_Constants.CREATE_PATH + '/:directoryId'),
251
254
  /*#__PURE__*/ jsx(Route, {
@@ -254,10 +257,7 @@ function Container_Container() {
254
257
  createDirectory: services.createDirectory,
255
258
  getDirectoryById: services.getDirectoryById,
256
259
  updateDirectory: services.updateDirectory,
257
- onUpdateDirectories: (parentDirectoryId)=>{
258
- isUndefined(parentDirectoryId) || queryData(parentDirectoryId);
259
- queryChildDirectoriesData(parentDirectoryId ?? 0, 0, Constants.PAGE_SIZE_DEFAULT);
260
- }
260
+ onUpdateDirectories: handleUpdateDirectories
261
261
  })
262
262
  }, external_constants_js_Constants.EDIT_PATH + '/:directoryId')
263
263
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.2-dev.547",
3
+ "version": "2.1.2-dev.548",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {