datastake-daf 0.6.364 → 0.6.366
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/.env +8 -0
- package/.vscode/settings.json +13 -0
- package/dist/components/index.js +43 -51
- package/dist/hooks/index.js +19 -16
- package/package.json +1 -1
- package/src/@daf/core/components/Charts/ColumnChart/ColumnChart.stories.jsx +0 -28
- package/src/@daf/core/components/Graphs/StakeholderMappings/index.jsx +1 -4
- package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +37 -40
- package/src/@daf/core/components/Graphs/components/Nodes/NameNode.jsx +32 -42
- package/src/@daf/hooks/useFilters.js +319 -277
package/.env
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": ["cukura"],
|
|
3
|
+
"files.autoSave": "afterDelay",
|
|
4
|
+
"editor.wordWrap": "on",
|
|
5
|
+
"editor.autoClosingBrackets": "always",
|
|
6
|
+
"editor.autoClosingComments": "always",
|
|
7
|
+
"editor.autoClosingQuotes": "always",
|
|
8
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
9
|
+
"editor.formatOnPaste": true,
|
|
10
|
+
"editor.formatOnSave": true,
|
|
11
|
+
"notebook.defaultFormatter": "esbenp.prettier-vscode",
|
|
12
|
+
"javascript.format.semicolons": "insert"
|
|
13
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -47000,6 +47000,7 @@ const filterParams = value => {
|
|
|
47000
47000
|
};
|
|
47001
47001
|
};
|
|
47002
47002
|
|
|
47003
|
+
const NEW_PAGINATION_TITLES = ["nashiriki"];
|
|
47003
47004
|
const useFilters = ({
|
|
47004
47005
|
view,
|
|
47005
47006
|
module,
|
|
@@ -47013,6 +47014,8 @@ const useFilters = ({
|
|
|
47013
47014
|
doPagination = true,
|
|
47014
47015
|
getRedirectLink
|
|
47015
47016
|
}) => {
|
|
47017
|
+
const PAGE = NEW_PAGINATION_TITLES.includes(module) ? "skip" : "page";
|
|
47018
|
+
const PAGE_SIZE = NEW_PAGINATION_TITLES.includes(module) ? "take" : "pageSize";
|
|
47016
47019
|
const params = React.useMemo(() => new URLSearchParams(location.search), [location.search]);
|
|
47017
47020
|
const [activeFilters, setActiveFilters] = React.useState(defaultActiveFilters || getDefaultActiveFilters(params, selectFiltersConfig, defaultPageSize, defaultUrlParams, doPagination));
|
|
47018
47021
|
const [pagination, setPagination] = React.useState(defaultActiveFilters ? {
|
|
@@ -47020,8 +47023,8 @@ const useFilters = ({
|
|
|
47020
47023
|
pageSize: defaultActiveFilters.pageSize || defaultPageSize,
|
|
47021
47024
|
showSizeChanger: true
|
|
47022
47025
|
} : {
|
|
47023
|
-
current: !isNaN(Number(params.get(
|
|
47024
|
-
pageSize: !isNaN(Number(params.get(
|
|
47026
|
+
current: !isNaN(Number(params.get(PAGE))) ? Number(params.get(PAGE)) || 1 : 1,
|
|
47027
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE))) ? Number(params.get(PAGE_SIZE)) || defaultPageSize : defaultPageSize,
|
|
47025
47028
|
showSizeChanger: true
|
|
47026
47029
|
});
|
|
47027
47030
|
React.useEffect(() => {
|
|
@@ -47036,32 +47039,32 @@ const useFilters = ({
|
|
|
47036
47039
|
}
|
|
47037
47040
|
setPagination(prev => ({
|
|
47038
47041
|
...prev,
|
|
47039
|
-
current: !isNaN(Number(params.get(
|
|
47040
|
-
pageSize: !isNaN(Number(params.get(
|
|
47042
|
+
current: !isNaN(Number(params.get(PAGE))) ? Number(params.get(PAGE)) || 1 : 1,
|
|
47043
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE))) ? Number(params.get(PAGE_SIZE)) || defaultPageSize : defaultPageSize,
|
|
47041
47044
|
showSizeChanger: true
|
|
47042
47045
|
}));
|
|
47043
47046
|
}, []);
|
|
47044
47047
|
const updateQuery = React.useCallback((filters, page) => {
|
|
47045
47048
|
const qs = Object.keys(filters).filter(key => {
|
|
47046
47049
|
if (!doPagination) {
|
|
47047
|
-
return !!filters[key] && key !==
|
|
47050
|
+
return !!filters[key] && key !== PAGE && key !== PAGE_SIZE;
|
|
47048
47051
|
}
|
|
47049
47052
|
return !!filters[key];
|
|
47050
47053
|
}).map(key => {
|
|
47051
|
-
if (filters[key] && typeof filters[key] ===
|
|
47054
|
+
if (filters[key] && typeof filters[key] === "object") {
|
|
47052
47055
|
return `${key}=${JSON.stringify(filters[key])}`;
|
|
47053
47056
|
}
|
|
47054
47057
|
return `${key}=${filters[key]}`;
|
|
47055
|
-
}).join(
|
|
47058
|
+
}).join("&");
|
|
47056
47059
|
if (view) {
|
|
47057
|
-
if (typeof getRedirectLink ===
|
|
47058
|
-
goTo(getRedirectLink(view ===
|
|
47060
|
+
if (typeof getRedirectLink === "function") {
|
|
47061
|
+
goTo(getRedirectLink(view === "mine-monitoring" ? qs !== "" ? `${location.pathname}?${qs}` : doPagination ? `${location.pathname}?${PAGE}=${page}` : location.pathname : qs !== "" ? `${`/app/${view}`}?${qs}` : doPagination ? `${`/app/${view}`}?${PAGE}=${page}` : `${`/app/${view}`}`));
|
|
47059
47062
|
return;
|
|
47060
47063
|
}
|
|
47061
|
-
if (view ===
|
|
47062
|
-
goTo(qs !==
|
|
47064
|
+
if (view === "mine-monitoring") {
|
|
47065
|
+
goTo(qs !== "" ? `${location.pathname}?${qs}` : doPagination ? `${location.pathname}?${PAGE}=${page}` : location.pathname);
|
|
47063
47066
|
} else {
|
|
47064
|
-
goTo(qs !==
|
|
47067
|
+
goTo(qs !== "" ? `${`/app/${module}/${view}`}?${qs}` : doPagination ? `${`/app/${module}/${view}`}?${PAGE}=${page}` : `${`/app/${module}/${view}`}`);
|
|
47065
47068
|
}
|
|
47066
47069
|
}
|
|
47067
47070
|
}, [module, view, location.pathname]); // Updated dependency array
|
|
@@ -47107,7 +47110,7 @@ const useFilters = ({
|
|
|
47107
47110
|
const {
|
|
47108
47111
|
show
|
|
47109
47112
|
} = conf;
|
|
47110
|
-
if (typeof show ===
|
|
47113
|
+
if (typeof show === "function") {
|
|
47111
47114
|
if (show(filters)) {
|
|
47112
47115
|
return all;
|
|
47113
47116
|
}
|
|
@@ -47125,7 +47128,7 @@ const useFilters = ({
|
|
|
47125
47128
|
...prev
|
|
47126
47129
|
};
|
|
47127
47130
|
Object.keys(o).forEach(k => {
|
|
47128
|
-
if (Object.keys(selectFiltersConfig).includes(k) || k ===
|
|
47131
|
+
if (Object.keys(selectFiltersConfig).includes(k) || k === "authorId") {
|
|
47129
47132
|
delete o[k];
|
|
47130
47133
|
}
|
|
47131
47134
|
});
|
|
@@ -47167,8 +47170,8 @@ const useFilters = ({
|
|
|
47167
47170
|
};
|
|
47168
47171
|
} else if (sortBy || sortDir) {
|
|
47169
47172
|
fs = Object.keys(fs).reduce((all, key) => {
|
|
47170
|
-
if (key !==
|
|
47171
|
-
if (key ===
|
|
47173
|
+
if (key !== "sortDir" && key !== "sortBy") {
|
|
47174
|
+
if (key === PAGE || key === PAGE_SIZE) {
|
|
47172
47175
|
all[key] = fs[key];
|
|
47173
47176
|
} else {
|
|
47174
47177
|
all[key] = activeFilters[key];
|
|
@@ -51378,7 +51381,6 @@ function NameNode({
|
|
|
51378
51381
|
token
|
|
51379
51382
|
} = useToken$7();
|
|
51380
51383
|
const translateFN = typeof data?.t === "function" ? data.t : key => key;
|
|
51381
|
-
const isPdf = data?.isPdf;
|
|
51382
51384
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
51383
51385
|
children: [/*#__PURE__*/jsxRuntime.jsx(react.Handle, {
|
|
51384
51386
|
type: "source",
|
|
@@ -51397,7 +51399,6 @@ function NameNode({
|
|
|
51397
51399
|
opacity: 0
|
|
51398
51400
|
}
|
|
51399
51401
|
}), /*#__PURE__*/jsxRuntime.jsxs(Style$d, {
|
|
51400
|
-
$isPdf: isPdf,
|
|
51401
51402
|
style: {
|
|
51402
51403
|
opacity: data.isEmpty ? 0.5 : 1
|
|
51403
51404
|
},
|
|
@@ -51448,7 +51449,7 @@ function NameNode({
|
|
|
51448
51449
|
}
|
|
51449
51450
|
})
|
|
51450
51451
|
}) : null]
|
|
51451
|
-
}),
|
|
51452
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
51452
51453
|
style: {
|
|
51453
51454
|
marginLeft: "auto"
|
|
51454
51455
|
},
|
|
@@ -51485,32 +51486,27 @@ function NameNode({
|
|
|
51485
51486
|
});
|
|
51486
51487
|
}
|
|
51487
51488
|
const Style$d = dt.div`
|
|
51488
|
-
|
|
51489
|
-
|
|
51490
|
-
|
|
51491
|
-
|
|
51492
|
-
|
|
51493
|
-
|
|
51494
|
-
|
|
51495
|
-
|
|
51496
|
-
box-shadow: 0px 5.64px 17.56px 5.02px #0000000d;
|
|
51497
|
-
/* Ensure borders/colors survive PDF rendering */
|
|
51498
|
-
border: ${props => props.$isPdf ? '1px solid var(--base-gray-30)' : 'none'};
|
|
51499
|
-
-webkit-print-color-adjust: exact;
|
|
51500
|
-
print-color-adjust: exact;
|
|
51489
|
+
width: ${NAME_CARD_WIDTH}px;
|
|
51490
|
+
display: flex;
|
|
51491
|
+
background: white;
|
|
51492
|
+
border-radius: 8px;
|
|
51493
|
+
box-shadow: 0px 3.76px 10.03px 0px #00000014;
|
|
51494
|
+
box-shadow: 0px 1.88px 3.76px -2.51px #0000001f;
|
|
51495
|
+
overflow: hidden;
|
|
51496
|
+
box-shadow: 0px 5.64px 17.56px 5.02px #0000000d;
|
|
51501
51497
|
|
|
51502
|
-
|
|
51503
|
-
|
|
51504
|
-
|
|
51505
|
-
|
|
51506
|
-
|
|
51507
|
-
|
|
51498
|
+
.left {
|
|
51499
|
+
width: 32px;
|
|
51500
|
+
background: red;
|
|
51501
|
+
border-top-left-radius: 12px;
|
|
51502
|
+
border-bottom-left-radius: 12px;
|
|
51503
|
+
}
|
|
51508
51504
|
|
|
51509
|
-
|
|
51510
|
-
|
|
51511
|
-
|
|
51512
|
-
|
|
51513
|
-
|
|
51505
|
+
.right {
|
|
51506
|
+
padding: 16px 12px;
|
|
51507
|
+
width: 100%
|
|
51508
|
+
border-bottom: 1px solid var(--base-gray-30);
|
|
51509
|
+
}
|
|
51514
51510
|
`;
|
|
51515
51511
|
|
|
51516
51512
|
const Style$c = dt.div`
|
|
@@ -52085,7 +52081,6 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
|
|
|
52085
52081
|
t,
|
|
52086
52082
|
withDuration = true,
|
|
52087
52083
|
onFilterChange,
|
|
52088
|
-
isPdf,
|
|
52089
52084
|
...props
|
|
52090
52085
|
}, ref) {
|
|
52091
52086
|
const {
|
|
@@ -52142,7 +52137,7 @@ const BaseGraph = /*#__PURE__*/React.forwardRef(function BaseGraph({
|
|
|
52142
52137
|
duration: withDuration ? 300 : undefined
|
|
52143
52138
|
},
|
|
52144
52139
|
...props,
|
|
52145
|
-
children:
|
|
52140
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(react.Controls, {
|
|
52146
52141
|
position: "bottom-right",
|
|
52147
52142
|
showFitView: false,
|
|
52148
52143
|
showInteractive: false,
|
|
@@ -52659,8 +52654,7 @@ function positionDataNodes(_ref2) {
|
|
|
52659
52654
|
total,
|
|
52660
52655
|
mainNode,
|
|
52661
52656
|
type,
|
|
52662
|
-
hasContent
|
|
52663
|
-
isPdf
|
|
52657
|
+
hasContent
|
|
52664
52658
|
} = _ref2;
|
|
52665
52659
|
const DATA_NODE_WIDTH = DATA_NODE_SIZE[type].width;
|
|
52666
52660
|
const DATA_NODE_HEIGHT = DATA_NODE_SIZE[type].height;
|
|
@@ -52686,7 +52680,7 @@ function positionDataNodes(_ref2) {
|
|
|
52686
52680
|
const startY = iconNodeCenterY - totalHeight / 2;
|
|
52687
52681
|
const END_Y = startY + totalHeight;
|
|
52688
52682
|
const yOffset = index * MIN_SPACE_REQUIRED;
|
|
52689
|
-
let yPosition = startY + yOffset
|
|
52683
|
+
let yPosition = startY + yOffset;
|
|
52690
52684
|
if (isAboveMainNode && END_Y >= mainNode.position.y + DATA_NODE_HEIGHT / 2) {
|
|
52691
52685
|
yPosition = mainNode.position.y + DATA_NODE_HEIGHT / 2 - totalHeight + yOffset;
|
|
52692
52686
|
} else if (!isAboveMainNode && startY < mainNode.position.y + DATA_NODE_HEIGHT / 2) {
|
|
@@ -52877,7 +52871,6 @@ function StakeholderMappings(_ref3) {
|
|
|
52877
52871
|
isLeftSide: node.data.order % 2 !== 0,
|
|
52878
52872
|
isAboveMainNode: node.data.order <= 2,
|
|
52879
52873
|
iconNode: node,
|
|
52880
|
-
isPdf: true,
|
|
52881
52874
|
index: 0,
|
|
52882
52875
|
total: 1,
|
|
52883
52876
|
mainNode,
|
|
@@ -52976,8 +52969,7 @@ function StakeholderMappings(_ref3) {
|
|
|
52976
52969
|
duration: 300
|
|
52977
52970
|
});
|
|
52978
52971
|
},
|
|
52979
|
-
ref: reactFlowWrapper
|
|
52980
|
-
isPdf: isPdf
|
|
52972
|
+
ref: reactFlowWrapper
|
|
52981
52973
|
});
|
|
52982
52974
|
}
|
|
52983
52975
|
var index$1 = withProvider(StakeholderMappings);
|
package/dist/hooks/index.js
CHANGED
|
@@ -200,6 +200,7 @@ class StorageManager {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
const NEW_PAGINATION_TITLES = ["nashiriki"];
|
|
203
204
|
const useFilters = ({
|
|
204
205
|
view,
|
|
205
206
|
module,
|
|
@@ -213,6 +214,8 @@ const useFilters = ({
|
|
|
213
214
|
doPagination = true,
|
|
214
215
|
getRedirectLink
|
|
215
216
|
}) => {
|
|
217
|
+
const PAGE = NEW_PAGINATION_TITLES.includes(module) ? "skip" : "page";
|
|
218
|
+
const PAGE_SIZE = NEW_PAGINATION_TITLES.includes(module) ? "take" : "pageSize";
|
|
216
219
|
const params = React.useMemo(() => new URLSearchParams(location.search), [location.search]);
|
|
217
220
|
const [activeFilters, setActiveFilters] = React.useState(defaultActiveFilters || getDefaultActiveFilters(params, selectFiltersConfig, defaultPageSize, defaultUrlParams, doPagination));
|
|
218
221
|
const [pagination, setPagination] = React.useState(defaultActiveFilters ? {
|
|
@@ -220,8 +223,8 @@ const useFilters = ({
|
|
|
220
223
|
pageSize: defaultActiveFilters.pageSize || defaultPageSize,
|
|
221
224
|
showSizeChanger: true
|
|
222
225
|
} : {
|
|
223
|
-
current: !isNaN(Number(params.get(
|
|
224
|
-
pageSize: !isNaN(Number(params.get(
|
|
226
|
+
current: !isNaN(Number(params.get(PAGE))) ? Number(params.get(PAGE)) || 1 : 1,
|
|
227
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE))) ? Number(params.get(PAGE_SIZE)) || defaultPageSize : defaultPageSize,
|
|
225
228
|
showSizeChanger: true
|
|
226
229
|
});
|
|
227
230
|
React.useEffect(() => {
|
|
@@ -236,32 +239,32 @@ const useFilters = ({
|
|
|
236
239
|
}
|
|
237
240
|
setPagination(prev => ({
|
|
238
241
|
...prev,
|
|
239
|
-
current: !isNaN(Number(params.get(
|
|
240
|
-
pageSize: !isNaN(Number(params.get(
|
|
242
|
+
current: !isNaN(Number(params.get(PAGE))) ? Number(params.get(PAGE)) || 1 : 1,
|
|
243
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE))) ? Number(params.get(PAGE_SIZE)) || defaultPageSize : defaultPageSize,
|
|
241
244
|
showSizeChanger: true
|
|
242
245
|
}));
|
|
243
246
|
}, []);
|
|
244
247
|
const updateQuery = React.useCallback((filters, page) => {
|
|
245
248
|
const qs = Object.keys(filters).filter(key => {
|
|
246
249
|
if (!doPagination) {
|
|
247
|
-
return !!filters[key] && key !==
|
|
250
|
+
return !!filters[key] && key !== PAGE && key !== PAGE_SIZE;
|
|
248
251
|
}
|
|
249
252
|
return !!filters[key];
|
|
250
253
|
}).map(key => {
|
|
251
|
-
if (filters[key] && typeof filters[key] ===
|
|
254
|
+
if (filters[key] && typeof filters[key] === "object") {
|
|
252
255
|
return `${key}=${JSON.stringify(filters[key])}`;
|
|
253
256
|
}
|
|
254
257
|
return `${key}=${filters[key]}`;
|
|
255
|
-
}).join(
|
|
258
|
+
}).join("&");
|
|
256
259
|
if (view) {
|
|
257
|
-
if (typeof getRedirectLink ===
|
|
258
|
-
goTo(getRedirectLink(view ===
|
|
260
|
+
if (typeof getRedirectLink === "function") {
|
|
261
|
+
goTo(getRedirectLink(view === "mine-monitoring" ? qs !== "" ? `${location.pathname}?${qs}` : doPagination ? `${location.pathname}?${PAGE}=${page}` : location.pathname : qs !== "" ? `${`/app/${view}`}?${qs}` : doPagination ? `${`/app/${view}`}?${PAGE}=${page}` : `${`/app/${view}`}`));
|
|
259
262
|
return;
|
|
260
263
|
}
|
|
261
|
-
if (view ===
|
|
262
|
-
goTo(qs !==
|
|
264
|
+
if (view === "mine-monitoring") {
|
|
265
|
+
goTo(qs !== "" ? `${location.pathname}?${qs}` : doPagination ? `${location.pathname}?${PAGE}=${page}` : location.pathname);
|
|
263
266
|
} else {
|
|
264
|
-
goTo(qs !==
|
|
267
|
+
goTo(qs !== "" ? `${`/app/${module}/${view}`}?${qs}` : doPagination ? `${`/app/${module}/${view}`}?${PAGE}=${page}` : `${`/app/${module}/${view}`}`);
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
270
|
}, [module, view, location.pathname]); // Updated dependency array
|
|
@@ -307,7 +310,7 @@ const useFilters = ({
|
|
|
307
310
|
const {
|
|
308
311
|
show
|
|
309
312
|
} = conf;
|
|
310
|
-
if (typeof show ===
|
|
313
|
+
if (typeof show === "function") {
|
|
311
314
|
if (show(filters)) {
|
|
312
315
|
return all;
|
|
313
316
|
}
|
|
@@ -325,7 +328,7 @@ const useFilters = ({
|
|
|
325
328
|
...prev
|
|
326
329
|
};
|
|
327
330
|
Object.keys(o).forEach(k => {
|
|
328
|
-
if (Object.keys(selectFiltersConfig).includes(k) || k ===
|
|
331
|
+
if (Object.keys(selectFiltersConfig).includes(k) || k === "authorId") {
|
|
329
332
|
delete o[k];
|
|
330
333
|
}
|
|
331
334
|
});
|
|
@@ -367,8 +370,8 @@ const useFilters = ({
|
|
|
367
370
|
};
|
|
368
371
|
} else if (sortBy || sortDir) {
|
|
369
372
|
fs = Object.keys(fs).reduce((all, key) => {
|
|
370
|
-
if (key !==
|
|
371
|
-
if (key ===
|
|
373
|
+
if (key !== "sortDir" && key !== "sortBy") {
|
|
374
|
+
if (key === PAGE || key === PAGE_SIZE) {
|
|
372
375
|
all[key] = fs[key];
|
|
373
376
|
} else {
|
|
374
377
|
all[key] = activeFilters[key];
|
package/package.json
CHANGED
|
@@ -457,34 +457,6 @@ export const Pdf = {
|
|
|
457
457
|
showBackground: true,
|
|
458
458
|
isPercentage: true,
|
|
459
459
|
shouldSeperateLegendName: true,
|
|
460
|
-
formattedXAxis: (s) => {
|
|
461
|
-
if (!s) return "";
|
|
462
|
-
|
|
463
|
-
const limit = 20;
|
|
464
|
-
let result = "";
|
|
465
|
-
let line = "";
|
|
466
|
-
|
|
467
|
-
for (let word of s.split(" ")) {
|
|
468
|
-
if ((line + word).length <= limit) {
|
|
469
|
-
line += (line ? " " : "") + word;
|
|
470
|
-
} else if (word.length > limit) {
|
|
471
|
-
// break long word with hyphen
|
|
472
|
-
while (word.length > limit) {
|
|
473
|
-
result += word.slice(0, limit - 1) + "-\n";
|
|
474
|
-
word = word.slice(limit - 1);
|
|
475
|
-
}
|
|
476
|
-
line = word;
|
|
477
|
-
} else {
|
|
478
|
-
// move current line into result
|
|
479
|
-
if (line) result += line + "\n";
|
|
480
|
-
line = word;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
if (line) result += line;
|
|
485
|
-
|
|
486
|
-
return result;
|
|
487
|
-
},
|
|
488
460
|
},
|
|
489
461
|
render: (args) => {
|
|
490
462
|
return <Widget title="Pdf Column Chart" className={"with-border-header"}>
|
|
@@ -72,7 +72,6 @@ function positionDataNodes({
|
|
|
72
72
|
mainNode,
|
|
73
73
|
type,
|
|
74
74
|
hasContent,
|
|
75
|
-
isPdf,
|
|
76
75
|
}) {
|
|
77
76
|
const DATA_NODE_WIDTH = DATA_NODE_SIZE[type].width;
|
|
78
77
|
const DATA_NODE_HEIGHT = DATA_NODE_SIZE[type].height;
|
|
@@ -105,7 +104,7 @@ function positionDataNodes({
|
|
|
105
104
|
|
|
106
105
|
const yOffset = index * MIN_SPACE_REQUIRED;
|
|
107
106
|
|
|
108
|
-
let yPosition = startY + yOffset
|
|
107
|
+
let yPosition = startY + yOffset;
|
|
109
108
|
|
|
110
109
|
if (isAboveMainNode && END_Y >= mainNode.position.y + DATA_NODE_HEIGHT / 2) {
|
|
111
110
|
yPosition = mainNode.position.y + DATA_NODE_HEIGHT / 2 - totalHeight + yOffset;
|
|
@@ -326,7 +325,6 @@ function StakeholderMappings({
|
|
|
326
325
|
isLeftSide: node.data.order % 2 !== 0,
|
|
327
326
|
isAboveMainNode: node.data.order <= 2,
|
|
328
327
|
iconNode: node,
|
|
329
|
-
isPdf: true,
|
|
330
328
|
index: 0,
|
|
331
329
|
total: 1,
|
|
332
330
|
mainNode,
|
|
@@ -446,7 +444,6 @@ function StakeholderMappings({
|
|
|
446
444
|
});
|
|
447
445
|
}}
|
|
448
446
|
ref={reactFlowWrapper}
|
|
449
|
-
isPdf={isPdf}
|
|
450
447
|
/>
|
|
451
448
|
);
|
|
452
449
|
}
|
|
@@ -32,7 +32,6 @@ const BaseGraph = forwardRef(function BaseGraph(
|
|
|
32
32
|
t,
|
|
33
33
|
withDuration = true,
|
|
34
34
|
onFilterChange,
|
|
35
|
-
isPdf,
|
|
36
35
|
...props
|
|
37
36
|
},
|
|
38
37
|
ref,
|
|
@@ -88,45 +87,43 @@ const BaseGraph = forwardRef(function BaseGraph(
|
|
|
88
87
|
}}
|
|
89
88
|
{...props}
|
|
90
89
|
>
|
|
91
|
-
{
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
</Controls>
|
|
129
|
-
)}
|
|
90
|
+
<Controls position="bottom-right" showFitView={false} showInteractive={false}>
|
|
91
|
+
<ControlButton
|
|
92
|
+
onClick={() => {
|
|
93
|
+
fitView({
|
|
94
|
+
padding: 0.1,
|
|
95
|
+
nodes: [...nodesToFit],
|
|
96
|
+
duration: withDuration ? 300 : undefined,
|
|
97
|
+
});
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<AimOutlined height={20} width={20} />
|
|
101
|
+
</ControlButton>
|
|
102
|
+
<ControlButton
|
|
103
|
+
onClick={() => {
|
|
104
|
+
const viewport = getViewport();
|
|
105
|
+
setViewport({
|
|
106
|
+
x: viewport.x,
|
|
107
|
+
y: viewport.y + 20,
|
|
108
|
+
zoom: viewport.zoom,
|
|
109
|
+
});
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<UpOutlined height={20} width={20}></UpOutlined>
|
|
113
|
+
</ControlButton>
|
|
114
|
+
<ControlButton
|
|
115
|
+
onClick={() => {
|
|
116
|
+
const viewport = getViewport();
|
|
117
|
+
setViewport({
|
|
118
|
+
x: viewport.x,
|
|
119
|
+
y: viewport.y - 20,
|
|
120
|
+
zoom: viewport.zoom,
|
|
121
|
+
});
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<DownOutlined height={20} width={20}></DownOutlined>
|
|
125
|
+
</ControlButton>
|
|
126
|
+
</Controls>
|
|
130
127
|
</ReactFlow>
|
|
131
128
|
</div>
|
|
132
129
|
</ComponentWithFocus>
|
|
@@ -13,8 +13,6 @@ const { useToken } = theme;
|
|
|
13
13
|
export default function NameNode({ data }) {
|
|
14
14
|
const { token } = useToken();
|
|
15
15
|
const translateFN = typeof data?.t === "function" ? data.t : (key) => key;
|
|
16
|
-
const isPdf = data?.isPdf;
|
|
17
|
-
|
|
18
16
|
return (
|
|
19
17
|
<>
|
|
20
18
|
<Handle
|
|
@@ -36,7 +34,6 @@ export default function NameNode({ data }) {
|
|
|
36
34
|
}}
|
|
37
35
|
/>
|
|
38
36
|
<Style
|
|
39
|
-
$isPdf={isPdf}
|
|
40
37
|
style={{
|
|
41
38
|
opacity: data.isEmpty ? 0.5 : 1,
|
|
42
39
|
}}
|
|
@@ -98,21 +95,19 @@ export default function NameNode({ data }) {
|
|
|
98
95
|
) : null}
|
|
99
96
|
</div>
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
</div>
|
|
115
|
-
)}
|
|
98
|
+
<div
|
|
99
|
+
style={{
|
|
100
|
+
marginLeft: "auto",
|
|
101
|
+
}}
|
|
102
|
+
className="go-to"
|
|
103
|
+
onClick={() => {
|
|
104
|
+
if (typeof data.onClick === "function") {
|
|
105
|
+
data.onClick();
|
|
106
|
+
}
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<CustomIcon height={14} width={14} name="LinkNewTab" />
|
|
110
|
+
</div>
|
|
116
111
|
</div>
|
|
117
112
|
</Style>
|
|
118
113
|
<Handle
|
|
@@ -134,30 +129,25 @@ export default function NameNode({ data }) {
|
|
|
134
129
|
}
|
|
135
130
|
|
|
136
131
|
const Style = styled.div`
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
box-shadow: 0px 5.64px 17.56px 5.02px #0000000d;
|
|
146
|
-
/* Ensure borders/colors survive PDF rendering */
|
|
147
|
-
border: ${(props) => (props.$isPdf ? '1px solid var(--base-gray-30)' : 'none')};
|
|
148
|
-
-webkit-print-color-adjust: exact;
|
|
149
|
-
print-color-adjust: exact;
|
|
132
|
+
width: ${NAME_CARD_WIDTH}px;
|
|
133
|
+
display: flex;
|
|
134
|
+
background: white;
|
|
135
|
+
border-radius: 8px;
|
|
136
|
+
box-shadow: 0px 3.76px 10.03px 0px #00000014;
|
|
137
|
+
box-shadow: 0px 1.88px 3.76px -2.51px #0000001f;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
box-shadow: 0px 5.64px 17.56px 5.02px #0000000d;
|
|
150
140
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
.left {
|
|
142
|
+
width: 32px;
|
|
143
|
+
background: red;
|
|
144
|
+
border-top-left-radius: 12px;
|
|
145
|
+
border-bottom-left-radius: 12px;
|
|
146
|
+
}
|
|
157
147
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
148
|
+
.right {
|
|
149
|
+
padding: 16px 12px;
|
|
150
|
+
width: 100%
|
|
151
|
+
border-bottom: 1px solid var(--base-gray-30);
|
|
152
|
+
}
|
|
163
153
|
`;
|
|
@@ -1,281 +1,323 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from
|
|
2
|
-
import { getDefaultActiveFilters } from
|
|
3
|
-
import { StorageManager } from
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { getDefaultActiveFilters } from "../utils/filters";
|
|
3
|
+
import { StorageManager } from "../../helpers/StorageManager";
|
|
4
|
+
|
|
5
|
+
const NEW_PAGINATION_TITLES = ["nashiriki"];
|
|
4
6
|
|
|
5
7
|
export const useFilters = ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
view,
|
|
9
|
+
module,
|
|
10
|
+
filtersConfig,
|
|
11
|
+
goTo,
|
|
12
|
+
location,
|
|
13
|
+
selectFiltersConfig,
|
|
14
|
+
defaultPageSize = 20,
|
|
15
|
+
defaultActiveFilters,
|
|
16
|
+
defaultUrlParams = {},
|
|
17
|
+
doPagination = true,
|
|
18
|
+
getRedirectLink,
|
|
17
19
|
}) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
20
|
+
const PAGE = NEW_PAGINATION_TITLES.includes(module) ? "skip" : "page";
|
|
21
|
+
const PAGE_SIZE = NEW_PAGINATION_TITLES.includes(module) ? "take" : "pageSize";
|
|
22
|
+
|
|
23
|
+
const params = useMemo(() => new URLSearchParams(location.search), [location.search]);
|
|
24
|
+
const [activeFilters, setActiveFilters] = useState(
|
|
25
|
+
defaultActiveFilters ||
|
|
26
|
+
getDefaultActiveFilters(
|
|
27
|
+
params,
|
|
28
|
+
selectFiltersConfig,
|
|
29
|
+
defaultPageSize,
|
|
30
|
+
defaultUrlParams,
|
|
31
|
+
doPagination,
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
const [pagination, setPagination] = useState(
|
|
35
|
+
defaultActiveFilters
|
|
36
|
+
? {
|
|
37
|
+
current: defaultActiveFilters.page || 1,
|
|
38
|
+
pageSize: defaultActiveFilters.pageSize || defaultPageSize,
|
|
39
|
+
showSizeChanger: true,
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
current: !isNaN(Number(params.get(PAGE)))
|
|
43
|
+
? Number(params.get(PAGE)) || 1
|
|
44
|
+
: 1,
|
|
45
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE)))
|
|
46
|
+
? Number(params.get(PAGE_SIZE)) || defaultPageSize
|
|
47
|
+
: defaultPageSize,
|
|
48
|
+
showSizeChanger: true,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (defaultActiveFilters) {
|
|
54
|
+
setPagination((prev) => ({
|
|
55
|
+
...prev,
|
|
56
|
+
current: defaultActiveFilters.page || 1,
|
|
57
|
+
pageSize: defaultActiveFilters.pageSize || defaultPageSize,
|
|
58
|
+
showSizeChanger: true,
|
|
59
|
+
}));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
setPagination((prev) => ({
|
|
63
|
+
...prev,
|
|
64
|
+
current: !isNaN(Number(params.get(PAGE))) ? Number(params.get(PAGE)) || 1 : 1,
|
|
65
|
+
pageSize: !isNaN(Number(params.get(PAGE_SIZE)))
|
|
66
|
+
? Number(params.get(PAGE_SIZE)) || defaultPageSize
|
|
67
|
+
: defaultPageSize,
|
|
68
|
+
showSizeChanger: true,
|
|
69
|
+
}));
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
const updateQuery = useCallback(
|
|
73
|
+
(filters, page) => {
|
|
74
|
+
const qs = Object.keys(filters)
|
|
75
|
+
.filter((key) => {
|
|
76
|
+
if (!doPagination) {
|
|
77
|
+
return !!filters[key] && key !== PAGE && key !== PAGE_SIZE;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return !!filters[key];
|
|
81
|
+
})
|
|
82
|
+
.map((key) => {
|
|
83
|
+
if (filters[key] && typeof filters[key] === "object") {
|
|
84
|
+
return `${key}=${JSON.stringify(filters[key])}`;
|
|
85
|
+
}
|
|
86
|
+
return `${key}=${filters[key]}`;
|
|
87
|
+
})
|
|
88
|
+
.join("&");
|
|
89
|
+
|
|
90
|
+
if (view) {
|
|
91
|
+
if (typeof getRedirectLink === "function") {
|
|
92
|
+
goTo(
|
|
93
|
+
getRedirectLink(
|
|
94
|
+
view === "mine-monitoring"
|
|
95
|
+
? qs !== ""
|
|
96
|
+
? `${location.pathname}?${qs}`
|
|
97
|
+
: doPagination
|
|
98
|
+
? `${location.pathname}?${PAGE}=${page}`
|
|
99
|
+
: location.pathname
|
|
100
|
+
: qs !== ""
|
|
101
|
+
? `${`/app/${view}`}?${qs}`
|
|
102
|
+
: doPagination
|
|
103
|
+
? `${`/app/${view}`}?${PAGE}=${page}`
|
|
104
|
+
: `${`/app/${view}`}`,
|
|
105
|
+
),
|
|
106
|
+
);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (view === "mine-monitoring") {
|
|
111
|
+
goTo(
|
|
112
|
+
qs !== ""
|
|
113
|
+
? `${location.pathname}?${qs}`
|
|
114
|
+
: doPagination
|
|
115
|
+
? `${location.pathname}?${PAGE}=${page}`
|
|
116
|
+
: location.pathname,
|
|
117
|
+
);
|
|
118
|
+
} else {
|
|
119
|
+
goTo(
|
|
120
|
+
qs !== ""
|
|
121
|
+
? `${`/app/${module}/${view}`}?${qs}`
|
|
122
|
+
: doPagination
|
|
123
|
+
? `${`/app/${module}/${view}`}?${PAGE}=${page}`
|
|
124
|
+
: `${`/app/${module}/${view}`}`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[module, view, location.pathname],
|
|
130
|
+
); // Updated dependency array
|
|
131
|
+
|
|
132
|
+
const defaultFilters = useMemo(() => {
|
|
133
|
+
const def = {};
|
|
134
|
+
Object.keys(selectFiltersConfig).forEach((key) => {
|
|
135
|
+
if (activeFilters[key]) {
|
|
136
|
+
def[key] = activeFilters[key];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return def;
|
|
140
|
+
}, [activeFilters, selectFiltersConfig]);
|
|
141
|
+
|
|
142
|
+
const newFiltersConfig = useMemo(() => {
|
|
143
|
+
const o = filtersConfig;
|
|
144
|
+
Object.keys(filtersConfig).forEach((key) => {
|
|
145
|
+
if (params.has(key)) {
|
|
146
|
+
o[key] = params.get(key);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return o;
|
|
150
|
+
}, [params, filtersConfig]);
|
|
151
|
+
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
const filteredFilters = Object.keys(activeFilters).reduce((all, key) => {
|
|
154
|
+
if (activeFilters[key]) {
|
|
155
|
+
all[key] = activeFilters[key];
|
|
156
|
+
}
|
|
157
|
+
return all;
|
|
158
|
+
}, {});
|
|
159
|
+
|
|
160
|
+
const filters = StorageManager.saveFilters(module, view, { ...filteredFilters });
|
|
161
|
+
|
|
162
|
+
if (!filters.pageSize) {
|
|
163
|
+
filters.page = 1;
|
|
164
|
+
filters.pageSize = pagination.pageSize;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
updateQuery(filters, 1);
|
|
168
|
+
}, [activeFilters]);
|
|
169
|
+
|
|
170
|
+
const onFiltersChange = useCallback(
|
|
171
|
+
(filters) => {
|
|
172
|
+
const filteredFilters = Object.keys(filters).reduce((all, key) => {
|
|
173
|
+
const conf = selectFiltersConfig[key];
|
|
174
|
+
if (conf) {
|
|
175
|
+
const { show } = conf;
|
|
176
|
+
if (typeof show === "function") {
|
|
177
|
+
if (show(filters)) {
|
|
178
|
+
return all;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (Array.isArray(filters[key]) && !filters[key].length) {
|
|
184
|
+
all[key] = undefined;
|
|
185
|
+
return all;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
all[key] = filters[key];
|
|
189
|
+
return all;
|
|
190
|
+
}, {});
|
|
191
|
+
|
|
192
|
+
setActiveFilters((prev) => {
|
|
193
|
+
const o = { ...prev };
|
|
194
|
+
Object.keys(o).forEach((k) => {
|
|
195
|
+
if (Object.keys(selectFiltersConfig).includes(k) || k === "authorId") {
|
|
196
|
+
delete o[k];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.entries(filteredFilters).forEach(([k, v]) => {
|
|
200
|
+
o[k] = v;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (doPagination) {
|
|
204
|
+
o.page = 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return o;
|
|
208
|
+
});
|
|
209
|
+
setPagination((prev) => ({ ...prev, current: 1 }));
|
|
210
|
+
},
|
|
211
|
+
[selectFiltersConfig],
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
const onTableChange = (page, f, sorter) => {
|
|
215
|
+
const { sortBy, sortDir } = activeFilters;
|
|
216
|
+
const { columnKey, order } = sorter || {};
|
|
217
|
+
|
|
218
|
+
let fs = {
|
|
219
|
+
...activeFilters,
|
|
220
|
+
page: page.pageSize !== activeFilters.pageSize ? 1 : page.current,
|
|
221
|
+
pageSize: page.pageSize || defaultPageSize,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
if (sorter && (columnKey !== sortBy || order !== sortDir)) {
|
|
225
|
+
fs.page = 1;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (order) {
|
|
229
|
+
fs = { ...fs, sortDir: order, sortBy: columnKey };
|
|
230
|
+
} else if (sortBy || sortDir) {
|
|
231
|
+
fs = Object.keys(fs).reduce((all, key) => {
|
|
232
|
+
if (key !== "sortDir" && key !== "sortBy") {
|
|
233
|
+
if (key === PAGE || key === PAGE_SIZE) {
|
|
234
|
+
all[key] = fs[key];
|
|
235
|
+
} else {
|
|
236
|
+
all[key] = activeFilters[key];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return all;
|
|
240
|
+
}, {});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
setActiveFilters(fs);
|
|
244
|
+
|
|
245
|
+
if (isNaN(page.current)) {
|
|
246
|
+
page.current = 1;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const filters = StorageManager.saveFilters(module, view, { page: page.current }, true);
|
|
250
|
+
|
|
251
|
+
updateQuery(filters, page.current);
|
|
252
|
+
setPagination((prev) => ({
|
|
253
|
+
...prev,
|
|
254
|
+
current: fs.page,
|
|
255
|
+
pageSize: fs.pageSize || defaultPageSize,
|
|
256
|
+
}));
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const onSearch = useCallback((activeFilter, value) => {
|
|
260
|
+
setActiveFilters((prev) => ({
|
|
261
|
+
...prev,
|
|
262
|
+
page: 1,
|
|
263
|
+
searchParams: activeFilter,
|
|
264
|
+
search: value,
|
|
265
|
+
}));
|
|
266
|
+
setPagination((prev) => ({ ...prev, current: 1 }));
|
|
267
|
+
}, []);
|
|
268
|
+
|
|
269
|
+
const totalPages = useMemo(() => {
|
|
270
|
+
return Math.ceil(pagination.total / pagination.pageSize);
|
|
271
|
+
}, [pagination]);
|
|
272
|
+
|
|
273
|
+
const canGoPrev = useMemo(() => pagination.current !== 1, [pagination]);
|
|
274
|
+
const canGoNext = useMemo(
|
|
275
|
+
() => pagination.current !== totalPages && totalPages,
|
|
276
|
+
[pagination, totalPages],
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const goPrev = () => {
|
|
280
|
+
if (!canGoPrev) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const { sortDir, sortBy } = activeFilters;
|
|
285
|
+
|
|
286
|
+
onTableChange(
|
|
287
|
+
{ ...pagination, current: pagination.current - 1 },
|
|
288
|
+
undefined,
|
|
289
|
+
sortBy && sortDir ? { sortBy, sortDir } : undefined,
|
|
290
|
+
);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const goNext = () => {
|
|
294
|
+
if (!canGoNext) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const { sortDir, sortBy } = activeFilters;
|
|
299
|
+
|
|
300
|
+
onTableChange(
|
|
301
|
+
{ ...pagination, current: pagination.current + 1 },
|
|
302
|
+
undefined,
|
|
303
|
+
sortBy && sortDir ? { columnKey: sortBy, order: sortDir } : undefined,
|
|
304
|
+
);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
newFiltersConfig,
|
|
309
|
+
totalPages,
|
|
310
|
+
canGoNext,
|
|
311
|
+
canGoPrev,
|
|
312
|
+
goPrev,
|
|
313
|
+
goNext,
|
|
314
|
+
pagination,
|
|
315
|
+
activeFilters,
|
|
316
|
+
onSearch,
|
|
317
|
+
defaultFilters,
|
|
318
|
+
onTableChange,
|
|
319
|
+
setPagination,
|
|
320
|
+
onFiltersChange,
|
|
321
|
+
setActiveFilters,
|
|
322
|
+
};
|
|
281
323
|
};
|