@fctc/widget-logic 2.3.7 → 2.3.8
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.d.mts +2 -7
- package/dist/hooks.d.ts +2 -7
- package/dist/hooks.js +110 -85
- package/dist/hooks.mjs +131 -97
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +271 -250
- package/dist/index.mjs +270 -227
- package/dist/utils.d.mts +14 -1
- package/dist/utils.d.ts +14 -1
- package/dist/utils.js +95 -0
- package/dist/utils.mjs +116 -1
- package/dist/widget.d.mts +28 -15
- package/dist/widget.d.ts +28 -15
- package/dist/widget.js +265 -240
- package/dist/widget.mjs +266 -218
- package/package.json +96 -96
package/dist/widget.js
CHANGED
|
@@ -4110,7 +4110,7 @@ var statusDropdownController = (props) => {
|
|
|
4110
4110
|
};
|
|
4111
4111
|
|
|
4112
4112
|
// src/widget/basic/many2one-field/controller.ts
|
|
4113
|
-
var
|
|
4113
|
+
var import_react15 = require("react");
|
|
4114
4114
|
|
|
4115
4115
|
// src/hooks.ts
|
|
4116
4116
|
var hooks_exports = {};
|
|
@@ -4123,7 +4123,6 @@ __export(hooks_exports, {
|
|
|
4123
4123
|
useConfig: () => useConfig,
|
|
4124
4124
|
useDebounce: () => useDebounce,
|
|
4125
4125
|
useDetail: () => useDetail,
|
|
4126
|
-
useGetRowIds: () => useGetRowIds,
|
|
4127
4126
|
useListData: () => useListData,
|
|
4128
4127
|
useMenu: () => useMenu,
|
|
4129
4128
|
useMenuItem: () => useMenuItem,
|
|
@@ -4251,6 +4250,12 @@ var import_react6 = require("react");
|
|
|
4251
4250
|
|
|
4252
4251
|
// src/utils/function.ts
|
|
4253
4252
|
var import_react5 = require("react");
|
|
4253
|
+
|
|
4254
|
+
// src/store.ts
|
|
4255
|
+
var store_exports = {};
|
|
4256
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4257
|
+
|
|
4258
|
+
// src/utils/function.ts
|
|
4254
4259
|
var countSum = (data, field) => {
|
|
4255
4260
|
if (!data || !field) return 0;
|
|
4256
4261
|
return data.reduce(
|
|
@@ -4269,6 +4274,91 @@ function mergeButtons(fields) {
|
|
|
4269
4274
|
}
|
|
4270
4275
|
return others;
|
|
4271
4276
|
}
|
|
4277
|
+
function isElementVisible(el) {
|
|
4278
|
+
const style = window.getComputedStyle(el);
|
|
4279
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4280
|
+
}
|
|
4281
|
+
function arraysAreEqual(a, b) {
|
|
4282
|
+
if (a.length !== b.length) return false;
|
|
4283
|
+
const setA = new Set(a);
|
|
4284
|
+
const setB = new Set(b);
|
|
4285
|
+
if (setA.size !== setB.size) return false;
|
|
4286
|
+
for (const val of setA) {
|
|
4287
|
+
if (!setB.has(val)) return false;
|
|
4288
|
+
}
|
|
4289
|
+
return true;
|
|
4290
|
+
}
|
|
4291
|
+
function useGetRowIds(tableRef) {
|
|
4292
|
+
const [rowIds, setRowIds] = (0, import_react5.useState)([]);
|
|
4293
|
+
const lastRowIdsRef = (0, import_react5.useRef)([]);
|
|
4294
|
+
const updateVisibleRowIds = (0, import_react5.useCallback)(() => {
|
|
4295
|
+
const table = tableRef?.current;
|
|
4296
|
+
if (!table) return;
|
|
4297
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4298
|
+
const ids = [];
|
|
4299
|
+
rows.forEach((row) => {
|
|
4300
|
+
const el = row;
|
|
4301
|
+
if (isElementVisible(el)) {
|
|
4302
|
+
const id = el.getAttribute("data-row-id");
|
|
4303
|
+
if (id) ids.push(id);
|
|
4304
|
+
}
|
|
4305
|
+
});
|
|
4306
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4307
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4308
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4309
|
+
setRowIds(uniqueIds);
|
|
4310
|
+
}
|
|
4311
|
+
}, [tableRef]);
|
|
4312
|
+
(0, import_react5.useEffect)(() => {
|
|
4313
|
+
const table = tableRef?.current;
|
|
4314
|
+
if (!table) return;
|
|
4315
|
+
const observer = new MutationObserver(() => {
|
|
4316
|
+
updateVisibleRowIds();
|
|
4317
|
+
});
|
|
4318
|
+
observer.observe(table, {
|
|
4319
|
+
childList: true,
|
|
4320
|
+
subtree: true,
|
|
4321
|
+
attributes: true,
|
|
4322
|
+
attributeFilter: ["style", "class"]
|
|
4323
|
+
});
|
|
4324
|
+
updateVisibleRowIds();
|
|
4325
|
+
return () => {
|
|
4326
|
+
observer.disconnect();
|
|
4327
|
+
};
|
|
4328
|
+
}, [updateVisibleRowIds, tableRef]);
|
|
4329
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4330
|
+
}
|
|
4331
|
+
var useSelectionState = ({
|
|
4332
|
+
typeTable,
|
|
4333
|
+
tableRef,
|
|
4334
|
+
rows
|
|
4335
|
+
}) => {
|
|
4336
|
+
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
4337
|
+
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
4338
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
4339
|
+
const selectedRowKeysRef = (0, import_react5.useRef)(recordIds);
|
|
4340
|
+
const isGroupTable = typeTable === "group";
|
|
4341
|
+
const recordsCheckedGroup = (0, import_react5.useMemo)(() => {
|
|
4342
|
+
if (!rows || !groupByDomain) return 0;
|
|
4343
|
+
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
4344
|
+
return countSum(rows, groupBy);
|
|
4345
|
+
}, [rows, groupByDomain]);
|
|
4346
|
+
const isAllGroupChecked = (0, import_react5.useMemo)(() => {
|
|
4347
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
4348
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
4349
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
4350
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
4351
|
+
return allGroupsSelected || allRecordsSelected;
|
|
4352
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
4353
|
+
const isAllNormalChecked = (0, import_react5.useMemo)(() => {
|
|
4354
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
4355
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
4356
|
+
(id) => rows.some((record) => record.id === id)
|
|
4357
|
+
);
|
|
4358
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
4359
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
4360
|
+
return { checkedAll, selectedRowKeysRef };
|
|
4361
|
+
};
|
|
4272
4362
|
var getDateRange = (currentDate, unit) => {
|
|
4273
4363
|
const date = new Date(currentDate);
|
|
4274
4364
|
let dateStart, dateEnd;
|
|
@@ -4409,19 +4499,19 @@ function useStorageState(key) {
|
|
|
4409
4499
|
|
|
4410
4500
|
// src/hooks/core/use-list-data.ts
|
|
4411
4501
|
var import_hooks4 = require("@fctc/interface-logic/hooks");
|
|
4412
|
-
var
|
|
4502
|
+
var import_store4 = require("@fctc/interface-logic/store");
|
|
4413
4503
|
var import_utils = require("@fctc/interface-logic/utils");
|
|
4414
4504
|
var useListData = ({
|
|
4415
4505
|
action,
|
|
4416
4506
|
context,
|
|
4417
4507
|
viewResponse
|
|
4418
4508
|
}) => {
|
|
4419
|
-
const { groupByDomain } = (0,
|
|
4509
|
+
const { groupByDomain } = (0, import_store4.useAppSelector)(import_store4.selectSearch);
|
|
4420
4510
|
const initModel = (0, import_hooks4.useModel)();
|
|
4421
4511
|
const [type, setType] = (0, import_react6.useState)("list");
|
|
4422
4512
|
const [mode, setMode] = (0, import_react6.useState)("month");
|
|
4423
4513
|
const [currentDate, setCurrentDate] = (0, import_react6.useState)(/* @__PURE__ */ new Date());
|
|
4424
|
-
const { pageLimit, page, order } = (0,
|
|
4514
|
+
const { pageLimit, page, order } = (0, import_store4.useAppSelector)(import_store4.selectList);
|
|
4425
4515
|
const listDataProps = (0, import_react6.useMemo)(() => {
|
|
4426
4516
|
const actData = action?.result;
|
|
4427
4517
|
if (!viewResponse || !actData || !context) {
|
|
@@ -4556,10 +4646,10 @@ var import_react8 = require("react");
|
|
|
4556
4646
|
var import_react_i18next = require("react-i18next");
|
|
4557
4647
|
var import_environment4 = require("@fctc/interface-logic/environment");
|
|
4558
4648
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
4559
|
-
var
|
|
4649
|
+
var import_store5 = require("@fctc/interface-logic/store");
|
|
4560
4650
|
var useProfile = (accessToken) => {
|
|
4561
4651
|
const getProfile = (0, import_hooks6.useGetProfile)();
|
|
4562
|
-
const dispatch = (0,
|
|
4652
|
+
const dispatch = (0, import_store5.useAppDispatch)();
|
|
4563
4653
|
const { i18n: i18n2 } = (0, import_react_i18next.useTranslation)();
|
|
4564
4654
|
const fetchUserProfile = async () => {
|
|
4565
4655
|
return await getProfile.mutateAsync();
|
|
@@ -4574,7 +4664,7 @@ var useProfile = (accessToken) => {
|
|
|
4574
4664
|
const userInfo = userInfoQuery.data;
|
|
4575
4665
|
const env = (0, import_environment4.getEnv)();
|
|
4576
4666
|
env.setUid(userInfo?.sub);
|
|
4577
|
-
dispatch((0,
|
|
4667
|
+
dispatch((0, import_store5.setDataUser)(userInfo));
|
|
4578
4668
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
4579
4669
|
env.setLang(userLocale?.id);
|
|
4580
4670
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
@@ -4639,11 +4729,11 @@ var useViewV2 = ({
|
|
|
4639
4729
|
|
|
4640
4730
|
// src/hooks/core/use-auth.ts
|
|
4641
4731
|
var import_hooks8 = require("@fctc/interface-logic/hooks");
|
|
4642
|
-
var
|
|
4732
|
+
var import_store6 = require("@fctc/interface-logic/store");
|
|
4643
4733
|
var useAuth = () => {
|
|
4644
4734
|
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
4645
4735
|
const loginMutate = (0, import_hooks8.useLoginCredential)();
|
|
4646
|
-
const dispatch = (0,
|
|
4736
|
+
const dispatch = (0, import_store6.useAppDispatch)();
|
|
4647
4737
|
const signIn = async (email, password) => {
|
|
4648
4738
|
try {
|
|
4649
4739
|
loginMutate.mutate(
|
|
@@ -4664,9 +4754,9 @@ var useAuth = () => {
|
|
|
4664
4754
|
}
|
|
4665
4755
|
};
|
|
4666
4756
|
const signOut = async () => {
|
|
4667
|
-
dispatch((0,
|
|
4668
|
-
dispatch((0,
|
|
4669
|
-
dispatch((0,
|
|
4757
|
+
dispatch((0, import_store6.setMenuList)([]));
|
|
4758
|
+
dispatch((0, import_store6.setDataUser)({}));
|
|
4759
|
+
dispatch((0, import_store6.setProfile)({}));
|
|
4670
4760
|
setAccessToken(null);
|
|
4671
4761
|
};
|
|
4672
4762
|
return {
|
|
@@ -4813,6 +4903,8 @@ __export(utils_exports, {
|
|
|
4813
4903
|
languages: () => languages,
|
|
4814
4904
|
mergeButtons: () => mergeButtons,
|
|
4815
4905
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4906
|
+
useGetRowIds: () => useGetRowIds,
|
|
4907
|
+
useSelectionState: () => useSelectionState,
|
|
4816
4908
|
useStorageState: () => useStorageState
|
|
4817
4909
|
});
|
|
4818
4910
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
@@ -4854,74 +4946,8 @@ var useMenuItem = (props) => {
|
|
|
4854
4946
|
return { handleClick, path, queryActionDetail };
|
|
4855
4947
|
};
|
|
4856
4948
|
|
|
4857
|
-
// src/hooks/core/use-get-rowids.ts
|
|
4858
|
-
var import_react13 = require("react");
|
|
4859
|
-
var useGetRowIds = (tableRef) => {
|
|
4860
|
-
function isElementVisible(el) {
|
|
4861
|
-
const style = window.getComputedStyle(el);
|
|
4862
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4863
|
-
}
|
|
4864
|
-
function arraysAreEqual(a, b) {
|
|
4865
|
-
if (a.length !== b.length) return false;
|
|
4866
|
-
if (a.length === 0 && b.length === 0) return true;
|
|
4867
|
-
const setA = new Set(a);
|
|
4868
|
-
const setB = new Set(b);
|
|
4869
|
-
if (setA.size !== setB.size) return false;
|
|
4870
|
-
for (const val of setA) {
|
|
4871
|
-
if (!setB.has(val)) return false;
|
|
4872
|
-
}
|
|
4873
|
-
return true;
|
|
4874
|
-
}
|
|
4875
|
-
const [rowIds, setRowIds] = (0, import_react13.useState)([]);
|
|
4876
|
-
const lastRowIdsRef = (0, import_react13.useRef)([]);
|
|
4877
|
-
const updateVisibleRowIds = (0, import_react13.useCallback)(() => {
|
|
4878
|
-
const table = tableRef.current;
|
|
4879
|
-
if (!table) return;
|
|
4880
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4881
|
-
const ids = [];
|
|
4882
|
-
rows.forEach((row) => {
|
|
4883
|
-
const el = row;
|
|
4884
|
-
if (isElementVisible(el)) {
|
|
4885
|
-
const id = el.getAttribute("data-row-id");
|
|
4886
|
-
if (id) ids.push(id);
|
|
4887
|
-
}
|
|
4888
|
-
});
|
|
4889
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4890
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4891
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4892
|
-
setRowIds(uniqueIds);
|
|
4893
|
-
}
|
|
4894
|
-
}, [tableRef]);
|
|
4895
|
-
(0, import_react13.useEffect)(() => {
|
|
4896
|
-
const table = tableRef.current;
|
|
4897
|
-
if (!table) return;
|
|
4898
|
-
const mutationObserver = new MutationObserver(() => {
|
|
4899
|
-
updateVisibleRowIds();
|
|
4900
|
-
});
|
|
4901
|
-
mutationObserver.observe(table, {
|
|
4902
|
-
childList: true,
|
|
4903
|
-
subtree: true,
|
|
4904
|
-
attributes: true,
|
|
4905
|
-
attributeFilter: ["style", "class"]
|
|
4906
|
-
});
|
|
4907
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
4908
|
-
updateVisibleRowIds();
|
|
4909
|
-
});
|
|
4910
|
-
resizeObserver.observe(table);
|
|
4911
|
-
const handleScroll = () => updateVisibleRowIds();
|
|
4912
|
-
table.addEventListener("scroll", handleScroll, true);
|
|
4913
|
-
updateVisibleRowIds();
|
|
4914
|
-
return () => {
|
|
4915
|
-
mutationObserver.disconnect();
|
|
4916
|
-
resizeObserver.disconnect();
|
|
4917
|
-
table.removeEventListener("scroll", handleScroll, true);
|
|
4918
|
-
};
|
|
4919
|
-
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4920
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4921
|
-
};
|
|
4922
|
-
|
|
4923
4949
|
// src/hooks/utils/use-click-outside.ts
|
|
4924
|
-
var
|
|
4950
|
+
var import_react13 = require("react");
|
|
4925
4951
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4926
4952
|
var useClickOutside = ({
|
|
4927
4953
|
handler,
|
|
@@ -4929,8 +4955,8 @@ var useClickOutside = ({
|
|
|
4929
4955
|
nodes = [],
|
|
4930
4956
|
refs
|
|
4931
4957
|
}) => {
|
|
4932
|
-
const ref = (0,
|
|
4933
|
-
(0,
|
|
4958
|
+
const ref = (0, import_react13.useRef)(null);
|
|
4959
|
+
(0, import_react13.useEffect)(() => {
|
|
4934
4960
|
const listener = (event) => {
|
|
4935
4961
|
const { target } = event;
|
|
4936
4962
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4952,10 +4978,10 @@ var useClickOutside = ({
|
|
|
4952
4978
|
};
|
|
4953
4979
|
|
|
4954
4980
|
// src/hooks/utils/use-debounce.ts
|
|
4955
|
-
var
|
|
4981
|
+
var import_react14 = require("react");
|
|
4956
4982
|
function useDebounce(value, delay) {
|
|
4957
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4958
|
-
(0,
|
|
4983
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
4984
|
+
(0, import_react14.useEffect)(() => {
|
|
4959
4985
|
const handler = setTimeout(() => {
|
|
4960
4986
|
setDebouncedValue(value);
|
|
4961
4987
|
}, delay);
|
|
@@ -4969,10 +4995,6 @@ function useDebounce(value, delay) {
|
|
|
4969
4995
|
// src/hooks.ts
|
|
4970
4996
|
__reExport(hooks_exports, require("@fctc/interface-logic/hooks"));
|
|
4971
4997
|
|
|
4972
|
-
// src/store.ts
|
|
4973
|
-
var store_exports = {};
|
|
4974
|
-
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4975
|
-
|
|
4976
4998
|
// src/provider.ts
|
|
4977
4999
|
var provider_exports = {};
|
|
4978
5000
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
@@ -4993,13 +5015,13 @@ var many2oneFieldController = (props) => {
|
|
|
4993
5015
|
showDetail
|
|
4994
5016
|
} = props;
|
|
4995
5017
|
const { env } = (0, provider_exports.useEnv)();
|
|
4996
|
-
const [options, setOptions] = (0,
|
|
4997
|
-
const [inputValue, setInputValue] = (0,
|
|
5018
|
+
const [options, setOptions] = (0, import_react15.useState)([]);
|
|
5019
|
+
const [inputValue, setInputValue] = (0, import_react15.useState)("");
|
|
4998
5020
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
4999
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
5000
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
5001
|
-
const [domainModal, setDomainModal] = (0,
|
|
5002
|
-
const [domainObject, setDomainObject] = (0,
|
|
5021
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react15.useState)(false);
|
|
5022
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react15.useState)(null);
|
|
5023
|
+
const [domainModal, setDomainModal] = (0, import_react15.useState)(null);
|
|
5024
|
+
const [domainObject, setDomainObject] = (0, import_react15.useState)(null);
|
|
5003
5025
|
const actionData = sessionStorageUtils.getActionData();
|
|
5004
5026
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5005
5027
|
const initValue = methods?.getValues(name);
|
|
@@ -5030,18 +5052,18 @@ var many2oneFieldController = (props) => {
|
|
|
5030
5052
|
queryKey,
|
|
5031
5053
|
enabled: false
|
|
5032
5054
|
});
|
|
5033
|
-
const selectOptions = (0,
|
|
5055
|
+
const selectOptions = (0, import_react15.useMemo)(() => {
|
|
5034
5056
|
return dataOfSelection?.records?.map((val) => ({
|
|
5035
5057
|
value: val?.id,
|
|
5036
5058
|
label: val?.display_name || val?.name
|
|
5037
5059
|
})) || [];
|
|
5038
5060
|
}, [dataOfSelection]);
|
|
5039
|
-
(0,
|
|
5061
|
+
(0, import_react15.useEffect)(() => {
|
|
5040
5062
|
setOptions(selectOptions);
|
|
5041
5063
|
setDomainModal(domainObject);
|
|
5042
5064
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5043
5065
|
}, [selectOptions]);
|
|
5044
|
-
(0,
|
|
5066
|
+
(0, import_react15.useEffect)(() => {
|
|
5045
5067
|
setDomainObject(
|
|
5046
5068
|
(0, utils_exports.evalJSONDomain)(
|
|
5047
5069
|
domain,
|
|
@@ -5049,7 +5071,7 @@ var many2oneFieldController = (props) => {
|
|
|
5049
5071
|
)
|
|
5050
5072
|
);
|
|
5051
5073
|
}, [domain, formValues]);
|
|
5052
|
-
(0,
|
|
5074
|
+
(0, import_react15.useEffect)(() => {
|
|
5053
5075
|
if (!propValue && tempSelectedOption) {
|
|
5054
5076
|
methods.setValue(name, null);
|
|
5055
5077
|
setTempSelectedOption(null);
|
|
@@ -5060,10 +5082,10 @@ var many2oneFieldController = (props) => {
|
|
|
5060
5082
|
});
|
|
5061
5083
|
}
|
|
5062
5084
|
}, [propValue]);
|
|
5063
|
-
const fetchMoreOptions = (0,
|
|
5085
|
+
const fetchMoreOptions = (0, import_react15.useCallback)(() => {
|
|
5064
5086
|
refetch();
|
|
5065
5087
|
}, [refetch]);
|
|
5066
|
-
(0,
|
|
5088
|
+
(0, import_react15.useEffect)(() => {
|
|
5067
5089
|
if (debouncedInputValue) {
|
|
5068
5090
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5069
5091
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5078,7 +5100,7 @@ var many2oneFieldController = (props) => {
|
|
|
5078
5100
|
}, 50);
|
|
5079
5101
|
}
|
|
5080
5102
|
}, [debouncedInputValue]);
|
|
5081
|
-
const handleChooseRecord = (0,
|
|
5103
|
+
const handleChooseRecord = (0, import_react15.useCallback)(
|
|
5082
5104
|
(idRecord) => {
|
|
5083
5105
|
const newOption = options.find(
|
|
5084
5106
|
(option) => option.value === idRecord
|
|
@@ -5103,8 +5125,8 @@ var many2oneFieldController = (props) => {
|
|
|
5103
5125
|
},
|
|
5104
5126
|
[options, methods, name, onChange]
|
|
5105
5127
|
);
|
|
5106
|
-
const handleClose = (0,
|
|
5107
|
-
const handleSelectChange = (0,
|
|
5128
|
+
const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5129
|
+
const handleSelectChange = (0, import_react15.useCallback)(
|
|
5108
5130
|
(selectedOption) => {
|
|
5109
5131
|
if (!selectedOption) {
|
|
5110
5132
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5178,7 +5200,7 @@ var many2oneButtonController = (props) => {
|
|
|
5178
5200
|
};
|
|
5179
5201
|
|
|
5180
5202
|
// src/widget/basic/many2many-field/controller.ts
|
|
5181
|
-
var
|
|
5203
|
+
var import_react16 = require("react");
|
|
5182
5204
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5183
5205
|
var many2manyFieldController = (props) => {
|
|
5184
5206
|
const {
|
|
@@ -5193,10 +5215,10 @@ var many2manyFieldController = (props) => {
|
|
|
5193
5215
|
actionData
|
|
5194
5216
|
} = props;
|
|
5195
5217
|
const { env } = (0, provider_exports.useEnv)();
|
|
5196
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5197
|
-
const [order, setOrder] = (0,
|
|
5198
|
-
const [page, setPage] = (0,
|
|
5199
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
5218
|
+
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5219
|
+
const [order, setOrder] = (0, import_react16.useState)();
|
|
5220
|
+
const [page, setPage] = (0, import_react16.useState)(0);
|
|
5221
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(null);
|
|
5200
5222
|
const [debouncedPage] = useDebounce(page, 500);
|
|
5201
5223
|
const contextObject = {
|
|
5202
5224
|
...env.context,
|
|
@@ -5211,7 +5233,7 @@ var many2manyFieldController = (props) => {
|
|
|
5211
5233
|
context: contextObject
|
|
5212
5234
|
};
|
|
5213
5235
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5214
|
-
const baseModel = (0,
|
|
5236
|
+
const baseModel = (0, import_react16.useMemo)(
|
|
5215
5237
|
() => ({
|
|
5216
5238
|
name: String(relation),
|
|
5217
5239
|
view: viewResponse || {},
|
|
@@ -5224,13 +5246,13 @@ var many2manyFieldController = (props) => {
|
|
|
5224
5246
|
[relation, viewResponse]
|
|
5225
5247
|
);
|
|
5226
5248
|
const initModel = (0, hooks_exports.useModel)();
|
|
5227
|
-
const modelInstance = (0,
|
|
5249
|
+
const modelInstance = (0, import_react16.useMemo)(() => {
|
|
5228
5250
|
if (viewResponse) {
|
|
5229
5251
|
return initModel.initModel(baseModel);
|
|
5230
5252
|
}
|
|
5231
5253
|
return null;
|
|
5232
5254
|
}, [baseModel, viewResponse]);
|
|
5233
|
-
const specification = (0,
|
|
5255
|
+
const specification = (0, import_react16.useMemo)(() => {
|
|
5234
5256
|
if (modelInstance) {
|
|
5235
5257
|
return modelInstance.getSpecification();
|
|
5236
5258
|
}
|
|
@@ -5272,8 +5294,8 @@ var many2manyFieldController = (props) => {
|
|
|
5272
5294
|
isLoading,
|
|
5273
5295
|
isFetched,
|
|
5274
5296
|
isPlaceholderData
|
|
5275
|
-
} =
|
|
5276
|
-
(0,
|
|
5297
|
+
} = useGetListData3(data, queryKey, enabled);
|
|
5298
|
+
(0, import_react16.useEffect)(() => {
|
|
5277
5299
|
if (viewResponse) {
|
|
5278
5300
|
fetchData();
|
|
5279
5301
|
}
|
|
@@ -5326,7 +5348,7 @@ var many2manyFieldController = (props) => {
|
|
|
5326
5348
|
};
|
|
5327
5349
|
|
|
5328
5350
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5329
|
-
var
|
|
5351
|
+
var import_react17 = require("react");
|
|
5330
5352
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5331
5353
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5332
5354
|
var many2manyTagsController = (props) => {
|
|
@@ -5342,7 +5364,7 @@ var many2manyTagsController = (props) => {
|
|
|
5342
5364
|
const { env } = (0, provider_exports.useEnv)();
|
|
5343
5365
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5344
5366
|
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5345
|
-
const domainObject = (0,
|
|
5367
|
+
const domainObject = (0, import_react17.useMemo)(
|
|
5346
5368
|
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5347
5369
|
[domain, formValues]
|
|
5348
5370
|
);
|
|
@@ -5384,7 +5406,7 @@ var many2manyTagsController = (props) => {
|
|
|
5384
5406
|
};
|
|
5385
5407
|
|
|
5386
5408
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5387
|
-
var
|
|
5409
|
+
var import_react18 = require("react");
|
|
5388
5410
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5389
5411
|
var durationController = (props) => {
|
|
5390
5412
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
@@ -5393,10 +5415,10 @@ var durationController = (props) => {
|
|
|
5393
5415
|
name: "",
|
|
5394
5416
|
fold: ""
|
|
5395
5417
|
};
|
|
5396
|
-
const { useGetListData:
|
|
5418
|
+
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5397
5419
|
const { env } = (0, provider_exports.useEnv)();
|
|
5398
|
-
const [disabled, setDisabled] = (0,
|
|
5399
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5420
|
+
const [disabled, setDisabled] = (0, import_react18.useState)(false);
|
|
5421
|
+
const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
|
|
5400
5422
|
const queryKey = [`data-status-duration`, specification];
|
|
5401
5423
|
const listDataProps = {
|
|
5402
5424
|
model: relation,
|
|
@@ -5411,7 +5433,7 @@ var durationController = (props) => {
|
|
|
5411
5433
|
},
|
|
5412
5434
|
sort: ""
|
|
5413
5435
|
};
|
|
5414
|
-
const { data: dataResponse } =
|
|
5436
|
+
const { data: dataResponse } = useGetListData3(
|
|
5415
5437
|
listDataProps,
|
|
5416
5438
|
queryKey,
|
|
5417
5439
|
enabled
|
|
@@ -5486,10 +5508,10 @@ var priorityFieldController = (props) => {
|
|
|
5486
5508
|
};
|
|
5487
5509
|
|
|
5488
5510
|
// src/widget/basic/download-file-field/controller.ts
|
|
5489
|
-
var
|
|
5511
|
+
var import_react19 = require("react");
|
|
5490
5512
|
var downloadFileController = () => {
|
|
5491
|
-
const inputId = (0,
|
|
5492
|
-
const [file, setFile] = (0,
|
|
5513
|
+
const inputId = (0, import_react19.useId)();
|
|
5514
|
+
const [file, setFile] = (0, import_react19.useState)(null);
|
|
5493
5515
|
const handleFileChange = (e) => {
|
|
5494
5516
|
setFile(e.target.files[0]);
|
|
5495
5517
|
};
|
|
@@ -6421,11 +6443,11 @@ var dateFieldController = (props) => {
|
|
|
6421
6443
|
};
|
|
6422
6444
|
|
|
6423
6445
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6424
|
-
var
|
|
6446
|
+
var import_react20 = require("react");
|
|
6425
6447
|
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6426
6448
|
var copyLinkButtonController = (props) => {
|
|
6427
6449
|
const { value, defaultValue } = props;
|
|
6428
|
-
const [isCopied, setIsCopied] = (0,
|
|
6450
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
6429
6451
|
const handleCopyToClipboard = async (value2) => {
|
|
6430
6452
|
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6431
6453
|
setIsCopied(true);
|
|
@@ -6473,16 +6495,16 @@ var colorFieldController = (props) => {
|
|
|
6473
6495
|
};
|
|
6474
6496
|
|
|
6475
6497
|
// src/widget/basic/binary-field/controller.ts
|
|
6476
|
-
var
|
|
6498
|
+
var import_react21 = require("react");
|
|
6477
6499
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6478
6500
|
var binaryFieldController = (props) => {
|
|
6479
6501
|
const { name, methods, readonly = false, value } = props;
|
|
6480
|
-
const inputId = (0,
|
|
6481
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6482
|
-
const [initialImage, setInitialImage] = (0,
|
|
6483
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6502
|
+
const inputId = (0, import_react21.useId)();
|
|
6503
|
+
const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
|
|
6504
|
+
const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
|
|
6505
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
|
|
6484
6506
|
const { setValue } = methods;
|
|
6485
|
-
const binaryRef = (0,
|
|
6507
|
+
const binaryRef = (0, import_react21.useRef)(null);
|
|
6486
6508
|
const convertUrlToBase64 = async (url) => {
|
|
6487
6509
|
try {
|
|
6488
6510
|
const response = await fetch(url);
|
|
@@ -6544,14 +6566,14 @@ var binaryFieldController = (props) => {
|
|
|
6544
6566
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6545
6567
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6546
6568
|
};
|
|
6547
|
-
(0,
|
|
6569
|
+
(0, import_react21.useEffect)(() => {
|
|
6548
6570
|
return () => {
|
|
6549
6571
|
if (selectedImage) {
|
|
6550
6572
|
URL.revokeObjectURL(selectedImage);
|
|
6551
6573
|
}
|
|
6552
6574
|
};
|
|
6553
6575
|
}, [selectedImage]);
|
|
6554
|
-
(0,
|
|
6576
|
+
(0, import_react21.useEffect)(() => {
|
|
6555
6577
|
if (binaryRef.current) {
|
|
6556
6578
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6557
6579
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6571,73 +6593,50 @@ var binaryFieldController = (props) => {
|
|
|
6571
6593
|
};
|
|
6572
6594
|
|
|
6573
6595
|
// src/widget/advance/table/table-head/controller.ts
|
|
6574
|
-
var
|
|
6575
|
-
var import_react23 = require("react");
|
|
6596
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6576
6597
|
var tableHeadController = (props) => {
|
|
6577
|
-
const { typeTable, rows,
|
|
6578
|
-
const appDispatch = (0,
|
|
6579
|
-
const {
|
|
6580
|
-
const selectedRowKeysRef = (0, import_react23.useRef)(recordIds);
|
|
6581
|
-
const isGroupTable = typeTable === "group";
|
|
6582
|
-
const recordsCheckedGroup = (0, import_react23.useMemo)(() => {
|
|
6583
|
-
if (!rows || !groupByList) return 0;
|
|
6584
|
-
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6585
|
-
return countSum(rows, groupBy);
|
|
6586
|
-
}, [rows, groupByList]);
|
|
6587
|
-
const isAllGroupChecked = (0, import_react23.useMemo)(() => {
|
|
6588
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6589
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6590
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6591
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6592
|
-
return allGroupsSelected || allRecordsSelected;
|
|
6593
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6594
|
-
const isAllNormalChecked = (0, import_react23.useMemo)(() => {
|
|
6595
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6596
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6597
|
-
(id) => rows.some((record) => record.id === id)
|
|
6598
|
-
);
|
|
6599
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6600
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6598
|
+
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6599
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6600
|
+
const { groupByDomain } = (0, import_store8.useAppSelector)(import_store8.selectSearch);
|
|
6601
6601
|
const handleCheckBoxAll = (event) => {
|
|
6602
6602
|
if (event?.target?.checked && typeTable === "list") {
|
|
6603
6603
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6604
|
-
appDispatch((0,
|
|
6604
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(allRowKeys));
|
|
6605
6605
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6606
6606
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6607
6607
|
const ids = Array.from(rowsIDs)?.map(
|
|
6608
6608
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6609
6609
|
);
|
|
6610
6610
|
if (ids?.length > 0) {
|
|
6611
|
-
appDispatch((0,
|
|
6611
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(ids));
|
|
6612
6612
|
} else {
|
|
6613
6613
|
const sum = countSum(
|
|
6614
6614
|
rows,
|
|
6615
|
-
typeof
|
|
6615
|
+
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6616
6616
|
);
|
|
6617
6617
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6618
|
-
appDispatch((0,
|
|
6618
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(keys));
|
|
6619
6619
|
}
|
|
6620
6620
|
if (selectedRowKeysRef) {
|
|
6621
6621
|
selectedRowKeysRef.current = [];
|
|
6622
6622
|
}
|
|
6623
6623
|
} else {
|
|
6624
|
-
appDispatch((0,
|
|
6624
|
+
appDispatch((0, import_store8.setSelectedRowKeys)([]));
|
|
6625
6625
|
}
|
|
6626
6626
|
};
|
|
6627
6627
|
return {
|
|
6628
|
-
handleCheckBoxAll
|
|
6629
|
-
checkedAll,
|
|
6630
|
-
selectedRowKeysRef
|
|
6628
|
+
handleCheckBoxAll
|
|
6631
6629
|
};
|
|
6632
6630
|
};
|
|
6633
6631
|
|
|
6634
6632
|
// src/widget/advance/table/table-view/controller.ts
|
|
6635
|
-
var
|
|
6633
|
+
var import_react22 = require("react");
|
|
6634
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6636
6635
|
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6637
6636
|
var tableController = ({ data }) => {
|
|
6638
|
-
const [rows, setRows] = (0,
|
|
6639
|
-
const [columns, setColumns] = (0,
|
|
6640
|
-
const dataModelFields = data
|
|
6637
|
+
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
6638
|
+
const [columns, setColumns] = (0, import_react22.useState)([]);
|
|
6639
|
+
const dataModelFields = data.fields?.map((field) => {
|
|
6641
6640
|
return {
|
|
6642
6641
|
...data.dataModel?.[field?.name],
|
|
6643
6642
|
...field,
|
|
@@ -6664,8 +6663,8 @@ var tableController = ({ data }) => {
|
|
|
6664
6663
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6665
6664
|
});
|
|
6666
6665
|
};
|
|
6667
|
-
(0,
|
|
6668
|
-
setRows(transformData(data.records));
|
|
6666
|
+
(0, import_react22.useEffect)(() => {
|
|
6667
|
+
setRows(transformData(data.records || null));
|
|
6669
6668
|
}, [data.records]);
|
|
6670
6669
|
const handleGetColumns = () => {
|
|
6671
6670
|
let cols = [];
|
|
@@ -6685,11 +6684,10 @@ var tableController = ({ data }) => {
|
|
|
6685
6684
|
}
|
|
6686
6685
|
return cols;
|
|
6687
6686
|
};
|
|
6688
|
-
(0,
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
}, [data]);
|
|
6687
|
+
(0, import_react22.useEffect)(() => {
|
|
6688
|
+
const columns2 = handleGetColumns();
|
|
6689
|
+
setColumns(columns2);
|
|
6690
|
+
}, [data.records]);
|
|
6693
6691
|
const onToggleColumnOptional = (item) => {
|
|
6694
6692
|
const tempColumn = [...columns]?.map((val) => {
|
|
6695
6693
|
if (item?.name === val?.name) {
|
|
@@ -6702,14 +6700,6 @@ var tableController = ({ data }) => {
|
|
|
6702
6700
|
});
|
|
6703
6701
|
setColumns(tempColumn);
|
|
6704
6702
|
};
|
|
6705
|
-
(0, import_react24.useEffect)(() => {
|
|
6706
|
-
setRows(null);
|
|
6707
|
-
setColumns(null);
|
|
6708
|
-
return () => {
|
|
6709
|
-
setRows(null);
|
|
6710
|
-
setColumns(null);
|
|
6711
|
-
};
|
|
6712
|
-
}, [data?.fields]);
|
|
6713
6703
|
return {
|
|
6714
6704
|
rows,
|
|
6715
6705
|
columns,
|
|
@@ -6719,32 +6709,47 @@ var tableController = ({ data }) => {
|
|
|
6719
6709
|
};
|
|
6720
6710
|
|
|
6721
6711
|
// src/widget/advance/table/table-group/controller.ts
|
|
6722
|
-
var
|
|
6723
|
-
var
|
|
6712
|
+
var import_react23 = require("react");
|
|
6713
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
6714
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6715
|
+
|
|
6716
|
+
// src/environment.ts
|
|
6717
|
+
var environment_exports = {};
|
|
6718
|
+
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
6719
|
+
|
|
6720
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
6724
6721
|
var tableGroupController = (props) => {
|
|
6725
|
-
const
|
|
6726
|
-
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6722
|
+
const env = (0, environment_exports.getEnv)();
|
|
6727
6723
|
const {
|
|
6724
|
+
rows,
|
|
6728
6725
|
columns,
|
|
6726
|
+
indexRow,
|
|
6729
6727
|
row,
|
|
6730
6728
|
model,
|
|
6731
6729
|
viewData,
|
|
6730
|
+
renderField,
|
|
6732
6731
|
level,
|
|
6733
6732
|
specification,
|
|
6733
|
+
domain,
|
|
6734
6734
|
context,
|
|
6735
6735
|
checkedAll,
|
|
6736
|
-
|
|
6737
|
-
|
|
6736
|
+
isDisplayCheckbox,
|
|
6737
|
+
isAutoSelect,
|
|
6738
|
+
setIsAutoSelect,
|
|
6739
|
+
selectedRowKeysRef
|
|
6738
6740
|
} = props;
|
|
6739
|
-
const [pageGroup, setPageGroup] = (0,
|
|
6740
|
-
const {
|
|
6741
|
-
const
|
|
6742
|
-
const
|
|
6741
|
+
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
6742
|
+
const { groupByDomain, selectedTags } = (0, import_store10.useAppSelector)(import_store10.selectSearch);
|
|
6743
|
+
const { selectedRowKeys } = (0, import_store10.useAppSelector)(import_store10.selectList);
|
|
6744
|
+
const appDispatch = (0, import_store10.useAppDispatch)();
|
|
6745
|
+
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
6746
|
+
const initVal = toDataJS(row, viewData, model);
|
|
6747
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
6748
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
6743
6749
|
fromStart: 1,
|
|
6744
6750
|
fromEnd: 1
|
|
6745
6751
|
});
|
|
6746
|
-
const
|
|
6747
|
-
const processedData = (0, import_react25.useMemo)(() => {
|
|
6752
|
+
const processedData = (0, import_react23.useMemo)(() => {
|
|
6748
6753
|
const calculateColSpanEmpty = () => {
|
|
6749
6754
|
const startIndex = columns.findIndex(
|
|
6750
6755
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6759,7 +6764,7 @@ var tableGroupController = (props) => {
|
|
|
6759
6764
|
};
|
|
6760
6765
|
return calculateColSpanEmpty();
|
|
6761
6766
|
}, [columns, row]);
|
|
6762
|
-
const shouldFetchData = (0,
|
|
6767
|
+
const shouldFetchData = (0, import_react23.useMemo)(() => {
|
|
6763
6768
|
return !!isShowGroup;
|
|
6764
6769
|
}, [isShowGroup]);
|
|
6765
6770
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6769,22 +6774,22 @@ var tableGroupController = (props) => {
|
|
|
6769
6774
|
domain,
|
|
6770
6775
|
context,
|
|
6771
6776
|
offset: pageGroup * 10,
|
|
6772
|
-
fields:
|
|
6773
|
-
groupby: [
|
|
6777
|
+
fields: groupByDomain?.fields,
|
|
6778
|
+
groupby: [groupByDomain?.contexts[level]?.group_by]
|
|
6774
6779
|
};
|
|
6775
6780
|
const queryKey = [
|
|
6776
|
-
`data-${model}
|
|
6781
|
+
`data-${model}--${level}-row${indexRow}`,
|
|
6777
6782
|
specification,
|
|
6778
6783
|
domain,
|
|
6779
6784
|
pageGroup
|
|
6780
6785
|
];
|
|
6781
6786
|
const {
|
|
6782
|
-
data:
|
|
6783
|
-
isFetched:
|
|
6787
|
+
data: dataResponse,
|
|
6788
|
+
isFetched: isQueryFetched,
|
|
6789
|
+
isPlaceholderData,
|
|
6784
6790
|
isLoading,
|
|
6785
|
-
isFetching
|
|
6786
|
-
|
|
6787
|
-
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
6791
|
+
isFetching
|
|
6792
|
+
} = (0, import_hooks15.useGetListData)(listDataProps, queryKey, enabled);
|
|
6788
6793
|
const {
|
|
6789
6794
|
columns: columnsGroup,
|
|
6790
6795
|
rows: rowsGroup,
|
|
@@ -6792,21 +6797,27 @@ var tableGroupController = (props) => {
|
|
|
6792
6797
|
} = tableController({
|
|
6793
6798
|
data: {
|
|
6794
6799
|
fields: viewData?.views?.list?.fields,
|
|
6795
|
-
records:
|
|
6800
|
+
records: dataResponse?.records ?? dataResponse?.groups,
|
|
6796
6801
|
dataModel: viewData?.models?.[model],
|
|
6797
6802
|
context: env.context,
|
|
6798
|
-
typeTable:
|
|
6803
|
+
typeTable: dataResponse?.groups ? "group" : "list"
|
|
6799
6804
|
}
|
|
6800
6805
|
});
|
|
6801
|
-
const
|
|
6806
|
+
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6807
|
+
(0, import_react23.useEffect)(() => {
|
|
6808
|
+
if (isShowGroup && selectedTags?.length > 0) {
|
|
6809
|
+
setIsShowGroup(false);
|
|
6810
|
+
}
|
|
6811
|
+
}, [selectedTags]);
|
|
6812
|
+
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
6802
6813
|
const nameGroup = Array.isArray(row[group_by_field_name]) ? row?.string ?? row[`${group_by_field_name}`][1] : viewData?.models?.[model]?.[group_by_field_name]?.selection ? viewData.models[model][group_by_field_name].selection.find(
|
|
6803
6814
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6804
6815
|
)?.[1] : row[group_by_field_name];
|
|
6805
6816
|
const nameGroupWithCount = `${typeof nameGroup === "string" ? nameGroup : typeof nameGroup === "boolean" && nameGroup ? i18n_default.t("yes") : i18n_default.t("no")} (${row[`${group_by_field_name?.split(":")?.[0]}_count`]})`;
|
|
6806
6817
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6807
|
-
const
|
|
6808
|
-
const onExpandChildGroup = () => {
|
|
6818
|
+
const handleExpandChildGroup = () => {
|
|
6809
6819
|
if (isLoading || isFetching) return;
|
|
6820
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6810
6821
|
if (allIdsNull || typeTableGroup === "group") {
|
|
6811
6822
|
toggleShowGroup();
|
|
6812
6823
|
return;
|
|
@@ -6816,39 +6827,53 @@ var tableGroupController = (props) => {
|
|
|
6816
6827
|
const filteredIds = selectedRowKeys.filter(
|
|
6817
6828
|
(id) => !ids.includes(id)
|
|
6818
6829
|
);
|
|
6819
|
-
|
|
6820
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
6830
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredIds));
|
|
6831
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6821
6832
|
const clonedKeys = [...selectedRowKeys];
|
|
6822
|
-
|
|
6823
|
-
setTimeout(() =>
|
|
6833
|
+
appDispatch((0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
6834
|
+
setTimeout(() => appDispatch((0, import_store10.setSelectedRowKeys)(clonedKeys)), 500);
|
|
6824
6835
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6825
|
-
console.log("abc");
|
|
6826
6836
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6827
|
-
|
|
6837
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredKeys));
|
|
6828
6838
|
}
|
|
6829
6839
|
toggleShowGroup();
|
|
6830
6840
|
};
|
|
6831
|
-
(0,
|
|
6832
|
-
if (!
|
|
6841
|
+
(0, import_react23.useEffect)(() => {
|
|
6842
|
+
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6833
6843
|
return;
|
|
6834
6844
|
}
|
|
6835
6845
|
const clonedKeys = [...selectedRowKeys];
|
|
6836
|
-
|
|
6837
|
-
setTimeout(() =>
|
|
6838
|
-
}, [
|
|
6846
|
+
(0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
6847
|
+
setTimeout(() => (0, import_store10.setSelectedRowKeys)(clonedKeys), 500);
|
|
6848
|
+
}, [isQueryFetched]);
|
|
6839
6849
|
return {
|
|
6840
|
-
|
|
6850
|
+
handleExpandChildGroup,
|
|
6841
6851
|
colEmptyGroup,
|
|
6852
|
+
leftPadding,
|
|
6842
6853
|
isShowGroup,
|
|
6843
|
-
|
|
6844
|
-
isDataPlaceHolder,
|
|
6854
|
+
isQueryFetched,
|
|
6845
6855
|
nameGroupWithCount,
|
|
6856
|
+
columns,
|
|
6857
|
+
row,
|
|
6858
|
+
isPlaceholderData,
|
|
6846
6859
|
columnsGroup,
|
|
6860
|
+
indexRow,
|
|
6847
6861
|
rowsGroup,
|
|
6848
|
-
|
|
6862
|
+
model,
|
|
6863
|
+
viewData,
|
|
6864
|
+
renderField,
|
|
6865
|
+
level,
|
|
6866
|
+
specification,
|
|
6867
|
+
context,
|
|
6868
|
+
checkedAll,
|
|
6869
|
+
isDisplayCheckbox,
|
|
6870
|
+
isAutoSelect,
|
|
6871
|
+
setIsAutoSelect,
|
|
6872
|
+
selectedRowKeysRef,
|
|
6873
|
+
initVal,
|
|
6874
|
+
dataResponse,
|
|
6849
6875
|
pageGroup,
|
|
6850
|
-
setPageGroup
|
|
6851
|
-
typeTableGroup
|
|
6876
|
+
setPageGroup
|
|
6852
6877
|
};
|
|
6853
6878
|
};
|
|
6854
6879
|
|
|
@@ -6856,7 +6881,7 @@ var tableGroupController = (props) => {
|
|
|
6856
6881
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
6857
6882
|
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6858
6883
|
var import_moment2 = __toESM(require_moment());
|
|
6859
|
-
var
|
|
6884
|
+
var import_react24 = require("react");
|
|
6860
6885
|
var searchController = ({
|
|
6861
6886
|
viewData,
|
|
6862
6887
|
model,
|
|
@@ -6865,12 +6890,12 @@ var searchController = ({
|
|
|
6865
6890
|
fieldsList
|
|
6866
6891
|
}) => {
|
|
6867
6892
|
const { env } = (0, provider_exports.useEnv)();
|
|
6868
|
-
const [filterBy, setFilterBy] = (0,
|
|
6869
|
-
const [searchBy, setSearchBy] = (0,
|
|
6870
|
-
const [groupBy, setGroupBy] = (0,
|
|
6871
|
-
const [selectedTags, setSelectedTags] = (0,
|
|
6872
|
-
const [searchString, setSearchString] = (0,
|
|
6873
|
-
const [searchMap, setSearchMap] = (0,
|
|
6893
|
+
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
6894
|
+
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
6895
|
+
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
6896
|
+
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
6897
|
+
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
6898
|
+
const [searchMap, setSearchMap] = (0, import_react24.useState)({});
|
|
6874
6899
|
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
6875
6900
|
const contextSearch = { ...env.context, ...actionContext };
|
|
6876
6901
|
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
@@ -6917,7 +6942,7 @@ var searchController = ({
|
|
|
6917
6942
|
}
|
|
6918
6943
|
}
|
|
6919
6944
|
};
|
|
6920
|
-
(0,
|
|
6945
|
+
(0, import_react24.useEffect)(() => {
|
|
6921
6946
|
fetchData();
|
|
6922
6947
|
}, [model, viewData]);
|
|
6923
6948
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -6999,7 +7024,7 @@ var searchController = ({
|
|
|
6999
7024
|
return [...domain2];
|
|
7000
7025
|
}
|
|
7001
7026
|
};
|
|
7002
|
-
const setTagSearch = (0,
|
|
7027
|
+
const setTagSearch = (0, import_react24.useCallback)(
|
|
7003
7028
|
(updatedMap) => {
|
|
7004
7029
|
if (!updatedMap) return;
|
|
7005
7030
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7062,7 +7087,7 @@ var searchController = ({
|
|
|
7062
7087
|
},
|
|
7063
7088
|
[searchMap]
|
|
7064
7089
|
);
|
|
7065
|
-
(0,
|
|
7090
|
+
(0, import_react24.useEffect)(() => {
|
|
7066
7091
|
setTagSearch(searchMap);
|
|
7067
7092
|
}, [searchMap]);
|
|
7068
7093
|
const handleAddTagSearch = (tag) => {
|