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