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