@fctc/widget-logic 5.3.7-beta.15 → 5.3.7-beta.17
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/dist/hooks.js +3 -299
- package/dist/hooks.mjs +3 -292
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -370
- package/dist/index.mjs +91 -366
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.mts +1 -3
- package/dist/utils.d.ts +1 -3
- package/dist/utils.js +1 -297
- package/dist/utils.mjs +1 -286
- package/dist/widget.d.mts +26 -22
- package/dist/widget.d.ts +26 -22
- package/dist/widget.js +170 -446
- package/dist/widget.mjs +160 -428
- package/package.json +1 -1
package/dist/widget.mjs
CHANGED
|
@@ -17,61 +17,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
18
|
|
|
19
19
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
20
|
-
import { useEffect, useRef, useState } from "react";
|
|
21
|
-
import { getEnv } from "@fctc/interface-logic/environment";
|
|
22
|
-
import { useSave } from "@fctc/interface-logic/hooks";
|
|
23
|
-
var statusDropdownController = (props) => {
|
|
24
|
-
const { selection, isForm, id, model, name, state, onRefetch } = props;
|
|
25
|
-
const env = getEnv();
|
|
26
|
-
const colors = {
|
|
27
|
-
normal: "bg-[#e9ecef]",
|
|
28
|
-
done: "bg-primary",
|
|
29
|
-
blocked: "bg-red-500"
|
|
30
|
-
};
|
|
31
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
32
|
-
const buttonRef = useRef(null);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const handleClickOutside = (event) => {
|
|
35
|
-
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
36
|
-
setIsOpen(false);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
40
|
-
return () => {
|
|
41
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
42
|
-
};
|
|
43
|
-
}, []);
|
|
44
|
-
const { mutate: onSave } = useSave();
|
|
45
|
-
const handleClick = async (status) => {
|
|
46
|
-
setIsOpen(!isOpen);
|
|
47
|
-
onSave(
|
|
48
|
-
{
|
|
49
|
-
ids: id ? [id] : [],
|
|
50
|
-
model: model ?? "",
|
|
51
|
-
data: { [name ?? ""]: status },
|
|
52
|
-
context: env.context
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
onSuccess: () => {
|
|
56
|
-
onRefetch && onRefetch();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
return {
|
|
62
|
-
handleClick,
|
|
63
|
-
buttonRef,
|
|
64
|
-
isForm,
|
|
65
|
-
setIsOpen,
|
|
66
|
-
isOpen,
|
|
67
|
-
selection,
|
|
68
|
-
state,
|
|
69
|
-
colors
|
|
70
|
-
};
|
|
71
|
-
};
|
|
20
|
+
import { useEffect as useEffect8, useRef as useRef2, useState as useState6 } from "react";
|
|
72
21
|
|
|
73
|
-
// src/
|
|
74
|
-
|
|
22
|
+
// src/environment.ts
|
|
23
|
+
var environment_exports = {};
|
|
24
|
+
__reExport(environment_exports, environment_star);
|
|
25
|
+
import * as environment_star from "@fctc/interface-logic/environment";
|
|
75
26
|
|
|
76
27
|
// src/hooks.ts
|
|
77
28
|
import {
|
|
@@ -130,7 +81,7 @@ import {
|
|
|
130
81
|
useResetPassword,
|
|
131
82
|
useResetPasswordSSO,
|
|
132
83
|
useRunAction,
|
|
133
|
-
useSave
|
|
84
|
+
useSave,
|
|
134
85
|
useSendComment,
|
|
135
86
|
useSettingsWebRead2fa,
|
|
136
87
|
useSignInSSO,
|
|
@@ -164,10 +115,10 @@ import {
|
|
|
164
115
|
import { createContext, useContext, useMemo as useMemo4 } from "react";
|
|
165
116
|
|
|
166
117
|
// src/hooks/core/use-menu.ts
|
|
167
|
-
import { useState as
|
|
118
|
+
import { useState as useState2 } from "react";
|
|
168
119
|
|
|
169
120
|
// src/hooks/core/use-call-action.ts
|
|
170
|
-
import { useCallback, useState
|
|
121
|
+
import { useCallback, useState } from "react";
|
|
171
122
|
|
|
172
123
|
// src/provider.ts
|
|
173
124
|
var provider_exports = {};
|
|
@@ -184,8 +135,7 @@ __export(utils_exports, {
|
|
|
184
135
|
languages: () => languages,
|
|
185
136
|
mergeButtons: () => mergeButtons,
|
|
186
137
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
187
|
-
useStorageState: () => useStorageState
|
|
188
|
-
validateAndParseDate: () => validateAndParseDate
|
|
138
|
+
useStorageState: () => useStorageState
|
|
189
139
|
});
|
|
190
140
|
|
|
191
141
|
// src/utils/constants.ts
|
|
@@ -196,7 +146,7 @@ var languages = [
|
|
|
196
146
|
var isBlobUrl = (url) => url.startsWith("blob:");
|
|
197
147
|
|
|
198
148
|
// src/utils/function.ts
|
|
199
|
-
import { useCallback as useCallback2, useEffect
|
|
149
|
+
import { useCallback as useCallback2, useEffect, useReducer } from "react";
|
|
200
150
|
var countSum = (data, field) => {
|
|
201
151
|
if (!data || !field) return 0;
|
|
202
152
|
return data.reduce(
|
|
@@ -241,7 +191,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
241
191
|
}
|
|
242
192
|
function useStorageState(key) {
|
|
243
193
|
const [state, setState] = useAsyncState();
|
|
244
|
-
|
|
194
|
+
useEffect(() => {
|
|
245
195
|
try {
|
|
246
196
|
const storedValue = localStorage.getItem(key);
|
|
247
197
|
setState(storedValue);
|
|
@@ -281,308 +231,24 @@ var guessTypeFromUrl = (url) => {
|
|
|
281
231
|
return map[ext] || null;
|
|
282
232
|
};
|
|
283
233
|
|
|
284
|
-
// src/utils/format-date.ts
|
|
285
|
-
import moment from "moment";
|
|
286
|
-
var validateAndParseDate = (input, isDateTime = false) => {
|
|
287
|
-
if (!input || typeof input !== "string") return null;
|
|
288
|
-
const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
|
|
289
|
-
const dateFormat = "YYYY-MM-DD";
|
|
290
|
-
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
291
|
-
const currentDay = moment().format("DD");
|
|
292
|
-
const currentMonth = moment().format("MM");
|
|
293
|
-
const currentYear = moment().format("YYYY");
|
|
294
|
-
const defaultTime = "00:00:00";
|
|
295
|
-
const maxYear = parseInt(currentYear) + 10;
|
|
296
|
-
const isValidDate = (day, month, year) => {
|
|
297
|
-
const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
|
|
298
|
-
return date.isValid();
|
|
299
|
-
};
|
|
300
|
-
const isValidTime = (hour, minute = "00", second = "00") => {
|
|
301
|
-
const h = parseInt(hour, 10);
|
|
302
|
-
const m = parseInt(minute, 10);
|
|
303
|
-
const s = parseInt(second, 10);
|
|
304
|
-
return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
|
|
305
|
-
};
|
|
306
|
-
const formatOutput = (day, month, year, time = defaultTime) => {
|
|
307
|
-
let result = moment(
|
|
308
|
-
`${day}-${month}-${year} ${time}`,
|
|
309
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
310
|
-
);
|
|
311
|
-
if (!result.isValid()) return null;
|
|
312
|
-
if (isDateTime) {
|
|
313
|
-
result = result.subtract(7, "hours");
|
|
314
|
-
return result.format(dateTimeFormat);
|
|
315
|
-
}
|
|
316
|
-
return result.format(dateFormat);
|
|
317
|
-
};
|
|
318
|
-
if (isDateTime && input.match(
|
|
319
|
-
/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
|
|
320
|
-
)) {
|
|
321
|
-
const [datePart, timePart] = input.split(/\s+/);
|
|
322
|
-
const dateParts = datePart.split(/[\/-]/);
|
|
323
|
-
const timeParts = timePart.split(":");
|
|
324
|
-
const day = dateParts[0].padStart(2, "0");
|
|
325
|
-
const month = dateParts[1].padStart(2, "0");
|
|
326
|
-
const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
|
|
327
|
-
const hour = timeParts[0].padStart(2, "0");
|
|
328
|
-
const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
|
|
329
|
-
const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
|
|
330
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
331
|
-
let result = moment(
|
|
332
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
333
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
334
|
-
);
|
|
335
|
-
if (!result.isValid()) return null;
|
|
336
|
-
result = result.subtract(7, "hours");
|
|
337
|
-
return result.format(dateTimeFormat);
|
|
338
|
-
}
|
|
339
|
-
return null;
|
|
340
|
-
}
|
|
341
|
-
if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
342
|
-
const [year, month, day] = cleanInput.split("-");
|
|
343
|
-
if (isValidDate(day, month, year)) {
|
|
344
|
-
return formatOutput(day, month, year);
|
|
345
|
-
}
|
|
346
|
-
return null;
|
|
347
|
-
}
|
|
348
|
-
if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
|
|
349
|
-
const [day, month, year] = cleanInput.split("/");
|
|
350
|
-
const paddedDay = day.padStart(2, "0");
|
|
351
|
-
const paddedMonth = month.padStart(2, "0");
|
|
352
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
353
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
354
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
355
|
-
}
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
|
|
359
|
-
const [day, month, year] = cleanInput.split("-");
|
|
360
|
-
const paddedDay = day.padStart(2, "0");
|
|
361
|
-
const paddedMonth = month.padStart(2, "0");
|
|
362
|
-
const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
|
|
363
|
-
if (isValidDate(paddedDay, paddedMonth, fullYear)) {
|
|
364
|
-
return formatOutput(paddedDay, paddedMonth, fullYear);
|
|
365
|
-
}
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
|
|
369
|
-
const [day, month] = cleanInput.split(/[\/-]/);
|
|
370
|
-
const paddedDay = day.padStart(2, "0");
|
|
371
|
-
const paddedMonth = month.padStart(2, "0");
|
|
372
|
-
if (isValidDate(paddedDay, paddedMonth, currentYear)) {
|
|
373
|
-
return formatOutput(paddedDay, paddedMonth, currentYear);
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
if (cleanInput.match(/^\d{4}$/)) {
|
|
378
|
-
const num = parseInt(cleanInput, 10);
|
|
379
|
-
if (num >= 2e3 && num <= maxYear) {
|
|
380
|
-
if (isValidDate(currentDay, currentMonth, num.toString())) {
|
|
381
|
-
return formatOutput(currentDay, currentMonth, num.toString());
|
|
382
|
-
}
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
const day = cleanInput.slice(0, 2);
|
|
386
|
-
const month = cleanInput.slice(2, 4);
|
|
387
|
-
if (isValidDate(day, month, currentYear)) {
|
|
388
|
-
return formatOutput(day, month, currentYear);
|
|
389
|
-
}
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
|
|
393
|
-
const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
|
|
394
|
-
let result = moment().subtract(daysToSubtract, "days");
|
|
395
|
-
if (isDateTime) {
|
|
396
|
-
result = result.subtract(7, "hours");
|
|
397
|
-
}
|
|
398
|
-
if (result.isValid()) {
|
|
399
|
-
return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
|
|
400
|
-
}
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
|
|
404
|
-
const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
|
|
405
|
-
const day = parts[0].padStart(2, "0");
|
|
406
|
-
const month = parts[1].padStart(2, "0");
|
|
407
|
-
let year = parts[2];
|
|
408
|
-
year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
|
|
409
|
-
if (isValidDate(day, month, year)) {
|
|
410
|
-
return formatOutput(day, month, year);
|
|
411
|
-
}
|
|
412
|
-
return null;
|
|
413
|
-
}
|
|
414
|
-
if (isDateTime) {
|
|
415
|
-
if (cleanInput.length === 9) {
|
|
416
|
-
const day = cleanInput.slice(0, 2);
|
|
417
|
-
const month = cleanInput.slice(2, 4);
|
|
418
|
-
const year = cleanInput.slice(4, 8);
|
|
419
|
-
const hour = cleanInput.slice(8, 9).padStart(2, "0");
|
|
420
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
421
|
-
let result = moment(
|
|
422
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
423
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
424
|
-
);
|
|
425
|
-
if (!result.isValid()) return null;
|
|
426
|
-
result = result.subtract(7, "hours");
|
|
427
|
-
return result.format(dateTimeFormat);
|
|
428
|
-
}
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
if (cleanInput.length === 10) {
|
|
432
|
-
const day = cleanInput.slice(0, 2);
|
|
433
|
-
const month = cleanInput.slice(2, 4);
|
|
434
|
-
const year = cleanInput.slice(4, 8);
|
|
435
|
-
const hour = cleanInput.slice(8, 10);
|
|
436
|
-
if (isValidDate(day, month, year) && isValidTime(hour)) {
|
|
437
|
-
let result = moment(
|
|
438
|
-
`${day}-${month}-${year} ${hour}:00:00`,
|
|
439
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
440
|
-
);
|
|
441
|
-
if (!result.isValid()) return null;
|
|
442
|
-
result = result.subtract(7, "hours");
|
|
443
|
-
return result.format(dateTimeFormat);
|
|
444
|
-
}
|
|
445
|
-
return null;
|
|
446
|
-
}
|
|
447
|
-
if (cleanInput.length === 11) {
|
|
448
|
-
const day = cleanInput.slice(0, 2);
|
|
449
|
-
const month = cleanInput.slice(2, 4);
|
|
450
|
-
const year = cleanInput.slice(4, 8);
|
|
451
|
-
const hour = cleanInput.slice(8, 10);
|
|
452
|
-
const minute = cleanInput.slice(10, 11).padStart(2, "0");
|
|
453
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
454
|
-
let result = moment(
|
|
455
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
456
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
457
|
-
);
|
|
458
|
-
if (!result.isValid()) return null;
|
|
459
|
-
result = result.subtract(7, "hours");
|
|
460
|
-
return result.format(dateTimeFormat);
|
|
461
|
-
}
|
|
462
|
-
return null;
|
|
463
|
-
}
|
|
464
|
-
if (cleanInput.length === 12) {
|
|
465
|
-
const day = cleanInput.slice(0, 2);
|
|
466
|
-
const month = cleanInput.slice(2, 4);
|
|
467
|
-
const year = cleanInput.slice(4, 8);
|
|
468
|
-
const hour = cleanInput.slice(8, 10);
|
|
469
|
-
const minute = cleanInput.slice(10, 12);
|
|
470
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
|
|
471
|
-
let result = moment(
|
|
472
|
-
`${day}-${month}-${year} ${hour}:${minute}:00`,
|
|
473
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
474
|
-
);
|
|
475
|
-
if (!result.isValid()) return null;
|
|
476
|
-
result = result.subtract(7, "hours");
|
|
477
|
-
return result.format(dateTimeFormat);
|
|
478
|
-
}
|
|
479
|
-
return null;
|
|
480
|
-
}
|
|
481
|
-
if (cleanInput.length === 13) {
|
|
482
|
-
const day = cleanInput.slice(0, 2);
|
|
483
|
-
const month = cleanInput.slice(2, 4);
|
|
484
|
-
const year = cleanInput.slice(4, 8);
|
|
485
|
-
const hour = cleanInput.slice(8, 10);
|
|
486
|
-
const minute = cleanInput.slice(10, 12);
|
|
487
|
-
const second = cleanInput.slice(12, 13).padStart(2, "0");
|
|
488
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
489
|
-
let result = moment(
|
|
490
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
491
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
492
|
-
);
|
|
493
|
-
if (!result.isValid()) return null;
|
|
494
|
-
result = result.subtract(7, "hours");
|
|
495
|
-
return result.format(dateTimeFormat);
|
|
496
|
-
}
|
|
497
|
-
return null;
|
|
498
|
-
}
|
|
499
|
-
if (cleanInput.length === 14) {
|
|
500
|
-
const day = cleanInput.slice(0, 2);
|
|
501
|
-
const month = cleanInput.slice(2, 4);
|
|
502
|
-
const year = cleanInput.slice(4, 8);
|
|
503
|
-
const hour = cleanInput.slice(8, 10);
|
|
504
|
-
const minute = cleanInput.slice(10, 12);
|
|
505
|
-
const second = cleanInput.slice(12, 14);
|
|
506
|
-
if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
|
|
507
|
-
let result = moment(
|
|
508
|
-
`${day}-${month}-${year} ${hour}:${minute}:${second}`,
|
|
509
|
-
"DD-MM-YYYY HH:mm:ss"
|
|
510
|
-
);
|
|
511
|
-
if (!result.isValid()) return null;
|
|
512
|
-
result = result.subtract(7, "hours");
|
|
513
|
-
return result.format(dateTimeFormat);
|
|
514
|
-
}
|
|
515
|
-
return null;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
const len = cleanInput.length;
|
|
519
|
-
if (len === 1 || len === 2) {
|
|
520
|
-
const paddedDay = cleanInput.padStart(2, "0");
|
|
521
|
-
if (isValidDate(paddedDay, currentMonth, currentYear)) {
|
|
522
|
-
return formatOutput(paddedDay, currentMonth, currentYear);
|
|
523
|
-
}
|
|
524
|
-
return null;
|
|
525
|
-
}
|
|
526
|
-
if (len === 3) {
|
|
527
|
-
const day = cleanInput.slice(0, 2);
|
|
528
|
-
const month = cleanInput.slice(2, 3).padStart(2, "0");
|
|
529
|
-
if (isValidDate(day, month, currentYear)) {
|
|
530
|
-
return formatOutput(day, month, currentYear);
|
|
531
|
-
}
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
if (len === 6) {
|
|
535
|
-
const day = cleanInput.slice(0, 2);
|
|
536
|
-
const month = cleanInput.slice(2, 4);
|
|
537
|
-
let year = cleanInput.slice(4, 6);
|
|
538
|
-
year = `20${year}`;
|
|
539
|
-
if (parseInt(month) > 12) {
|
|
540
|
-
if (isValidDate(day, currentMonth, currentYear)) {
|
|
541
|
-
return formatOutput(day, currentMonth, currentYear);
|
|
542
|
-
}
|
|
543
|
-
return null;
|
|
544
|
-
}
|
|
545
|
-
if (isValidDate(day, month, year)) {
|
|
546
|
-
return formatOutput(day, month, year);
|
|
547
|
-
}
|
|
548
|
-
return null;
|
|
549
|
-
}
|
|
550
|
-
if (len === 7) {
|
|
551
|
-
return null;
|
|
552
|
-
}
|
|
553
|
-
if (len === 8) {
|
|
554
|
-
const day = cleanInput.slice(0, 2);
|
|
555
|
-
const month = cleanInput.slice(2, 4);
|
|
556
|
-
const year = cleanInput.slice(4, 8);
|
|
557
|
-
if (isValidDate(day, month, year)) {
|
|
558
|
-
return formatOutput(day, month, year);
|
|
559
|
-
}
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
|
-
if (len > 8 && !isDateTime) {
|
|
563
|
-
return null;
|
|
564
|
-
}
|
|
565
|
-
return null;
|
|
566
|
-
};
|
|
567
|
-
|
|
568
234
|
// src/utils.ts
|
|
569
235
|
__reExport(utils_exports, utils_star);
|
|
570
236
|
import * as utils_star from "@fctc/interface-logic/utils";
|
|
571
237
|
|
|
572
238
|
// src/hooks/core/use-detail.ts
|
|
573
239
|
import { useQuery } from "@tanstack/react-query";
|
|
574
|
-
import { useEffect as
|
|
240
|
+
import { useEffect as useEffect2 } from "react";
|
|
575
241
|
|
|
576
242
|
// src/hooks/core/use-profile.ts
|
|
577
243
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
578
|
-
import { useEffect as
|
|
244
|
+
import { useEffect as useEffect3, useMemo } from "react";
|
|
579
245
|
|
|
580
246
|
// src/hooks/core/use-view-v2.ts
|
|
581
247
|
import { useMemo as useMemo2 } from "react";
|
|
582
248
|
|
|
583
249
|
// src/hooks/core/use-company.ts
|
|
584
250
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
585
|
-
import { useEffect as
|
|
251
|
+
import { useEffect as useEffect4, useMemo as useMemo3 } from "react";
|
|
586
252
|
|
|
587
253
|
// src/hooks/core/use-app-provider.tsx
|
|
588
254
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -603,7 +269,7 @@ var useAppProvider = () => {
|
|
|
603
269
|
};
|
|
604
270
|
|
|
605
271
|
// src/hooks/core/use-config.ts
|
|
606
|
-
import { useEffect as
|
|
272
|
+
import { useEffect as useEffect5 } from "react";
|
|
607
273
|
|
|
608
274
|
// src/hooks/core/use-get-specification.ts
|
|
609
275
|
import { useMemo as useMemo5 } from "react";
|
|
@@ -637,17 +303,13 @@ var useGetSpecification = ({
|
|
|
637
303
|
};
|
|
638
304
|
|
|
639
305
|
// src/hooks/core/use-list-data.ts
|
|
640
|
-
import { useMemo as useMemo6, useState as
|
|
641
|
-
import {
|
|
642
|
-
evalJSONDomain,
|
|
643
|
-
formatSortingString
|
|
644
|
-
} from "@fctc/interface-logic/utils";
|
|
306
|
+
import { useMemo as useMemo6, useState as useState5 } from "react";
|
|
645
307
|
|
|
646
308
|
// src/hooks/utils/use-debounce.ts
|
|
647
|
-
import { useEffect as
|
|
309
|
+
import { useEffect as useEffect6, useState as useState3 } from "react";
|
|
648
310
|
function useDebounce(value, delay) {
|
|
649
|
-
const [debouncedValue, setDebouncedValue] =
|
|
650
|
-
|
|
311
|
+
const [debouncedValue, setDebouncedValue] = useState3(value);
|
|
312
|
+
useEffect6(() => {
|
|
651
313
|
const handler = setTimeout(() => {
|
|
652
314
|
setDebouncedValue(value);
|
|
653
315
|
}, delay);
|
|
@@ -659,7 +321,7 @@ function useDebounce(value, delay) {
|
|
|
659
321
|
}
|
|
660
322
|
|
|
661
323
|
// src/hooks/utils/use-get-rowids.ts
|
|
662
|
-
import { useCallback as useCallback3, useEffect as
|
|
324
|
+
import { useCallback as useCallback3, useEffect as useEffect7, useRef, useState as useState4 } from "react";
|
|
663
325
|
var useGetRowIds = (tableRef) => {
|
|
664
326
|
function isElementVisible(el) {
|
|
665
327
|
const style = window.getComputedStyle(el);
|
|
@@ -676,8 +338,8 @@ var useGetRowIds = (tableRef) => {
|
|
|
676
338
|
}
|
|
677
339
|
return true;
|
|
678
340
|
}
|
|
679
|
-
const [rowIds, setRowIds] =
|
|
680
|
-
const lastRowIdsRef =
|
|
341
|
+
const [rowIds, setRowIds] = useState4([]);
|
|
342
|
+
const lastRowIdsRef = useRef([]);
|
|
681
343
|
const updateVisibleRowIds = useCallback3(() => {
|
|
682
344
|
const table = tableRef.current;
|
|
683
345
|
if (!table) return;
|
|
@@ -696,7 +358,7 @@ var useGetRowIds = (tableRef) => {
|
|
|
696
358
|
setRowIds(uniqueIds);
|
|
697
359
|
}
|
|
698
360
|
}, [tableRef]);
|
|
699
|
-
|
|
361
|
+
useEffect7(() => {
|
|
700
362
|
const table = tableRef.current;
|
|
701
363
|
if (!table) return;
|
|
702
364
|
const mutationObserver = new MutationObserver(() => {
|
|
@@ -736,12 +398,12 @@ var useListData = ({
|
|
|
736
398
|
limit = 10
|
|
737
399
|
}) => {
|
|
738
400
|
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
739
|
-
const [page, setPage] =
|
|
740
|
-
const [pageLimit, setPageLimit] =
|
|
741
|
-
const [groupByList, setGroupByList] =
|
|
742
|
-
const [domain, setDomain] =
|
|
743
|
-
const [order, setOrder] =
|
|
744
|
-
const [selectedRowKeys, setSelectedRowKeys] =
|
|
401
|
+
const [page, setPage] = useState5(0);
|
|
402
|
+
const [pageLimit, setPageLimit] = useState5(limit);
|
|
403
|
+
const [groupByList, setGroupByList] = useState5(null);
|
|
404
|
+
const [domain, setDomain] = useState5(null);
|
|
405
|
+
const [order, setOrder] = useState5("");
|
|
406
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState5([]);
|
|
745
407
|
const [debouncedPage] = useDebounce(page, 500);
|
|
746
408
|
const [debouncedDomain] = useDebounce(domain, 500);
|
|
747
409
|
const { specification } = useGetSpecification({
|
|
@@ -753,12 +415,12 @@ var useListData = ({
|
|
|
753
415
|
if (!viewData || !action || !context) {
|
|
754
416
|
return null;
|
|
755
417
|
}
|
|
756
|
-
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : evalJSONDomain(action?.domain, context) : [];
|
|
418
|
+
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, utils_exports.evalJSONDomain)(action?.domain, context) : [];
|
|
757
419
|
const limit2 = pageLimit;
|
|
758
420
|
const offset = debouncedPage * pageLimit;
|
|
759
421
|
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
760
422
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
761
|
-
const sort = order ?? formatSortingString(
|
|
423
|
+
const sort = order ?? (0, utils_exports.formatSortingString)(
|
|
762
424
|
(mode === "kanban" ? viewData?.views?.kanban : viewData?.views?.list)?.default_order
|
|
763
425
|
) ?? "";
|
|
764
426
|
return {
|
|
@@ -819,7 +481,59 @@ var useListData = ({
|
|
|
819
481
|
};
|
|
820
482
|
};
|
|
821
483
|
|
|
484
|
+
// src/widget/basic/status-dropdown-field/controller.ts
|
|
485
|
+
var statusDropdownController = (props) => {
|
|
486
|
+
const { selection, isForm, id, model, name, state, onRefetch } = props;
|
|
487
|
+
const env = (0, environment_exports.getEnv)();
|
|
488
|
+
const colors = {
|
|
489
|
+
normal: "bg-[#e9ecef]",
|
|
490
|
+
done: "bg-primary",
|
|
491
|
+
blocked: "bg-red-500"
|
|
492
|
+
};
|
|
493
|
+
const [isOpen, setIsOpen] = useState6(false);
|
|
494
|
+
const buttonRef = useRef2(null);
|
|
495
|
+
useEffect8(() => {
|
|
496
|
+
const handleClickOutside = (event) => {
|
|
497
|
+
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
498
|
+
setIsOpen(false);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
502
|
+
return () => {
|
|
503
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
504
|
+
};
|
|
505
|
+
}, []);
|
|
506
|
+
const { mutate: onSave } = useSave();
|
|
507
|
+
const handleClick = async (status) => {
|
|
508
|
+
setIsOpen(!isOpen);
|
|
509
|
+
onSave(
|
|
510
|
+
{
|
|
511
|
+
ids: id ? [id] : [],
|
|
512
|
+
model: model ?? "",
|
|
513
|
+
data: { [name ?? ""]: status },
|
|
514
|
+
context: env.context
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
onSuccess: () => {
|
|
518
|
+
onRefetch && onRefetch();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
return {
|
|
524
|
+
handleClick,
|
|
525
|
+
buttonRef,
|
|
526
|
+
isForm,
|
|
527
|
+
setIsOpen,
|
|
528
|
+
isOpen,
|
|
529
|
+
selection,
|
|
530
|
+
state,
|
|
531
|
+
colors
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
|
|
822
535
|
// src/widget/basic/many2one-field/controller.ts
|
|
536
|
+
import { useCallback as useCallback4, useEffect as useEffect9, useMemo as useMemo7, useState as useState7 } from "react";
|
|
823
537
|
var MANY2ONE_EXTERNAL = "many2one_external";
|
|
824
538
|
var many2oneFieldController = (props) => {
|
|
825
539
|
const {
|
|
@@ -842,7 +556,7 @@ var many2oneFieldController = (props) => {
|
|
|
842
556
|
} = props;
|
|
843
557
|
const { env } = (0, provider_exports.useEnv)();
|
|
844
558
|
const { action } = useAppProvider();
|
|
845
|
-
const { useGetSelection:
|
|
559
|
+
const { useGetSelection: useGetSelection2, useGetDetail: useGetDetail2 } = (0, provider_exports.useService)();
|
|
846
560
|
const [listOptions, setListOptions] = useState7([]);
|
|
847
561
|
const [inputValue, setInputValue] = useState7("");
|
|
848
562
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
@@ -880,7 +594,7 @@ var many2oneFieldController = (props) => {
|
|
|
880
594
|
data: dataOfSelection,
|
|
881
595
|
refetch,
|
|
882
596
|
isFetching
|
|
883
|
-
} =
|
|
597
|
+
} = useGetSelection2({
|
|
884
598
|
data,
|
|
885
599
|
queryKey: [`data_${relation}`, domainObject],
|
|
886
600
|
enabled: false,
|
|
@@ -1098,20 +812,17 @@ var many2oneFieldController = (props) => {
|
|
|
1098
812
|
};
|
|
1099
813
|
|
|
1100
814
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
1101
|
-
import { getEnv as getEnv2 } from "@fctc/interface-logic/environment";
|
|
1102
|
-
import { useGetSelection as useGetSelection2 } from "@fctc/interface-logic/hooks";
|
|
1103
|
-
import { evalJSONDomain as evalJSONDomain3, evalJSONContext as evalJSONContext3 } from "@fctc/interface-logic/utils";
|
|
1104
815
|
var many2oneButtonController = (props) => {
|
|
1105
816
|
const { domain, methods, relation, service, xNode } = props;
|
|
1106
817
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
1107
|
-
const env =
|
|
1108
|
-
const domainObject =
|
|
818
|
+
const env = (0, environment_exports.getEnv)();
|
|
819
|
+
const domainObject = (0, utils_exports.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
1109
820
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
1110
|
-
const { data: dataOfSelection } =
|
|
821
|
+
const { data: dataOfSelection } = useGetSelection({
|
|
1111
822
|
data: {
|
|
1112
823
|
model: relation ?? "",
|
|
1113
824
|
domain: domainObject,
|
|
1114
|
-
context: { ...env.context, ...
|
|
825
|
+
context: { ...env.context, ...(0, utils_exports.evalJSONContext)(actionData?.context) }
|
|
1115
826
|
},
|
|
1116
827
|
queryKey: [`data_${relation}`, domainObject],
|
|
1117
828
|
service,
|
|
@@ -1128,7 +839,6 @@ var many2oneButtonController = (props) => {
|
|
|
1128
839
|
|
|
1129
840
|
// src/widget/basic/many2many-field/controller.ts
|
|
1130
841
|
import { useEffect as useEffect10, useMemo as useMemo8 } from "react";
|
|
1131
|
-
import { evalJSONContext as evalJSONContext4 } from "@fctc/interface-logic/utils";
|
|
1132
842
|
var many2manyFieldController = (props) => {
|
|
1133
843
|
const {
|
|
1134
844
|
relation,
|
|
@@ -1136,7 +846,9 @@ var many2manyFieldController = (props) => {
|
|
|
1136
846
|
context,
|
|
1137
847
|
options,
|
|
1138
848
|
enabled: enabledCallAPI,
|
|
1139
|
-
service
|
|
849
|
+
service,
|
|
850
|
+
validateAndParseDate,
|
|
851
|
+
moment
|
|
1140
852
|
} = props;
|
|
1141
853
|
const { env } = (0, provider_exports.useEnv)();
|
|
1142
854
|
const { user } = useAppProvider();
|
|
@@ -1168,7 +880,7 @@ var many2manyFieldController = (props) => {
|
|
|
1168
880
|
});
|
|
1169
881
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
1170
882
|
const optionsObject = useMemo8(
|
|
1171
|
-
() => (options && typeof options === "string" ?
|
|
883
|
+
() => (options && typeof options === "string" ? (0, utils_exports.evalJSONContext)(options) : options) || {},
|
|
1172
884
|
[options]
|
|
1173
885
|
);
|
|
1174
886
|
const {
|
|
@@ -1228,10 +940,10 @@ var many2manyFieldController = (props) => {
|
|
|
1228
940
|
...columns?.filter(
|
|
1229
941
|
(col) => col?.field?.type_co === "field" && col?.optional !== "hide"
|
|
1230
942
|
)?.map((col) => ({ ...col.field })) ?? []
|
|
1231
|
-
]
|
|
943
|
+
],
|
|
944
|
+
validateAndParseDate,
|
|
945
|
+
moment
|
|
1232
946
|
});
|
|
1233
|
-
const handleCreateNewOnPage = async () => {
|
|
1234
|
-
};
|
|
1235
947
|
return {
|
|
1236
948
|
rows,
|
|
1237
949
|
columns,
|
|
@@ -1254,15 +966,19 @@ var many2manyFieldController = (props) => {
|
|
|
1254
966
|
setGroupByList,
|
|
1255
967
|
setSelectedRowKeys,
|
|
1256
968
|
searchController: searchControllers,
|
|
1257
|
-
handleCreateNewOnPage,
|
|
1258
969
|
specification
|
|
1259
970
|
};
|
|
1260
971
|
};
|
|
1261
972
|
|
|
1262
973
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
1263
974
|
import { useCallback as useCallback5, useEffect as useEffect11, useMemo as useMemo9, useState as useState8 } from "react";
|
|
1264
|
-
|
|
1265
|
-
|
|
975
|
+
|
|
976
|
+
// src/constants.ts
|
|
977
|
+
var constants_exports = {};
|
|
978
|
+
__reExport(constants_exports, constants_star);
|
|
979
|
+
import * as constants_star from "@fctc/interface-logic/constants";
|
|
980
|
+
|
|
981
|
+
// src/widget/basic/many2many-tags-field/controller.ts
|
|
1266
982
|
var many2manyTagsController = (props) => {
|
|
1267
983
|
const {
|
|
1268
984
|
relation,
|
|
@@ -1280,13 +996,13 @@ var many2manyTagsController = (props) => {
|
|
|
1280
996
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
1281
997
|
const { env } = (0, provider_exports.useEnv)();
|
|
1282
998
|
const { action } = useAppProvider();
|
|
1283
|
-
const { useGetSelection:
|
|
999
|
+
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
1284
1000
|
const [options, setOptions] = useState8([]);
|
|
1285
1001
|
const [domainObject, setDomainObject] = useState8(null);
|
|
1286
1002
|
const [isShowModalMany2Many, setIsShowModalMany2Many] = useState8(false);
|
|
1287
|
-
const addtionalFields = optionsFields ?
|
|
1003
|
+
const addtionalFields = optionsFields ? (0, utils_exports.evalJSONContext)(optionsFields) : null;
|
|
1288
1004
|
const contextObject = {
|
|
1289
|
-
...
|
|
1005
|
+
...(0, utils_exports.evalJSONContext)(action?.context) || {},
|
|
1290
1006
|
...fieldContext ?? {},
|
|
1291
1007
|
...env?.context
|
|
1292
1008
|
};
|
|
@@ -1302,7 +1018,7 @@ var many2manyTagsController = (props) => {
|
|
|
1302
1018
|
[formValues, contextObject]
|
|
1303
1019
|
);
|
|
1304
1020
|
useEffect11(() => {
|
|
1305
|
-
const newDomain =
|
|
1021
|
+
const newDomain = (0, utils_exports.evalJSONDomain)(domain, parsedFormValues);
|
|
1306
1022
|
setDomainObject(
|
|
1307
1023
|
(prev) => JSON.stringify(prev) === JSON.stringify(newDomain) ? prev : newDomain
|
|
1308
1024
|
);
|
|
@@ -1314,8 +1030,8 @@ var many2manyTagsController = (props) => {
|
|
|
1314
1030
|
id: {},
|
|
1315
1031
|
name: {},
|
|
1316
1032
|
display_name: {},
|
|
1317
|
-
...widget && WIDGETAVATAR[widget] ? { image_256: {} } : {},
|
|
1318
|
-
...widget && WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
|
|
1033
|
+
...widget && constants_exports.WIDGETAVATAR[widget] ? { image_256: {} } : {},
|
|
1034
|
+
...widget && constants_exports.WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
|
|
1319
1035
|
},
|
|
1320
1036
|
context: env.context
|
|
1321
1037
|
};
|
|
@@ -1324,7 +1040,7 @@ var many2manyTagsController = (props) => {
|
|
|
1324
1040
|
data: dataOfSelection,
|
|
1325
1041
|
refetch,
|
|
1326
1042
|
isFetching
|
|
1327
|
-
} =
|
|
1043
|
+
} = useGetSelection2({
|
|
1328
1044
|
data,
|
|
1329
1045
|
queryKey,
|
|
1330
1046
|
service,
|
|
@@ -1377,7 +1093,6 @@ var many2manyTagsController = (props) => {
|
|
|
1377
1093
|
|
|
1378
1094
|
// src/widget/basic/status-bar-field/controller.ts
|
|
1379
1095
|
import { useState as useState9 } from "react";
|
|
1380
|
-
import { evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
1381
1096
|
var durationController = (props) => {
|
|
1382
1097
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
1383
1098
|
const specification = {
|
|
@@ -1393,7 +1108,7 @@ var durationController = (props) => {
|
|
|
1393
1108
|
const listDataProps = {
|
|
1394
1109
|
model: relation,
|
|
1395
1110
|
specification,
|
|
1396
|
-
domain:
|
|
1111
|
+
domain: (0, utils_exports.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
1397
1112
|
limit: 10,
|
|
1398
1113
|
offset: 0,
|
|
1399
1114
|
fields: "",
|
|
@@ -1443,13 +1158,12 @@ var durationController = (props) => {
|
|
|
1443
1158
|
};
|
|
1444
1159
|
|
|
1445
1160
|
// src/widget/basic/priority-field/controller.ts
|
|
1446
|
-
import { evalJSONContext as evalJSONContext6 } from "@fctc/interface-logic/utils";
|
|
1447
1161
|
var priorityFieldController = (props) => {
|
|
1448
1162
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
1449
|
-
const _context = { ...
|
|
1163
|
+
const _context = { ...(0, utils_exports.evalJSONContext)(actionData?.context) };
|
|
1450
1164
|
const contextObject = { ...context, ..._context };
|
|
1451
|
-
const { useSave:
|
|
1452
|
-
const { mutateAsync: fetchSave } =
|
|
1165
|
+
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
1166
|
+
const { mutateAsync: fetchSave } = useSave2();
|
|
1453
1167
|
const savePriorities = async ({
|
|
1454
1168
|
value,
|
|
1455
1169
|
resetPriority
|
|
@@ -1581,15 +1295,14 @@ var copyLinkButtonController = (props) => {
|
|
|
1581
1295
|
};
|
|
1582
1296
|
|
|
1583
1297
|
// src/widget/basic/color-field/color-controller.ts
|
|
1584
|
-
import { evalJSONContext as evalJSONContext7 } from "@fctc/interface-logic/utils";
|
|
1585
1298
|
var colorFieldController = (props) => {
|
|
1586
1299
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
1587
1300
|
const { env } = (0, provider_exports.useEnv)();
|
|
1588
|
-
const { useSave:
|
|
1589
|
-
const _context = { ...
|
|
1301
|
+
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
1302
|
+
const _context = { ...(0, utils_exports.evalJSONContext)(actionData?.context) || {} };
|
|
1590
1303
|
const contextObject = { ...env.context, ..._context };
|
|
1591
1304
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
1592
|
-
const { mutate: onSave } =
|
|
1305
|
+
const { mutate: onSave } = useSave2();
|
|
1593
1306
|
const savePickColor = async (colorObject) => {
|
|
1594
1307
|
const { id } = colorObject;
|
|
1595
1308
|
if (value === id) return;
|
|
@@ -1808,7 +1521,7 @@ var providerEinvoiceFieldController = (props) => {
|
|
|
1808
1521
|
const { relation, formValues, options: fieldOptions, xNode } = props;
|
|
1809
1522
|
const { env } = (0, provider_exports.useEnv)();
|
|
1810
1523
|
const { action } = useAppProvider();
|
|
1811
|
-
const { useGetSelection:
|
|
1524
|
+
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
1812
1525
|
const contextObject = {
|
|
1813
1526
|
...(typeof action?.context === "string" ? (0, utils_exports.evalJSONContext)(action?.context) : action?.context) || {},
|
|
1814
1527
|
...env?.context
|
|
@@ -1828,7 +1541,7 @@ var providerEinvoiceFieldController = (props) => {
|
|
|
1828
1541
|
},
|
|
1829
1542
|
specification: optionsObject?.specification
|
|
1830
1543
|
};
|
|
1831
|
-
const { data: listDataCard } =
|
|
1544
|
+
const { data: listDataCard } = useGetSelection2({
|
|
1832
1545
|
data,
|
|
1833
1546
|
queryKey: [`data_${relation}`],
|
|
1834
1547
|
enabled: true,
|
|
@@ -1908,7 +1621,6 @@ var tableHeadController = (props) => {
|
|
|
1908
1621
|
|
|
1909
1622
|
// src/widget/advance/table/table-view/controller.ts
|
|
1910
1623
|
import { useCallback as useCallback6, useEffect as useEffect13, useMemo as useMemo11, useState as useState14 } from "react";
|
|
1911
|
-
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
1912
1624
|
var tableController = ({ data }) => {
|
|
1913
1625
|
const [rows, setRows] = useState14([]);
|
|
1914
1626
|
const [columnVisibility, setColumnVisibility] = useState14({});
|
|
@@ -1951,10 +1663,10 @@ var tableController = ({ data }) => {
|
|
|
1951
1663
|
const columns = useMemo11(() => {
|
|
1952
1664
|
try {
|
|
1953
1665
|
return mergeFields?.filter((item) => {
|
|
1954
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? domainHelper.matchDomains(
|
|
1666
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? utils_exports.domainHelper.matchDomains(
|
|
1955
1667
|
data.context,
|
|
1956
1668
|
item?.column_invisible
|
|
1957
|
-
) : item?.invisible ? domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
1669
|
+
) : item?.invisible ? utils_exports.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
1958
1670
|
})?.map((field) => {
|
|
1959
1671
|
const overridden = columnVisibility[field?.name];
|
|
1960
1672
|
return {
|
|
@@ -2084,24 +1796,18 @@ var tableGroupController = (props) => {
|
|
|
2084
1796
|
};
|
|
2085
1797
|
|
|
2086
1798
|
// src/widget/advance/search/controller.ts
|
|
2087
|
-
import
|
|
2088
|
-
import { useCallback as useCallback7, useEffect as useEffect14, useState as useState16 } from "react";
|
|
2089
|
-
|
|
2090
|
-
// src/constants.ts
|
|
2091
|
-
var constants_exports = {};
|
|
2092
|
-
__reExport(constants_exports, constants_star);
|
|
2093
|
-
import * as constants_star from "@fctc/interface-logic/constants";
|
|
2094
|
-
|
|
2095
|
-
// src/widget/advance/search/controller.ts
|
|
1799
|
+
import { useState as useState16, useEffect as useEffect14, useCallback as useCallback7 } from "react";
|
|
2096
1800
|
var searchController = ({
|
|
2097
1801
|
viewData,
|
|
2098
1802
|
model,
|
|
2099
1803
|
domain,
|
|
2100
1804
|
context,
|
|
2101
|
-
fieldsList
|
|
1805
|
+
fieldsList,
|
|
1806
|
+
validateAndParseDate,
|
|
1807
|
+
moment
|
|
2102
1808
|
}) => {
|
|
2103
1809
|
const { env } = (0, provider_exports.useEnv)();
|
|
2104
|
-
const [filterBy, setFilterBy] = useState16(
|
|
1810
|
+
const [filterBy, setFilterBy] = useState16([]);
|
|
2105
1811
|
const [searchBy, setSearchBy] = useState16(null);
|
|
2106
1812
|
const [groupBy, setGroupBy] = useState16(null);
|
|
2107
1813
|
const [selectedTags, setSelectedTags] = useState16(null);
|
|
@@ -2112,7 +1818,7 @@ var searchController = ({
|
|
|
2112
1818
|
const actionContext = typeof context === "string" ? (0, utils_exports.evalJSONContext)(context) : context;
|
|
2113
1819
|
const contextSearch = { ...env.context, ...actionContext };
|
|
2114
1820
|
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, utils_exports.evalJSONDomain)(domain, contextSearch) : [];
|
|
2115
|
-
const
|
|
1821
|
+
const resetAllStateSearch = () => {
|
|
2116
1822
|
setFilterBy([]);
|
|
2117
1823
|
setGroupBy([]);
|
|
2118
1824
|
setSearchBy([]);
|
|
@@ -2128,7 +1834,17 @@ var searchController = ({
|
|
|
2128
1834
|
const searchByItems = searchViews?.search_by?.filter(
|
|
2129
1835
|
(item) => !utils_exports.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
2130
1836
|
)?.map(
|
|
2131
|
-
({
|
|
1837
|
+
({
|
|
1838
|
+
string,
|
|
1839
|
+
name,
|
|
1840
|
+
filter_domain,
|
|
1841
|
+
operator,
|
|
1842
|
+
widget,
|
|
1843
|
+
class: classSearchItem,
|
|
1844
|
+
placeholder
|
|
1845
|
+
}, index) => ({
|
|
1846
|
+
placeholder,
|
|
1847
|
+
class: classSearchItem,
|
|
2132
1848
|
dataIndex: index,
|
|
2133
1849
|
title: string ?? dataModel?.[name]?.string,
|
|
2134
1850
|
name: name ?? dataModel?.[name]?.name,
|
|
@@ -2223,8 +1939,8 @@ var searchController = ({
|
|
|
2223
1939
|
} else if (value?.modelType === "datetime") {
|
|
2224
1940
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
2225
1941
|
const parsedDate = validateAndParseDate(value?.value, true);
|
|
2226
|
-
const hasTime =
|
|
2227
|
-
valueDomainItem = hasTime ?
|
|
1942
|
+
const hasTime = moment(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
1943
|
+
valueDomainItem = hasTime ? moment(parsedDate).format("YYYY-MM-DD HH:mm:ss") : moment(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
2228
1944
|
} else {
|
|
2229
1945
|
valueDomainItem = validateAndParseDate(value?.value, true);
|
|
2230
1946
|
}
|
|
@@ -2249,7 +1965,8 @@ var searchController = ({
|
|
|
2249
1965
|
type,
|
|
2250
1966
|
widget,
|
|
2251
1967
|
modelType,
|
|
2252
|
-
dataIndex
|
|
1968
|
+
dataIndex,
|
|
1969
|
+
date
|
|
2253
1970
|
} = objValues[0];
|
|
2254
1971
|
if (!key?.includes(constants_exports.SearchType.GROUP)) {
|
|
2255
1972
|
const values = objValues?.map((objValue) => objValue.value);
|
|
@@ -2259,7 +1976,8 @@ var searchController = ({
|
|
|
2259
1976
|
values,
|
|
2260
1977
|
type,
|
|
2261
1978
|
widget,
|
|
2262
|
-
modelType
|
|
1979
|
+
modelType,
|
|
1980
|
+
date
|
|
2263
1981
|
};
|
|
2264
1982
|
} else {
|
|
2265
1983
|
const contexts = [];
|
|
@@ -2300,6 +2018,19 @@ var searchController = ({
|
|
|
2300
2018
|
},
|
|
2301
2019
|
[searchMap]
|
|
2302
2020
|
);
|
|
2021
|
+
const removeSearchItemsByType = (type) => {
|
|
2022
|
+
const newSearchMap = {};
|
|
2023
|
+
Object.entries(searchMap).forEach(([key, values]) => {
|
|
2024
|
+
const isGroup = key.includes(constants_exports.SearchType.GROUP);
|
|
2025
|
+
const isFilter = key.includes(constants_exports.SearchType.FILTER);
|
|
2026
|
+
const isSearch = key.includes(constants_exports.SearchType.SEARCH);
|
|
2027
|
+
if (type === constants_exports.SearchType.GROUP && isGroup) return;
|
|
2028
|
+
if (type === constants_exports.SearchType.FILTER && isFilter) return;
|
|
2029
|
+
if (type === constants_exports.SearchType.SEARCH && isSearch) return;
|
|
2030
|
+
newSearchMap[key] = values;
|
|
2031
|
+
});
|
|
2032
|
+
setSearchMap(newSearchMap);
|
|
2033
|
+
};
|
|
2303
2034
|
useEffect14(() => {
|
|
2304
2035
|
setTagSearch(searchMap);
|
|
2305
2036
|
}, [searchMap]);
|
|
@@ -2397,7 +2128,7 @@ var searchController = ({
|
|
|
2397
2128
|
setFilterBy,
|
|
2398
2129
|
setGroupBy,
|
|
2399
2130
|
setSearchBy,
|
|
2400
|
-
|
|
2131
|
+
resetAllStateSearch,
|
|
2401
2132
|
setSelectedTags,
|
|
2402
2133
|
removeSearchItems,
|
|
2403
2134
|
onSearchString: onChangeSearchInput,
|
|
@@ -2407,7 +2138,8 @@ var searchController = ({
|
|
|
2407
2138
|
onKeyDown,
|
|
2408
2139
|
handleMouseEnter,
|
|
2409
2140
|
handleMouseLeave,
|
|
2410
|
-
hoveredIndexSearchList
|
|
2141
|
+
hoveredIndexSearchList,
|
|
2142
|
+
removeSearchItemsByType
|
|
2411
2143
|
};
|
|
2412
2144
|
};
|
|
2413
2145
|
export {
|