@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/index.js
CHANGED
|
@@ -4083,7 +4083,6 @@ __export(index_exports, {
|
|
|
4083
4083
|
useMenu: () => useMenu,
|
|
4084
4084
|
useMenuItem: () => useMenuItem,
|
|
4085
4085
|
useProfile: () => useProfile,
|
|
4086
|
-
useSelectionState: () => useSelectionState,
|
|
4087
4086
|
useStorageState: () => useStorageState,
|
|
4088
4087
|
useUser: () => useUser,
|
|
4089
4088
|
useViewV2: () => useViewV2
|
|
@@ -4101,6 +4100,7 @@ __export(hooks_exports, {
|
|
|
4101
4100
|
useConfig: () => useConfig,
|
|
4102
4101
|
useDebounce: () => useDebounce,
|
|
4103
4102
|
useDetail: () => useDetail,
|
|
4103
|
+
useGetRowIds: () => useGetRowIds,
|
|
4104
4104
|
useListData: () => useListData,
|
|
4105
4105
|
useMenu: () => useMenu,
|
|
4106
4106
|
useMenuItem: () => useMenuItem,
|
|
@@ -4228,12 +4228,6 @@ var import_react5 = require("react");
|
|
|
4228
4228
|
|
|
4229
4229
|
// src/utils/function.ts
|
|
4230
4230
|
var import_react4 = require("react");
|
|
4231
|
-
|
|
4232
|
-
// src/store.ts
|
|
4233
|
-
var store_exports = {};
|
|
4234
|
-
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4235
|
-
|
|
4236
|
-
// src/utils/function.ts
|
|
4237
4231
|
var countSum = (data, field) => {
|
|
4238
4232
|
if (!data || !field) return 0;
|
|
4239
4233
|
return data.reduce(
|
|
@@ -4252,91 +4246,6 @@ function mergeButtons(fields) {
|
|
|
4252
4246
|
}
|
|
4253
4247
|
return others;
|
|
4254
4248
|
}
|
|
4255
|
-
function isElementVisible(el) {
|
|
4256
|
-
const style = window.getComputedStyle(el);
|
|
4257
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4258
|
-
}
|
|
4259
|
-
function arraysAreEqual(a, b) {
|
|
4260
|
-
if (a.length !== b.length) return false;
|
|
4261
|
-
const setA = new Set(a);
|
|
4262
|
-
const setB = new Set(b);
|
|
4263
|
-
if (setA.size !== setB.size) return false;
|
|
4264
|
-
for (const val of setA) {
|
|
4265
|
-
if (!setB.has(val)) return false;
|
|
4266
|
-
}
|
|
4267
|
-
return true;
|
|
4268
|
-
}
|
|
4269
|
-
function useGetRowIds(tableRef) {
|
|
4270
|
-
const [rowIds, setRowIds] = (0, import_react4.useState)([]);
|
|
4271
|
-
const lastRowIdsRef = (0, import_react4.useRef)([]);
|
|
4272
|
-
const updateVisibleRowIds = (0, import_react4.useCallback)(() => {
|
|
4273
|
-
const table = tableRef?.current;
|
|
4274
|
-
if (!table) return;
|
|
4275
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4276
|
-
const ids = [];
|
|
4277
|
-
rows.forEach((row) => {
|
|
4278
|
-
const el = row;
|
|
4279
|
-
if (isElementVisible(el)) {
|
|
4280
|
-
const id = el.getAttribute("data-row-id");
|
|
4281
|
-
if (id) ids.push(id);
|
|
4282
|
-
}
|
|
4283
|
-
});
|
|
4284
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4285
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4286
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4287
|
-
setRowIds(uniqueIds);
|
|
4288
|
-
}
|
|
4289
|
-
}, [tableRef]);
|
|
4290
|
-
(0, import_react4.useEffect)(() => {
|
|
4291
|
-
const table = tableRef?.current;
|
|
4292
|
-
if (!table) return;
|
|
4293
|
-
const observer = new MutationObserver(() => {
|
|
4294
|
-
updateVisibleRowIds();
|
|
4295
|
-
});
|
|
4296
|
-
observer.observe(table, {
|
|
4297
|
-
childList: true,
|
|
4298
|
-
subtree: true,
|
|
4299
|
-
attributes: true,
|
|
4300
|
-
attributeFilter: ["style", "class"]
|
|
4301
|
-
});
|
|
4302
|
-
updateVisibleRowIds();
|
|
4303
|
-
return () => {
|
|
4304
|
-
observer.disconnect();
|
|
4305
|
-
};
|
|
4306
|
-
}, [updateVisibleRowIds, tableRef]);
|
|
4307
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4308
|
-
}
|
|
4309
|
-
var useSelectionState = ({
|
|
4310
|
-
typeTable,
|
|
4311
|
-
tableRef,
|
|
4312
|
-
rows
|
|
4313
|
-
}) => {
|
|
4314
|
-
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
4315
|
-
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
4316
|
-
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
4317
|
-
const selectedRowKeysRef = (0, import_react4.useRef)(recordIds);
|
|
4318
|
-
const isGroupTable = typeTable === "group";
|
|
4319
|
-
const recordsCheckedGroup = (0, import_react4.useMemo)(() => {
|
|
4320
|
-
if (!rows || !groupByDomain) return 0;
|
|
4321
|
-
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
4322
|
-
return countSum(rows, groupBy);
|
|
4323
|
-
}, [rows, groupByDomain]);
|
|
4324
|
-
const isAllGroupChecked = (0, import_react4.useMemo)(() => {
|
|
4325
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
4326
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
4327
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
4328
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
4329
|
-
return allGroupsSelected || allRecordsSelected;
|
|
4330
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
4331
|
-
const isAllNormalChecked = (0, import_react4.useMemo)(() => {
|
|
4332
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
4333
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
4334
|
-
(id) => rows.some((record) => record.id === id)
|
|
4335
|
-
);
|
|
4336
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
4337
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
4338
|
-
return { checkedAll, selectedRowKeysRef };
|
|
4339
|
-
};
|
|
4340
4249
|
var getDateRange = (currentDate, unit) => {
|
|
4341
4250
|
const date = new Date(currentDate);
|
|
4342
4251
|
let dateStart, dateEnd;
|
|
@@ -4477,19 +4386,19 @@ function useStorageState(key) {
|
|
|
4477
4386
|
|
|
4478
4387
|
// src/hooks/core/use-list-data.ts
|
|
4479
4388
|
var import_hooks3 = require("@fctc/interface-logic/hooks");
|
|
4480
|
-
var
|
|
4389
|
+
var import_store3 = require("@fctc/interface-logic/store");
|
|
4481
4390
|
var import_utils = require("@fctc/interface-logic/utils");
|
|
4482
4391
|
var useListData = ({
|
|
4483
4392
|
action,
|
|
4484
4393
|
context,
|
|
4485
4394
|
viewResponse
|
|
4486
4395
|
}) => {
|
|
4487
|
-
const { groupByDomain } = (0,
|
|
4396
|
+
const { groupByDomain } = (0, import_store3.useAppSelector)(import_store3.selectSearch);
|
|
4488
4397
|
const initModel = (0, import_hooks3.useModel)();
|
|
4489
4398
|
const [type, setType] = (0, import_react5.useState)("list");
|
|
4490
4399
|
const [mode, setMode] = (0, import_react5.useState)("month");
|
|
4491
4400
|
const [currentDate, setCurrentDate] = (0, import_react5.useState)(/* @__PURE__ */ new Date());
|
|
4492
|
-
const { pageLimit, page, order } = (0,
|
|
4401
|
+
const { pageLimit, page, order } = (0, import_store3.useAppSelector)(import_store3.selectList);
|
|
4493
4402
|
const listDataProps = (0, import_react5.useMemo)(() => {
|
|
4494
4403
|
const actData = action?.result;
|
|
4495
4404
|
if (!viewResponse || !actData || !context) {
|
|
@@ -4624,10 +4533,10 @@ var import_react7 = require("react");
|
|
|
4624
4533
|
var import_react_i18next = require("react-i18next");
|
|
4625
4534
|
var import_environment3 = require("@fctc/interface-logic/environment");
|
|
4626
4535
|
var import_hooks5 = require("@fctc/interface-logic/hooks");
|
|
4627
|
-
var
|
|
4536
|
+
var import_store4 = require("@fctc/interface-logic/store");
|
|
4628
4537
|
var useProfile = (accessToken) => {
|
|
4629
4538
|
const getProfile = (0, import_hooks5.useGetProfile)();
|
|
4630
|
-
const dispatch = (0,
|
|
4539
|
+
const dispatch = (0, import_store4.useAppDispatch)();
|
|
4631
4540
|
const { i18n: i18n2 } = (0, import_react_i18next.useTranslation)();
|
|
4632
4541
|
const fetchUserProfile = async () => {
|
|
4633
4542
|
return await getProfile.mutateAsync();
|
|
@@ -4642,7 +4551,7 @@ var useProfile = (accessToken) => {
|
|
|
4642
4551
|
const userInfo = userInfoQuery.data;
|
|
4643
4552
|
const env = (0, import_environment3.getEnv)();
|
|
4644
4553
|
env.setUid(userInfo?.sub);
|
|
4645
|
-
dispatch((0,
|
|
4554
|
+
dispatch((0, import_store4.setDataUser)(userInfo));
|
|
4646
4555
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
4647
4556
|
env.setLang(userLocale?.id);
|
|
4648
4557
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
@@ -4707,11 +4616,11 @@ var useViewV2 = ({
|
|
|
4707
4616
|
|
|
4708
4617
|
// src/hooks/core/use-auth.ts
|
|
4709
4618
|
var import_hooks7 = require("@fctc/interface-logic/hooks");
|
|
4710
|
-
var
|
|
4619
|
+
var import_store5 = require("@fctc/interface-logic/store");
|
|
4711
4620
|
var useAuth = () => {
|
|
4712
4621
|
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
4713
4622
|
const loginMutate = (0, import_hooks7.useLoginCredential)();
|
|
4714
|
-
const dispatch = (0,
|
|
4623
|
+
const dispatch = (0, import_store5.useAppDispatch)();
|
|
4715
4624
|
const signIn = async (email, password) => {
|
|
4716
4625
|
try {
|
|
4717
4626
|
loginMutate.mutate(
|
|
@@ -4732,9 +4641,9 @@ var useAuth = () => {
|
|
|
4732
4641
|
}
|
|
4733
4642
|
};
|
|
4734
4643
|
const signOut = async () => {
|
|
4735
|
-
dispatch((0,
|
|
4736
|
-
dispatch((0,
|
|
4737
|
-
dispatch((0,
|
|
4644
|
+
dispatch((0, import_store5.setMenuList)([]));
|
|
4645
|
+
dispatch((0, import_store5.setDataUser)({}));
|
|
4646
|
+
dispatch((0, import_store5.setProfile)({}));
|
|
4738
4647
|
setAccessToken(null);
|
|
4739
4648
|
};
|
|
4740
4649
|
return {
|
|
@@ -4881,8 +4790,6 @@ __export(utils_exports, {
|
|
|
4881
4790
|
languages: () => languages,
|
|
4882
4791
|
mergeButtons: () => mergeButtons,
|
|
4883
4792
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4884
|
-
useGetRowIds: () => useGetRowIds,
|
|
4885
|
-
useSelectionState: () => useSelectionState,
|
|
4886
4793
|
useStorageState: () => useStorageState
|
|
4887
4794
|
});
|
|
4888
4795
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
@@ -4924,8 +4831,74 @@ var useMenuItem = (props) => {
|
|
|
4924
4831
|
return { handleClick, path, queryActionDetail };
|
|
4925
4832
|
};
|
|
4926
4833
|
|
|
4927
|
-
// src/hooks/
|
|
4834
|
+
// src/hooks/core/use-get-rowids.ts
|
|
4928
4835
|
var import_react12 = require("react");
|
|
4836
|
+
var useGetRowIds = (tableRef) => {
|
|
4837
|
+
function isElementVisible(el) {
|
|
4838
|
+
const style = window.getComputedStyle(el);
|
|
4839
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4840
|
+
}
|
|
4841
|
+
function arraysAreEqual(a, b) {
|
|
4842
|
+
if (a.length !== b.length) return false;
|
|
4843
|
+
if (a.length === 0 && b.length === 0) return true;
|
|
4844
|
+
const setA = new Set(a);
|
|
4845
|
+
const setB = new Set(b);
|
|
4846
|
+
if (setA.size !== setB.size) return false;
|
|
4847
|
+
for (const val of setA) {
|
|
4848
|
+
if (!setB.has(val)) return false;
|
|
4849
|
+
}
|
|
4850
|
+
return true;
|
|
4851
|
+
}
|
|
4852
|
+
const [rowIds, setRowIds] = (0, import_react12.useState)([]);
|
|
4853
|
+
const lastRowIdsRef = (0, import_react12.useRef)([]);
|
|
4854
|
+
const updateVisibleRowIds = (0, import_react12.useCallback)(() => {
|
|
4855
|
+
const table = tableRef.current;
|
|
4856
|
+
if (!table) return;
|
|
4857
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4858
|
+
const ids = [];
|
|
4859
|
+
rows.forEach((row) => {
|
|
4860
|
+
const el = row;
|
|
4861
|
+
if (isElementVisible(el)) {
|
|
4862
|
+
const id = el.getAttribute("data-row-id");
|
|
4863
|
+
if (id) ids.push(id);
|
|
4864
|
+
}
|
|
4865
|
+
});
|
|
4866
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4867
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4868
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4869
|
+
setRowIds(uniqueIds);
|
|
4870
|
+
}
|
|
4871
|
+
}, [tableRef]);
|
|
4872
|
+
(0, import_react12.useEffect)(() => {
|
|
4873
|
+
const table = tableRef.current;
|
|
4874
|
+
if (!table) return;
|
|
4875
|
+
const mutationObserver = new MutationObserver(() => {
|
|
4876
|
+
updateVisibleRowIds();
|
|
4877
|
+
});
|
|
4878
|
+
mutationObserver.observe(table, {
|
|
4879
|
+
childList: true,
|
|
4880
|
+
subtree: true,
|
|
4881
|
+
attributes: true,
|
|
4882
|
+
attributeFilter: ["style", "class"]
|
|
4883
|
+
});
|
|
4884
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4885
|
+
updateVisibleRowIds();
|
|
4886
|
+
});
|
|
4887
|
+
resizeObserver.observe(table);
|
|
4888
|
+
const handleScroll = () => updateVisibleRowIds();
|
|
4889
|
+
table.addEventListener("scroll", handleScroll, true);
|
|
4890
|
+
updateVisibleRowIds();
|
|
4891
|
+
return () => {
|
|
4892
|
+
mutationObserver.disconnect();
|
|
4893
|
+
resizeObserver.disconnect();
|
|
4894
|
+
table.removeEventListener("scroll", handleScroll, true);
|
|
4895
|
+
};
|
|
4896
|
+
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4897
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4898
|
+
};
|
|
4899
|
+
|
|
4900
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4901
|
+
var import_react13 = require("react");
|
|
4929
4902
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4930
4903
|
var useClickOutside = ({
|
|
4931
4904
|
handler,
|
|
@@ -4933,8 +4906,8 @@ var useClickOutside = ({
|
|
|
4933
4906
|
nodes = [],
|
|
4934
4907
|
refs
|
|
4935
4908
|
}) => {
|
|
4936
|
-
const ref = (0,
|
|
4937
|
-
(0,
|
|
4909
|
+
const ref = (0, import_react13.useRef)(null);
|
|
4910
|
+
(0, import_react13.useEffect)(() => {
|
|
4938
4911
|
const listener = (event) => {
|
|
4939
4912
|
const { target } = event;
|
|
4940
4913
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4956,10 +4929,10 @@ var useClickOutside = ({
|
|
|
4956
4929
|
};
|
|
4957
4930
|
|
|
4958
4931
|
// src/hooks/utils/use-debounce.ts
|
|
4959
|
-
var
|
|
4932
|
+
var import_react14 = require("react");
|
|
4960
4933
|
function useDebounce(value, delay) {
|
|
4961
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4962
|
-
(0,
|
|
4934
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
4935
|
+
(0, import_react14.useEffect)(() => {
|
|
4963
4936
|
const handler = setTimeout(() => {
|
|
4964
4937
|
setDebouncedValue(value);
|
|
4965
4938
|
}, delay);
|
|
@@ -5214,7 +5187,7 @@ var ChevronBottomIcon = ({
|
|
|
5214
5187
|
};
|
|
5215
5188
|
|
|
5216
5189
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
5217
|
-
var
|
|
5190
|
+
var import_react15 = require("react");
|
|
5218
5191
|
var import_environment6 = require("@fctc/interface-logic/environment");
|
|
5219
5192
|
var import_hooks11 = require("@fctc/interface-logic/hooks");
|
|
5220
5193
|
var statusDropdownController = (props) => {
|
|
@@ -5225,9 +5198,9 @@ var statusDropdownController = (props) => {
|
|
|
5225
5198
|
done: "bg-primary",
|
|
5226
5199
|
blocked: "bg-red-500"
|
|
5227
5200
|
};
|
|
5228
|
-
const [isOpen, setIsOpen] = (0,
|
|
5229
|
-
const buttonRef = (0,
|
|
5230
|
-
(0,
|
|
5201
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
|
|
5202
|
+
const buttonRef = (0, import_react15.useRef)(null);
|
|
5203
|
+
(0, import_react15.useEffect)(() => {
|
|
5231
5204
|
const handleClickOutside = (event) => {
|
|
5232
5205
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
5233
5206
|
setIsOpen(false);
|
|
@@ -5268,7 +5241,11 @@ var statusDropdownController = (props) => {
|
|
|
5268
5241
|
};
|
|
5269
5242
|
|
|
5270
5243
|
// src/widget/basic/many2one-field/controller.ts
|
|
5271
|
-
var
|
|
5244
|
+
var import_react16 = require("react");
|
|
5245
|
+
|
|
5246
|
+
// src/store.ts
|
|
5247
|
+
var store_exports = {};
|
|
5248
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
5272
5249
|
|
|
5273
5250
|
// src/provider.ts
|
|
5274
5251
|
var provider_exports = {};
|
|
@@ -5290,13 +5267,13 @@ var many2oneFieldController = (props) => {
|
|
|
5290
5267
|
showDetail
|
|
5291
5268
|
} = props;
|
|
5292
5269
|
const { env } = (0, provider_exports.useEnv)();
|
|
5293
|
-
const [options, setOptions] = (0,
|
|
5294
|
-
const [inputValue, setInputValue] = (0,
|
|
5270
|
+
const [options, setOptions] = (0, import_react16.useState)([]);
|
|
5271
|
+
const [inputValue, setInputValue] = (0, import_react16.useState)("");
|
|
5295
5272
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
5296
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
5297
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
5298
|
-
const [domainModal, setDomainModal] = (0,
|
|
5299
|
-
const [domainObject, setDomainObject] = (0,
|
|
5273
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react16.useState)(false);
|
|
5274
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react16.useState)(null);
|
|
5275
|
+
const [domainModal, setDomainModal] = (0, import_react16.useState)(null);
|
|
5276
|
+
const [domainObject, setDomainObject] = (0, import_react16.useState)(null);
|
|
5300
5277
|
const actionData = sessionStorageUtils.getActionData();
|
|
5301
5278
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5302
5279
|
const initValue = methods?.getValues(name);
|
|
@@ -5327,18 +5304,18 @@ var many2oneFieldController = (props) => {
|
|
|
5327
5304
|
queryKey,
|
|
5328
5305
|
enabled: false
|
|
5329
5306
|
});
|
|
5330
|
-
const selectOptions = (0,
|
|
5307
|
+
const selectOptions = (0, import_react16.useMemo)(() => {
|
|
5331
5308
|
return dataOfSelection?.records?.map((val) => ({
|
|
5332
5309
|
value: val?.id,
|
|
5333
5310
|
label: val?.display_name || val?.name
|
|
5334
5311
|
})) || [];
|
|
5335
5312
|
}, [dataOfSelection]);
|
|
5336
|
-
(0,
|
|
5313
|
+
(0, import_react16.useEffect)(() => {
|
|
5337
5314
|
setOptions(selectOptions);
|
|
5338
5315
|
setDomainModal(domainObject);
|
|
5339
5316
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5340
5317
|
}, [selectOptions]);
|
|
5341
|
-
(0,
|
|
5318
|
+
(0, import_react16.useEffect)(() => {
|
|
5342
5319
|
setDomainObject(
|
|
5343
5320
|
(0, utils_exports.evalJSONDomain)(
|
|
5344
5321
|
domain,
|
|
@@ -5346,7 +5323,7 @@ var many2oneFieldController = (props) => {
|
|
|
5346
5323
|
)
|
|
5347
5324
|
);
|
|
5348
5325
|
}, [domain, formValues]);
|
|
5349
|
-
(0,
|
|
5326
|
+
(0, import_react16.useEffect)(() => {
|
|
5350
5327
|
if (!propValue && tempSelectedOption) {
|
|
5351
5328
|
methods.setValue(name, null);
|
|
5352
5329
|
setTempSelectedOption(null);
|
|
@@ -5357,10 +5334,10 @@ var many2oneFieldController = (props) => {
|
|
|
5357
5334
|
});
|
|
5358
5335
|
}
|
|
5359
5336
|
}, [propValue]);
|
|
5360
|
-
const fetchMoreOptions = (0,
|
|
5337
|
+
const fetchMoreOptions = (0, import_react16.useCallback)(() => {
|
|
5361
5338
|
refetch();
|
|
5362
5339
|
}, [refetch]);
|
|
5363
|
-
(0,
|
|
5340
|
+
(0, import_react16.useEffect)(() => {
|
|
5364
5341
|
if (debouncedInputValue) {
|
|
5365
5342
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5366
5343
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5375,7 +5352,7 @@ var many2oneFieldController = (props) => {
|
|
|
5375
5352
|
}, 50);
|
|
5376
5353
|
}
|
|
5377
5354
|
}, [debouncedInputValue]);
|
|
5378
|
-
const handleChooseRecord = (0,
|
|
5355
|
+
const handleChooseRecord = (0, import_react16.useCallback)(
|
|
5379
5356
|
(idRecord) => {
|
|
5380
5357
|
const newOption = options.find(
|
|
5381
5358
|
(option) => option.value === idRecord
|
|
@@ -5400,8 +5377,8 @@ var many2oneFieldController = (props) => {
|
|
|
5400
5377
|
},
|
|
5401
5378
|
[options, methods, name, onChange]
|
|
5402
5379
|
);
|
|
5403
|
-
const handleClose = (0,
|
|
5404
|
-
const handleSelectChange = (0,
|
|
5380
|
+
const handleClose = (0, import_react16.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5381
|
+
const handleSelectChange = (0, import_react16.useCallback)(
|
|
5405
5382
|
(selectedOption) => {
|
|
5406
5383
|
if (!selectedOption) {
|
|
5407
5384
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5475,7 +5452,7 @@ var many2oneButtonController = (props) => {
|
|
|
5475
5452
|
};
|
|
5476
5453
|
|
|
5477
5454
|
// src/widget/basic/many2many-field/controller.ts
|
|
5478
|
-
var
|
|
5455
|
+
var import_react17 = require("react");
|
|
5479
5456
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5480
5457
|
var many2manyFieldController = (props) => {
|
|
5481
5458
|
const {
|
|
@@ -5490,10 +5467,10 @@ var many2manyFieldController = (props) => {
|
|
|
5490
5467
|
actionData
|
|
5491
5468
|
} = props;
|
|
5492
5469
|
const { env } = (0, provider_exports.useEnv)();
|
|
5493
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5494
|
-
const [order, setOrder] = (0,
|
|
5495
|
-
const [page, setPage] = (0,
|
|
5496
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
5470
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView } = (0, provider_exports.useService)();
|
|
5471
|
+
const [order, setOrder] = (0, import_react17.useState)();
|
|
5472
|
+
const [page, setPage] = (0, import_react17.useState)(0);
|
|
5473
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
5497
5474
|
const [debouncedPage] = useDebounce(page, 500);
|
|
5498
5475
|
const contextObject = {
|
|
5499
5476
|
...env.context,
|
|
@@ -5508,7 +5485,7 @@ var many2manyFieldController = (props) => {
|
|
|
5508
5485
|
context: contextObject
|
|
5509
5486
|
};
|
|
5510
5487
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5511
|
-
const baseModel = (0,
|
|
5488
|
+
const baseModel = (0, import_react17.useMemo)(
|
|
5512
5489
|
() => ({
|
|
5513
5490
|
name: String(relation),
|
|
5514
5491
|
view: viewResponse || {},
|
|
@@ -5521,13 +5498,13 @@ var many2manyFieldController = (props) => {
|
|
|
5521
5498
|
[relation, viewResponse]
|
|
5522
5499
|
);
|
|
5523
5500
|
const initModel = (0, hooks_exports.useModel)();
|
|
5524
|
-
const modelInstance = (0,
|
|
5501
|
+
const modelInstance = (0, import_react17.useMemo)(() => {
|
|
5525
5502
|
if (viewResponse) {
|
|
5526
5503
|
return initModel.initModel(baseModel);
|
|
5527
5504
|
}
|
|
5528
5505
|
return null;
|
|
5529
5506
|
}, [baseModel, viewResponse]);
|
|
5530
|
-
const specification = (0,
|
|
5507
|
+
const specification = (0, import_react17.useMemo)(() => {
|
|
5531
5508
|
if (modelInstance) {
|
|
5532
5509
|
return modelInstance.getSpecification();
|
|
5533
5510
|
}
|
|
@@ -5569,8 +5546,8 @@ var many2manyFieldController = (props) => {
|
|
|
5569
5546
|
isLoading,
|
|
5570
5547
|
isFetched,
|
|
5571
5548
|
isPlaceholderData
|
|
5572
|
-
} =
|
|
5573
|
-
(0,
|
|
5549
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5550
|
+
(0, import_react17.useEffect)(() => {
|
|
5574
5551
|
if (viewResponse) {
|
|
5575
5552
|
fetchData();
|
|
5576
5553
|
}
|
|
@@ -5623,7 +5600,7 @@ var many2manyFieldController = (props) => {
|
|
|
5623
5600
|
};
|
|
5624
5601
|
|
|
5625
5602
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5626
|
-
var
|
|
5603
|
+
var import_react18 = require("react");
|
|
5627
5604
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5628
5605
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5629
5606
|
var many2manyTagsController = (props) => {
|
|
@@ -5639,7 +5616,7 @@ var many2manyTagsController = (props) => {
|
|
|
5639
5616
|
const { env } = (0, provider_exports.useEnv)();
|
|
5640
5617
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5641
5618
|
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5642
|
-
const domainObject = (0,
|
|
5619
|
+
const domainObject = (0, import_react18.useMemo)(
|
|
5643
5620
|
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5644
5621
|
[domain, formValues]
|
|
5645
5622
|
);
|
|
@@ -5681,7 +5658,7 @@ var many2manyTagsController = (props) => {
|
|
|
5681
5658
|
};
|
|
5682
5659
|
|
|
5683
5660
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5684
|
-
var
|
|
5661
|
+
var import_react19 = require("react");
|
|
5685
5662
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5686
5663
|
var durationController = (props) => {
|
|
5687
5664
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
@@ -5690,10 +5667,10 @@ var durationController = (props) => {
|
|
|
5690
5667
|
name: "",
|
|
5691
5668
|
fold: ""
|
|
5692
5669
|
};
|
|
5693
|
-
const { useGetListData:
|
|
5670
|
+
const { useGetListData: useGetListData2, useChangeStatus } = (0, provider_exports.useService)();
|
|
5694
5671
|
const { env } = (0, provider_exports.useEnv)();
|
|
5695
|
-
const [disabled, setDisabled] = (0,
|
|
5696
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5672
|
+
const [disabled, setDisabled] = (0, import_react19.useState)(false);
|
|
5673
|
+
const [modelStatus, setModalStatus] = (0, import_react19.useState)(false);
|
|
5697
5674
|
const queryKey = [`data-status-duration`, specification];
|
|
5698
5675
|
const listDataProps = {
|
|
5699
5676
|
model: relation,
|
|
@@ -5708,7 +5685,7 @@ var durationController = (props) => {
|
|
|
5708
5685
|
},
|
|
5709
5686
|
sort: ""
|
|
5710
5687
|
};
|
|
5711
|
-
const { data: dataResponse } =
|
|
5688
|
+
const { data: dataResponse } = useGetListData2(
|
|
5712
5689
|
listDataProps,
|
|
5713
5690
|
queryKey,
|
|
5714
5691
|
enabled
|
|
@@ -5783,10 +5760,10 @@ var priorityFieldController = (props) => {
|
|
|
5783
5760
|
};
|
|
5784
5761
|
|
|
5785
5762
|
// src/widget/basic/download-file-field/controller.ts
|
|
5786
|
-
var
|
|
5763
|
+
var import_react20 = require("react");
|
|
5787
5764
|
var downloadFileController = () => {
|
|
5788
|
-
const inputId = (0,
|
|
5789
|
-
const [file, setFile] = (0,
|
|
5765
|
+
const inputId = (0, import_react20.useId)();
|
|
5766
|
+
const [file, setFile] = (0, import_react20.useState)(null);
|
|
5790
5767
|
const handleFileChange = (e) => {
|
|
5791
5768
|
setFile(e.target.files[0]);
|
|
5792
5769
|
};
|
|
@@ -6718,11 +6695,11 @@ var dateFieldController = (props) => {
|
|
|
6718
6695
|
};
|
|
6719
6696
|
|
|
6720
6697
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6721
|
-
var
|
|
6698
|
+
var import_react21 = require("react");
|
|
6722
6699
|
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6723
6700
|
var copyLinkButtonController = (props) => {
|
|
6724
6701
|
const { value, defaultValue } = props;
|
|
6725
|
-
const [isCopied, setIsCopied] = (0,
|
|
6702
|
+
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6726
6703
|
const handleCopyToClipboard = async (value2) => {
|
|
6727
6704
|
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6728
6705
|
setIsCopied(true);
|
|
@@ -6770,16 +6747,16 @@ var colorFieldController = (props) => {
|
|
|
6770
6747
|
};
|
|
6771
6748
|
|
|
6772
6749
|
// src/widget/basic/binary-field/controller.ts
|
|
6773
|
-
var
|
|
6750
|
+
var import_react22 = require("react");
|
|
6774
6751
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6775
6752
|
var binaryFieldController = (props) => {
|
|
6776
6753
|
const { name, methods, readonly = false, value } = props;
|
|
6777
|
-
const inputId = (0,
|
|
6778
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6779
|
-
const [initialImage, setInitialImage] = (0,
|
|
6780
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6754
|
+
const inputId = (0, import_react22.useId)();
|
|
6755
|
+
const [selectedImage, setSelectedImage] = (0, import_react22.useState)(null);
|
|
6756
|
+
const [initialImage, setInitialImage] = (0, import_react22.useState)(value || null);
|
|
6757
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react22.useState)(false);
|
|
6781
6758
|
const { setValue } = methods;
|
|
6782
|
-
const binaryRef = (0,
|
|
6759
|
+
const binaryRef = (0, import_react22.useRef)(null);
|
|
6783
6760
|
const convertUrlToBase64 = async (url) => {
|
|
6784
6761
|
try {
|
|
6785
6762
|
const response = await fetch(url);
|
|
@@ -6841,14 +6818,14 @@ var binaryFieldController = (props) => {
|
|
|
6841
6818
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6842
6819
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6843
6820
|
};
|
|
6844
|
-
(0,
|
|
6821
|
+
(0, import_react22.useEffect)(() => {
|
|
6845
6822
|
return () => {
|
|
6846
6823
|
if (selectedImage) {
|
|
6847
6824
|
URL.revokeObjectURL(selectedImage);
|
|
6848
6825
|
}
|
|
6849
6826
|
};
|
|
6850
6827
|
}, [selectedImage]);
|
|
6851
|
-
(0,
|
|
6828
|
+
(0, import_react22.useEffect)(() => {
|
|
6852
6829
|
if (binaryRef.current) {
|
|
6853
6830
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6854
6831
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6868,50 +6845,73 @@ var binaryFieldController = (props) => {
|
|
|
6868
6845
|
};
|
|
6869
6846
|
|
|
6870
6847
|
// src/widget/advance/table/table-head/controller.ts
|
|
6871
|
-
var
|
|
6848
|
+
var import_store7 = require("@fctc/interface-logic/store");
|
|
6849
|
+
var import_react23 = require("react");
|
|
6872
6850
|
var tableHeadController = (props) => {
|
|
6873
|
-
const { typeTable, rows,
|
|
6874
|
-
const appDispatch = (0,
|
|
6875
|
-
const {
|
|
6851
|
+
const { typeTable, rows, tableRef, groupByList, selectedRowKeys } = props;
|
|
6852
|
+
const appDispatch = (0, import_store7.useAppDispatch)();
|
|
6853
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6854
|
+
const selectedRowKeysRef = (0, import_react23.useRef)(recordIds);
|
|
6855
|
+
const isGroupTable = typeTable === "group";
|
|
6856
|
+
const recordsCheckedGroup = (0, import_react23.useMemo)(() => {
|
|
6857
|
+
if (!rows || !groupByList) return 0;
|
|
6858
|
+
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6859
|
+
return countSum(rows, groupBy);
|
|
6860
|
+
}, [rows, groupByList]);
|
|
6861
|
+
const isAllGroupChecked = (0, import_react23.useMemo)(() => {
|
|
6862
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6863
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6864
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6865
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6866
|
+
return allGroupsSelected || allRecordsSelected;
|
|
6867
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6868
|
+
const isAllNormalChecked = (0, import_react23.useMemo)(() => {
|
|
6869
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6870
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6871
|
+
(id) => rows.some((record) => record.id === id)
|
|
6872
|
+
);
|
|
6873
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6874
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6876
6875
|
const handleCheckBoxAll = (event) => {
|
|
6877
6876
|
if (event?.target?.checked && typeTable === "list") {
|
|
6878
6877
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6879
|
-
appDispatch((0,
|
|
6878
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(allRowKeys));
|
|
6880
6879
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6881
6880
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6882
6881
|
const ids = Array.from(rowsIDs)?.map(
|
|
6883
6882
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6884
6883
|
);
|
|
6885
6884
|
if (ids?.length > 0) {
|
|
6886
|
-
appDispatch((0,
|
|
6885
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(ids));
|
|
6887
6886
|
} else {
|
|
6888
6887
|
const sum = countSum(
|
|
6889
6888
|
rows,
|
|
6890
|
-
typeof
|
|
6889
|
+
typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0
|
|
6891
6890
|
);
|
|
6892
6891
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6893
|
-
appDispatch((0,
|
|
6892
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(keys));
|
|
6894
6893
|
}
|
|
6895
6894
|
if (selectedRowKeysRef) {
|
|
6896
6895
|
selectedRowKeysRef.current = [];
|
|
6897
6896
|
}
|
|
6898
6897
|
} else {
|
|
6899
|
-
appDispatch((0,
|
|
6898
|
+
appDispatch((0, import_store7.setSelectedRowKeys)([]));
|
|
6900
6899
|
}
|
|
6901
6900
|
};
|
|
6902
6901
|
return {
|
|
6903
|
-
handleCheckBoxAll
|
|
6902
|
+
handleCheckBoxAll,
|
|
6903
|
+
checkedAll,
|
|
6904
|
+
selectedRowKeysRef
|
|
6904
6905
|
};
|
|
6905
6906
|
};
|
|
6906
6907
|
|
|
6907
6908
|
// src/widget/advance/table/table-view/controller.ts
|
|
6908
|
-
var
|
|
6909
|
-
var import_store9 = require("@fctc/interface-logic/store");
|
|
6909
|
+
var import_react24 = require("react");
|
|
6910
6910
|
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6911
6911
|
var tableController = ({ data }) => {
|
|
6912
|
-
const [rows, setRows] = (0,
|
|
6913
|
-
const [columns, setColumns] = (0,
|
|
6914
|
-
const dataModelFields = data
|
|
6912
|
+
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6913
|
+
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
6914
|
+
const dataModelFields = data?.fields?.map((field) => {
|
|
6915
6915
|
return {
|
|
6916
6916
|
...data.dataModel?.[field?.name],
|
|
6917
6917
|
...field,
|
|
@@ -6938,8 +6938,8 @@ var tableController = ({ data }) => {
|
|
|
6938
6938
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6939
6939
|
});
|
|
6940
6940
|
};
|
|
6941
|
-
(0,
|
|
6942
|
-
setRows(transformData(data.records
|
|
6941
|
+
(0, import_react24.useEffect)(() => {
|
|
6942
|
+
setRows(transformData(data.records));
|
|
6943
6943
|
}, [data.records]);
|
|
6944
6944
|
const handleGetColumns = () => {
|
|
6945
6945
|
let cols = [];
|
|
@@ -6959,10 +6959,11 @@ var tableController = ({ data }) => {
|
|
|
6959
6959
|
}
|
|
6960
6960
|
return cols;
|
|
6961
6961
|
};
|
|
6962
|
-
(0,
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6962
|
+
(0, import_react24.useEffect)(() => {
|
|
6963
|
+
if (!columns) {
|
|
6964
|
+
setColumns(handleGetColumns());
|
|
6965
|
+
}
|
|
6966
|
+
}, [data]);
|
|
6966
6967
|
const onToggleColumnOptional = (item) => {
|
|
6967
6968
|
const tempColumn = [...columns]?.map((val) => {
|
|
6968
6969
|
if (item?.name === val?.name) {
|
|
@@ -6975,6 +6976,14 @@ var tableController = ({ data }) => {
|
|
|
6975
6976
|
});
|
|
6976
6977
|
setColumns(tempColumn);
|
|
6977
6978
|
};
|
|
6979
|
+
(0, import_react24.useEffect)(() => {
|
|
6980
|
+
setRows(null);
|
|
6981
|
+
setColumns(null);
|
|
6982
|
+
return () => {
|
|
6983
|
+
setRows(null);
|
|
6984
|
+
setColumns(null);
|
|
6985
|
+
};
|
|
6986
|
+
}, [data?.fields]);
|
|
6978
6987
|
return {
|
|
6979
6988
|
rows,
|
|
6980
6989
|
columns,
|
|
@@ -6984,47 +6993,32 @@ var tableController = ({ data }) => {
|
|
|
6984
6993
|
};
|
|
6985
6994
|
|
|
6986
6995
|
// src/widget/advance/table/table-group/controller.ts
|
|
6987
|
-
var
|
|
6988
|
-
var
|
|
6989
|
-
var import_store10 = require("@fctc/interface-logic/store");
|
|
6990
|
-
|
|
6991
|
-
// src/environment.ts
|
|
6992
|
-
var environment_exports = {};
|
|
6993
|
-
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
6994
|
-
|
|
6995
|
-
// src/widget/advance/table/table-group/controller.ts
|
|
6996
|
+
var import_react25 = require("react");
|
|
6997
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6996
6998
|
var tableGroupController = (props) => {
|
|
6997
|
-
const env = (0,
|
|
6999
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
7000
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6998
7001
|
const {
|
|
6999
|
-
rows,
|
|
7000
7002
|
columns,
|
|
7001
|
-
indexRow,
|
|
7002
7003
|
row,
|
|
7003
7004
|
model,
|
|
7004
7005
|
viewData,
|
|
7005
|
-
renderField,
|
|
7006
7006
|
level,
|
|
7007
7007
|
specification,
|
|
7008
|
-
domain,
|
|
7009
7008
|
context,
|
|
7010
7009
|
checkedAll,
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
setIsAutoSelect,
|
|
7014
|
-
selectedRowKeysRef
|
|
7010
|
+
groupByList,
|
|
7011
|
+
setSelectedRowKeys: setSelectedRowKeys3
|
|
7015
7012
|
} = props;
|
|
7016
|
-
const [pageGroup, setPageGroup] = (0,
|
|
7017
|
-
const {
|
|
7018
|
-
const
|
|
7019
|
-
const
|
|
7020
|
-
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
7021
|
-
const initVal = toDataJS(row, viewData, model);
|
|
7022
|
-
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
7023
|
-
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
7013
|
+
const [pageGroup, setPageGroup] = (0, import_react25.useState)(0);
|
|
7014
|
+
const { selectedRowKeys } = (0, import_store8.useAppSelector)(import_store8.selectList);
|
|
7015
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react25.useState)(false);
|
|
7016
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react25.useState)({
|
|
7024
7017
|
fromStart: 1,
|
|
7025
7018
|
fromEnd: 1
|
|
7026
7019
|
});
|
|
7027
|
-
const
|
|
7020
|
+
const domain = row?.__domain;
|
|
7021
|
+
const processedData = (0, import_react25.useMemo)(() => {
|
|
7028
7022
|
const calculateColSpanEmpty = () => {
|
|
7029
7023
|
const startIndex = columns.findIndex(
|
|
7030
7024
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -7039,7 +7033,7 @@ var tableGroupController = (props) => {
|
|
|
7039
7033
|
};
|
|
7040
7034
|
return calculateColSpanEmpty();
|
|
7041
7035
|
}, [columns, row]);
|
|
7042
|
-
const shouldFetchData = (0,
|
|
7036
|
+
const shouldFetchData = (0, import_react25.useMemo)(() => {
|
|
7043
7037
|
return !!isShowGroup;
|
|
7044
7038
|
}, [isShowGroup]);
|
|
7045
7039
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -7049,22 +7043,22 @@ var tableGroupController = (props) => {
|
|
|
7049
7043
|
domain,
|
|
7050
7044
|
context,
|
|
7051
7045
|
offset: pageGroup * 10,
|
|
7052
|
-
fields:
|
|
7053
|
-
groupby: [
|
|
7046
|
+
fields: groupByList?.fields,
|
|
7047
|
+
groupby: [groupByList?.contexts[level]?.group_by]
|
|
7054
7048
|
};
|
|
7055
7049
|
const queryKey = [
|
|
7056
|
-
`data-${model}
|
|
7050
|
+
`data-${model}-level_${level}-row-${row?.id}`,
|
|
7057
7051
|
specification,
|
|
7058
7052
|
domain,
|
|
7059
7053
|
pageGroup
|
|
7060
7054
|
];
|
|
7061
7055
|
const {
|
|
7062
|
-
data:
|
|
7063
|
-
isFetched:
|
|
7064
|
-
isPlaceholderData,
|
|
7056
|
+
data: dataGroup,
|
|
7057
|
+
isFetched: isDataGroupFetched,
|
|
7065
7058
|
isLoading,
|
|
7066
|
-
isFetching
|
|
7067
|
-
|
|
7059
|
+
isFetching,
|
|
7060
|
+
isPlaceholderData: isDataPlaceHolder
|
|
7061
|
+
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
7068
7062
|
const {
|
|
7069
7063
|
columns: columnsGroup,
|
|
7070
7064
|
rows: rowsGroup,
|
|
@@ -7072,27 +7066,21 @@ var tableGroupController = (props) => {
|
|
|
7072
7066
|
} = tableController({
|
|
7073
7067
|
data: {
|
|
7074
7068
|
fields: viewData?.views?.list?.fields,
|
|
7075
|
-
records:
|
|
7069
|
+
records: dataGroup?.records ?? dataGroup?.groups,
|
|
7076
7070
|
dataModel: viewData?.models?.[model],
|
|
7077
7071
|
context: env.context,
|
|
7078
|
-
typeTable:
|
|
7072
|
+
typeTable: dataGroup?.groups ? "group" : "list"
|
|
7079
7073
|
}
|
|
7080
7074
|
});
|
|
7081
|
-
const
|
|
7082
|
-
(0, import_react23.useEffect)(() => {
|
|
7083
|
-
if (isShowGroup && selectedTags?.length > 0) {
|
|
7084
|
-
setIsShowGroup(false);
|
|
7085
|
-
}
|
|
7086
|
-
}, [selectedTags]);
|
|
7087
|
-
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
7075
|
+
const group_by_field_name = groupByList?.contexts[level - 1]?.group_by;
|
|
7088
7076
|
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(
|
|
7089
7077
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
7090
7078
|
)?.[1] : row[group_by_field_name];
|
|
7091
7079
|
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`]})`;
|
|
7092
7080
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
7093
|
-
const
|
|
7081
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7082
|
+
const onExpandChildGroup = () => {
|
|
7094
7083
|
if (isLoading || isFetching) return;
|
|
7095
|
-
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7096
7084
|
if (allIdsNull || typeTableGroup === "group") {
|
|
7097
7085
|
toggleShowGroup();
|
|
7098
7086
|
return;
|
|
@@ -7102,53 +7090,39 @@ var tableGroupController = (props) => {
|
|
|
7102
7090
|
const filteredIds = selectedRowKeys.filter(
|
|
7103
7091
|
(id) => !ids.includes(id)
|
|
7104
7092
|
);
|
|
7105
|
-
|
|
7106
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull
|
|
7093
|
+
setSelectedRowKeys3(filteredIds);
|
|
7094
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
7107
7095
|
const clonedKeys = [...selectedRowKeys];
|
|
7108
|
-
|
|
7109
|
-
setTimeout(() =>
|
|
7096
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7097
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7110
7098
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7099
|
+
console.log("abc");
|
|
7111
7100
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7112
|
-
|
|
7101
|
+
setSelectedRowKeys3(filteredKeys);
|
|
7113
7102
|
}
|
|
7114
7103
|
toggleShowGroup();
|
|
7115
7104
|
};
|
|
7116
|
-
(0,
|
|
7117
|
-
if (!
|
|
7105
|
+
(0, import_react25.useEffect)(() => {
|
|
7106
|
+
if (!isDataGroupFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
7118
7107
|
return;
|
|
7119
7108
|
}
|
|
7120
7109
|
const clonedKeys = [...selectedRowKeys];
|
|
7121
|
-
(
|
|
7122
|
-
setTimeout(() => (
|
|
7123
|
-
}, [
|
|
7110
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7111
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7112
|
+
}, [isDataGroupFetched]);
|
|
7124
7113
|
return {
|
|
7125
|
-
|
|
7114
|
+
onExpandChildGroup,
|
|
7126
7115
|
colEmptyGroup,
|
|
7127
|
-
leftPadding,
|
|
7128
7116
|
isShowGroup,
|
|
7129
|
-
|
|
7117
|
+
isDataGroupFetched,
|
|
7118
|
+
isDataPlaceHolder,
|
|
7130
7119
|
nameGroupWithCount,
|
|
7131
|
-
columns,
|
|
7132
|
-
row,
|
|
7133
|
-
isPlaceholderData,
|
|
7134
7120
|
columnsGroup,
|
|
7135
|
-
indexRow,
|
|
7136
7121
|
rowsGroup,
|
|
7137
|
-
|
|
7138
|
-
viewData,
|
|
7139
|
-
renderField,
|
|
7140
|
-
level,
|
|
7141
|
-
specification,
|
|
7142
|
-
context,
|
|
7143
|
-
checkedAll,
|
|
7144
|
-
isDisplayCheckbox,
|
|
7145
|
-
isAutoSelect,
|
|
7146
|
-
setIsAutoSelect,
|
|
7147
|
-
selectedRowKeysRef,
|
|
7148
|
-
initVal,
|
|
7149
|
-
dataResponse,
|
|
7122
|
+
dataGroup,
|
|
7150
7123
|
pageGroup,
|
|
7151
|
-
setPageGroup
|
|
7124
|
+
setPageGroup,
|
|
7125
|
+
typeTableGroup
|
|
7152
7126
|
};
|
|
7153
7127
|
};
|
|
7154
7128
|
|
|
@@ -7156,7 +7130,7 @@ var tableGroupController = (props) => {
|
|
|
7156
7130
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
7157
7131
|
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
7158
7132
|
var import_moment2 = __toESM(require_moment());
|
|
7159
|
-
var
|
|
7133
|
+
var import_react26 = require("react");
|
|
7160
7134
|
var searchController = ({
|
|
7161
7135
|
viewData,
|
|
7162
7136
|
model,
|
|
@@ -7165,12 +7139,12 @@ var searchController = ({
|
|
|
7165
7139
|
fieldsList
|
|
7166
7140
|
}) => {
|
|
7167
7141
|
const { env } = (0, provider_exports.useEnv)();
|
|
7168
|
-
const [filterBy, setFilterBy] = (0,
|
|
7169
|
-
const [searchBy, setSearchBy] = (0,
|
|
7170
|
-
const [groupBy, setGroupBy] = (0,
|
|
7171
|
-
const [selectedTags, setSelectedTags] = (0,
|
|
7172
|
-
const [searchString, setSearchString] = (0,
|
|
7173
|
-
const [searchMap, setSearchMap] = (0,
|
|
7142
|
+
const [filterBy, setFilterBy] = (0, import_react26.useState)(null);
|
|
7143
|
+
const [searchBy, setSearchBy] = (0, import_react26.useState)(null);
|
|
7144
|
+
const [groupBy, setGroupBy] = (0, import_react26.useState)(null);
|
|
7145
|
+
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
7146
|
+
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
7147
|
+
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
7174
7148
|
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
7175
7149
|
const contextSearch = { ...env.context, ...actionContext };
|
|
7176
7150
|
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
@@ -7217,7 +7191,7 @@ var searchController = ({
|
|
|
7217
7191
|
}
|
|
7218
7192
|
}
|
|
7219
7193
|
};
|
|
7220
|
-
(0,
|
|
7194
|
+
(0, import_react26.useEffect)(() => {
|
|
7221
7195
|
fetchData();
|
|
7222
7196
|
}, [model, viewData]);
|
|
7223
7197
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7299,7 +7273,7 @@ var searchController = ({
|
|
|
7299
7273
|
return [...domain2];
|
|
7300
7274
|
}
|
|
7301
7275
|
};
|
|
7302
|
-
const setTagSearch = (0,
|
|
7276
|
+
const setTagSearch = (0, import_react26.useCallback)(
|
|
7303
7277
|
(updatedMap) => {
|
|
7304
7278
|
if (!updatedMap) return;
|
|
7305
7279
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7362,7 +7336,7 @@ var searchController = ({
|
|
|
7362
7336
|
},
|
|
7363
7337
|
[searchMap]
|
|
7364
7338
|
);
|
|
7365
|
-
(0,
|
|
7339
|
+
(0, import_react26.useEffect)(() => {
|
|
7366
7340
|
setTagSearch(searchMap);
|
|
7367
7341
|
}, [searchMap]);
|
|
7368
7342
|
const handleAddTagSearch = (tag) => {
|
|
@@ -7429,6 +7403,12 @@ __reExport(constants_exports, require("@fctc/interface-logic/constants"));
|
|
|
7429
7403
|
|
|
7430
7404
|
// src/index.ts
|
|
7431
7405
|
__reExport(index_exports, constants_exports, module.exports);
|
|
7406
|
+
|
|
7407
|
+
// src/environment.ts
|
|
7408
|
+
var environment_exports = {};
|
|
7409
|
+
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
7410
|
+
|
|
7411
|
+
// src/index.ts
|
|
7432
7412
|
__reExport(index_exports, environment_exports, module.exports);
|
|
7433
7413
|
__reExport(index_exports, provider_exports, module.exports);
|
|
7434
7414
|
|
|
@@ -7495,7 +7475,6 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
7495
7475
|
useMenu,
|
|
7496
7476
|
useMenuItem,
|
|
7497
7477
|
useProfile,
|
|
7498
|
-
useSelectionState,
|
|
7499
7478
|
useStorageState,
|
|
7500
7479
|
useUser,
|
|
7501
7480
|
useViewV2
|