@fctc/widget-logic 2.3.7 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.mts +2 -7
- package/dist/hooks.d.ts +2 -7
- package/dist/hooks.js +110 -85
- package/dist/hooks.mjs +131 -97
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +271 -250
- package/dist/index.mjs +270 -227
- package/dist/utils.d.mts +14 -1
- package/dist/utils.d.ts +14 -1
- package/dist/utils.js +95 -0
- package/dist/utils.mjs +116 -1
- package/dist/widget.d.mts +28 -15
- package/dist/widget.d.ts +28 -15
- package/dist/widget.js +265 -240
- package/dist/widget.mjs +266 -218
- package/package.json +96 -96
package/dist/widget.mjs
CHANGED
|
@@ -4091,7 +4091,7 @@ var statusDropdownController = (props) => {
|
|
|
4091
4091
|
};
|
|
4092
4092
|
|
|
4093
4093
|
// src/widget/basic/many2one-field/controller.ts
|
|
4094
|
-
import { useCallback as
|
|
4094
|
+
import { useCallback as useCallback2, useEffect as useEffect10, useMemo as useMemo9, useState as useState8 } from "react";
|
|
4095
4095
|
|
|
4096
4096
|
// src/hooks.ts
|
|
4097
4097
|
var hooks_exports = {};
|
|
@@ -4104,7 +4104,6 @@ __export(hooks_exports, {
|
|
|
4104
4104
|
useConfig: () => useConfig,
|
|
4105
4105
|
useDebounce: () => useDebounce,
|
|
4106
4106
|
useDetail: () => useDetail,
|
|
4107
|
-
useGetRowIds: () => useGetRowIds,
|
|
4108
4107
|
useListData: () => useListData,
|
|
4109
4108
|
useMenu: () => useMenu,
|
|
4110
4109
|
useMenuItem: () => useMenuItem,
|
|
@@ -4228,10 +4227,24 @@ var useDetail = (accessToken, sub) => {
|
|
|
4228
4227
|
};
|
|
4229
4228
|
|
|
4230
4229
|
// src/hooks/core/use-list-data.ts
|
|
4231
|
-
import { useMemo as
|
|
4230
|
+
import { useMemo as useMemo3, useState as useState4 } from "react";
|
|
4231
|
+
|
|
4232
|
+
// src/utils/function.ts
|
|
4233
|
+
import {
|
|
4234
|
+
useCallback,
|
|
4235
|
+
useEffect as useEffect4,
|
|
4236
|
+
useMemo as useMemo2,
|
|
4237
|
+
useReducer,
|
|
4238
|
+
useRef as useRef2,
|
|
4239
|
+
useState as useState3
|
|
4240
|
+
} from "react";
|
|
4241
|
+
|
|
4242
|
+
// src/store.ts
|
|
4243
|
+
var store_exports = {};
|
|
4244
|
+
__reExport(store_exports, store_star);
|
|
4245
|
+
import * as store_star from "@fctc/interface-logic/store";
|
|
4232
4246
|
|
|
4233
4247
|
// src/utils/function.ts
|
|
4234
|
-
import { useCallback, useEffect as useEffect4, useReducer } from "react";
|
|
4235
4248
|
var countSum = (data, field) => {
|
|
4236
4249
|
if (!data || !field) return 0;
|
|
4237
4250
|
return data.reduce(
|
|
@@ -4250,6 +4263,91 @@ function mergeButtons(fields) {
|
|
|
4250
4263
|
}
|
|
4251
4264
|
return others;
|
|
4252
4265
|
}
|
|
4266
|
+
function isElementVisible(el) {
|
|
4267
|
+
const style = window.getComputedStyle(el);
|
|
4268
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4269
|
+
}
|
|
4270
|
+
function arraysAreEqual(a, b) {
|
|
4271
|
+
if (a.length !== b.length) return false;
|
|
4272
|
+
const setA = new Set(a);
|
|
4273
|
+
const setB = new Set(b);
|
|
4274
|
+
if (setA.size !== setB.size) return false;
|
|
4275
|
+
for (const val of setA) {
|
|
4276
|
+
if (!setB.has(val)) return false;
|
|
4277
|
+
}
|
|
4278
|
+
return true;
|
|
4279
|
+
}
|
|
4280
|
+
function useGetRowIds(tableRef) {
|
|
4281
|
+
const [rowIds, setRowIds] = useState3([]);
|
|
4282
|
+
const lastRowIdsRef = useRef2([]);
|
|
4283
|
+
const updateVisibleRowIds = useCallback(() => {
|
|
4284
|
+
const table = tableRef?.current;
|
|
4285
|
+
if (!table) return;
|
|
4286
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4287
|
+
const ids = [];
|
|
4288
|
+
rows.forEach((row) => {
|
|
4289
|
+
const el = row;
|
|
4290
|
+
if (isElementVisible(el)) {
|
|
4291
|
+
const id = el.getAttribute("data-row-id");
|
|
4292
|
+
if (id) ids.push(id);
|
|
4293
|
+
}
|
|
4294
|
+
});
|
|
4295
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4296
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4297
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4298
|
+
setRowIds(uniqueIds);
|
|
4299
|
+
}
|
|
4300
|
+
}, [tableRef]);
|
|
4301
|
+
useEffect4(() => {
|
|
4302
|
+
const table = tableRef?.current;
|
|
4303
|
+
if (!table) return;
|
|
4304
|
+
const observer = new MutationObserver(() => {
|
|
4305
|
+
updateVisibleRowIds();
|
|
4306
|
+
});
|
|
4307
|
+
observer.observe(table, {
|
|
4308
|
+
childList: true,
|
|
4309
|
+
subtree: true,
|
|
4310
|
+
attributes: true,
|
|
4311
|
+
attributeFilter: ["style", "class"]
|
|
4312
|
+
});
|
|
4313
|
+
updateVisibleRowIds();
|
|
4314
|
+
return () => {
|
|
4315
|
+
observer.disconnect();
|
|
4316
|
+
};
|
|
4317
|
+
}, [updateVisibleRowIds, tableRef]);
|
|
4318
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4319
|
+
}
|
|
4320
|
+
var useSelectionState = ({
|
|
4321
|
+
typeTable,
|
|
4322
|
+
tableRef,
|
|
4323
|
+
rows
|
|
4324
|
+
}) => {
|
|
4325
|
+
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
4326
|
+
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
4327
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
4328
|
+
const selectedRowKeysRef = useRef2(recordIds);
|
|
4329
|
+
const isGroupTable = typeTable === "group";
|
|
4330
|
+
const recordsCheckedGroup = useMemo2(() => {
|
|
4331
|
+
if (!rows || !groupByDomain) return 0;
|
|
4332
|
+
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
4333
|
+
return countSum(rows, groupBy);
|
|
4334
|
+
}, [rows, groupByDomain]);
|
|
4335
|
+
const isAllGroupChecked = useMemo2(() => {
|
|
4336
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
4337
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
4338
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
4339
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
4340
|
+
return allGroupsSelected || allRecordsSelected;
|
|
4341
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
4342
|
+
const isAllNormalChecked = useMemo2(() => {
|
|
4343
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
4344
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
4345
|
+
(id) => rows.some((record) => record.id === id)
|
|
4346
|
+
);
|
|
4347
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
4348
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
4349
|
+
return { checkedAll, selectedRowKeysRef };
|
|
4350
|
+
};
|
|
4253
4351
|
var getDateRange = (currentDate, unit) => {
|
|
4254
4352
|
const date = new Date(currentDate);
|
|
4255
4353
|
let dateStart, dateEnd;
|
|
@@ -4391,9 +4489,9 @@ function useStorageState(key) {
|
|
|
4391
4489
|
// src/hooks/core/use-list-data.ts
|
|
4392
4490
|
import { useModel, useGetListData } from "@fctc/interface-logic/hooks";
|
|
4393
4491
|
import {
|
|
4394
|
-
useAppSelector,
|
|
4395
|
-
selectSearch,
|
|
4396
|
-
selectList
|
|
4492
|
+
useAppSelector as useAppSelector2,
|
|
4493
|
+
selectSearch as selectSearch2,
|
|
4494
|
+
selectList as selectList2
|
|
4397
4495
|
} from "@fctc/interface-logic/store";
|
|
4398
4496
|
import {
|
|
4399
4497
|
evalJSONDomain,
|
|
@@ -4404,13 +4502,13 @@ var useListData = ({
|
|
|
4404
4502
|
context,
|
|
4405
4503
|
viewResponse
|
|
4406
4504
|
}) => {
|
|
4407
|
-
const { groupByDomain } =
|
|
4505
|
+
const { groupByDomain } = useAppSelector2(selectSearch2);
|
|
4408
4506
|
const initModel = useModel();
|
|
4409
|
-
const [type, setType] =
|
|
4410
|
-
const [mode, setMode] =
|
|
4411
|
-
const [currentDate, setCurrentDate] =
|
|
4412
|
-
const { pageLimit, page, order } =
|
|
4413
|
-
const listDataProps =
|
|
4507
|
+
const [type, setType] = useState4("list");
|
|
4508
|
+
const [mode, setMode] = useState4("month");
|
|
4509
|
+
const [currentDate, setCurrentDate] = useState4(/* @__PURE__ */ new Date());
|
|
4510
|
+
const { pageLimit, page, order } = useAppSelector2(selectList2);
|
|
4511
|
+
const listDataProps = useMemo3(() => {
|
|
4414
4512
|
const actData = action?.result;
|
|
4415
4513
|
if (!viewResponse || !actData || !context) {
|
|
4416
4514
|
return null;
|
|
@@ -4471,7 +4569,7 @@ var useListData = ({
|
|
|
4471
4569
|
};
|
|
4472
4570
|
|
|
4473
4571
|
// src/hooks/core/use-menu.ts
|
|
4474
|
-
import { useEffect as useEffect5, useMemo as
|
|
4572
|
+
import { useEffect as useEffect5, useMemo as useMemo4, useState as useState5 } from "react";
|
|
4475
4573
|
|
|
4476
4574
|
// src/utils/constants.ts
|
|
4477
4575
|
var languages = [
|
|
@@ -4491,9 +4589,9 @@ var API_APP_URL = {
|
|
|
4491
4589
|
import { useGetMenu } from "@fctc/interface-logic/hooks";
|
|
4492
4590
|
var useMenu = ({ context }) => {
|
|
4493
4591
|
const menuData = useGetMenu(context, !!context);
|
|
4494
|
-
const [menuid, setMenuId] =
|
|
4592
|
+
const [menuid, setMenuId] = useState5(void 0);
|
|
4495
4593
|
const [action, setAction] = useCallAction();
|
|
4496
|
-
const configedIconData =
|
|
4594
|
+
const configedIconData = useMemo4(() => {
|
|
4497
4595
|
const data = menuData.data;
|
|
4498
4596
|
return data?.map((item) => {
|
|
4499
4597
|
return {
|
|
@@ -4540,7 +4638,7 @@ var useMenu = ({ context }) => {
|
|
|
4540
4638
|
|
|
4541
4639
|
// src/hooks/core/use-profile.ts
|
|
4542
4640
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
4543
|
-
import { useEffect as useEffect6, useMemo as
|
|
4641
|
+
import { useEffect as useEffect6, useMemo as useMemo5 } from "react";
|
|
4544
4642
|
import { useTranslation } from "react-i18next";
|
|
4545
4643
|
import { getEnv as getEnv4 } from "@fctc/interface-logic/environment";
|
|
4546
4644
|
import { useGetProfile } from "@fctc/interface-logic/hooks";
|
|
@@ -4568,7 +4666,7 @@ var useProfile = (accessToken) => {
|
|
|
4568
4666
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
4569
4667
|
}
|
|
4570
4668
|
}, [dispatch, userInfoQuery.data]);
|
|
4571
|
-
const context =
|
|
4669
|
+
const context = useMemo5(() => {
|
|
4572
4670
|
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
4573
4671
|
return {
|
|
4574
4672
|
uid: Number(userInfoQuery.data.sub),
|
|
@@ -4590,13 +4688,13 @@ var useUser = (accessToken) => {
|
|
|
4590
4688
|
};
|
|
4591
4689
|
|
|
4592
4690
|
// src/hooks/core/use-view-v2.ts
|
|
4593
|
-
import { useMemo as
|
|
4691
|
+
import { useMemo as useMemo6 } from "react";
|
|
4594
4692
|
import { useGetView } from "@fctc/interface-logic/hooks";
|
|
4595
4693
|
var useViewV2 = ({
|
|
4596
4694
|
action,
|
|
4597
4695
|
context
|
|
4598
4696
|
}) => {
|
|
4599
|
-
const viewParams =
|
|
4697
|
+
const viewParams = useMemo6(() => {
|
|
4600
4698
|
if (!action?.result) {
|
|
4601
4699
|
return void 0;
|
|
4602
4700
|
}
|
|
@@ -4671,11 +4769,11 @@ var useAuth = () => {
|
|
|
4671
4769
|
};
|
|
4672
4770
|
|
|
4673
4771
|
// src/hooks/core/use-app-provider.tsx
|
|
4674
|
-
import { createContext, useContext, useMemo as
|
|
4772
|
+
import { createContext, useContext, useMemo as useMemo8 } from "react";
|
|
4675
4773
|
|
|
4676
4774
|
// src/hooks/core/use-company.ts
|
|
4677
4775
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
4678
|
-
import { useEffect as useEffect7, useMemo as
|
|
4776
|
+
import { useEffect as useEffect7, useMemo as useMemo7 } from "react";
|
|
4679
4777
|
import { getEnv as getEnv5 } from "@fctc/interface-logic/environment";
|
|
4680
4778
|
import {
|
|
4681
4779
|
useGetCurrentCompany,
|
|
@@ -4691,7 +4789,7 @@ var useCompany = (accessToken) => {
|
|
|
4691
4789
|
queryFn: fetchCurrentCompany,
|
|
4692
4790
|
enabled: !!accessToken
|
|
4693
4791
|
});
|
|
4694
|
-
const current_company_id =
|
|
4792
|
+
const current_company_id = useMemo7(() => {
|
|
4695
4793
|
return currentCompany.data?.current_company_id;
|
|
4696
4794
|
}, [currentCompany.data]);
|
|
4697
4795
|
useEffect7(() => {
|
|
@@ -4744,14 +4842,14 @@ var AppProvider = ({ children }) => {
|
|
|
4744
4842
|
const auth = useAuth();
|
|
4745
4843
|
const user = useUser(auth.accessToken);
|
|
4746
4844
|
const company = use_company_default(auth.accessToken);
|
|
4747
|
-
const menuContext =
|
|
4845
|
+
const menuContext = useMemo8(() => {
|
|
4748
4846
|
return combineContexts([user.context, company.context]);
|
|
4749
4847
|
}, [user.context, company.context]);
|
|
4750
4848
|
const menu = useMenu({ context: menuContext });
|
|
4751
|
-
const action =
|
|
4849
|
+
const action = useMemo8(() => {
|
|
4752
4850
|
return menu.state.action;
|
|
4753
4851
|
}, [menu.state.action]);
|
|
4754
|
-
const viewContext =
|
|
4852
|
+
const viewContext = useMemo8(() => {
|
|
4755
4853
|
return combineContexts([
|
|
4756
4854
|
menuContext,
|
|
4757
4855
|
{ ...evalJSONContext(action?.result?.context) }
|
|
@@ -4794,7 +4892,7 @@ var useAppProvider = () => {
|
|
|
4794
4892
|
// src/hooks/core/use-menu-item.tsx
|
|
4795
4893
|
import { getEnv as getEnv6 } from "@fctc/interface-logic/environment";
|
|
4796
4894
|
import { useGetActionDetail } from "@fctc/interface-logic/hooks";
|
|
4797
|
-
import { useState as
|
|
4895
|
+
import { useState as useState6 } from "react";
|
|
4798
4896
|
|
|
4799
4897
|
// src/utils.ts
|
|
4800
4898
|
var utils_exports = {};
|
|
@@ -4809,6 +4907,8 @@ __export(utils_exports, {
|
|
|
4809
4907
|
languages: () => languages,
|
|
4810
4908
|
mergeButtons: () => mergeButtons,
|
|
4811
4909
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4910
|
+
useGetRowIds: () => useGetRowIds,
|
|
4911
|
+
useSelectionState: () => useSelectionState,
|
|
4812
4912
|
useStorageState: () => useStorageState
|
|
4813
4913
|
});
|
|
4814
4914
|
__reExport(utils_exports, utils_star);
|
|
@@ -4829,7 +4929,7 @@ var useMenuItem = (props) => {
|
|
|
4829
4929
|
enabled: true,
|
|
4830
4930
|
queryKey: [`action-${aid}`]
|
|
4831
4931
|
}).data;
|
|
4832
|
-
const [path, setPath] =
|
|
4932
|
+
const [path, setPath] = useState6("");
|
|
4833
4933
|
const handleClick = () => {
|
|
4834
4934
|
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4835
4935
|
return;
|
|
@@ -4851,74 +4951,8 @@ var useMenuItem = (props) => {
|
|
|
4851
4951
|
return { handleClick, path, queryActionDetail };
|
|
4852
4952
|
};
|
|
4853
4953
|
|
|
4854
|
-
// src/hooks/core/use-get-rowids.ts
|
|
4855
|
-
import { useCallback as useCallback2, useEffect as useEffect8, useRef as useRef2, useState as useState6 } from "react";
|
|
4856
|
-
var useGetRowIds = (tableRef) => {
|
|
4857
|
-
function isElementVisible(el) {
|
|
4858
|
-
const style = window.getComputedStyle(el);
|
|
4859
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4860
|
-
}
|
|
4861
|
-
function arraysAreEqual(a, b) {
|
|
4862
|
-
if (a.length !== b.length) return false;
|
|
4863
|
-
if (a.length === 0 && b.length === 0) return true;
|
|
4864
|
-
const setA = new Set(a);
|
|
4865
|
-
const setB = new Set(b);
|
|
4866
|
-
if (setA.size !== setB.size) return false;
|
|
4867
|
-
for (const val of setA) {
|
|
4868
|
-
if (!setB.has(val)) return false;
|
|
4869
|
-
}
|
|
4870
|
-
return true;
|
|
4871
|
-
}
|
|
4872
|
-
const [rowIds, setRowIds] = useState6([]);
|
|
4873
|
-
const lastRowIdsRef = useRef2([]);
|
|
4874
|
-
const updateVisibleRowIds = useCallback2(() => {
|
|
4875
|
-
const table = tableRef.current;
|
|
4876
|
-
if (!table) return;
|
|
4877
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4878
|
-
const ids = [];
|
|
4879
|
-
rows.forEach((row) => {
|
|
4880
|
-
const el = row;
|
|
4881
|
-
if (isElementVisible(el)) {
|
|
4882
|
-
const id = el.getAttribute("data-row-id");
|
|
4883
|
-
if (id) ids.push(id);
|
|
4884
|
-
}
|
|
4885
|
-
});
|
|
4886
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4887
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4888
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4889
|
-
setRowIds(uniqueIds);
|
|
4890
|
-
}
|
|
4891
|
-
}, [tableRef]);
|
|
4892
|
-
useEffect8(() => {
|
|
4893
|
-
const table = tableRef.current;
|
|
4894
|
-
if (!table) return;
|
|
4895
|
-
const mutationObserver = new MutationObserver(() => {
|
|
4896
|
-
updateVisibleRowIds();
|
|
4897
|
-
});
|
|
4898
|
-
mutationObserver.observe(table, {
|
|
4899
|
-
childList: true,
|
|
4900
|
-
subtree: true,
|
|
4901
|
-
attributes: true,
|
|
4902
|
-
attributeFilter: ["style", "class"]
|
|
4903
|
-
});
|
|
4904
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
4905
|
-
updateVisibleRowIds();
|
|
4906
|
-
});
|
|
4907
|
-
resizeObserver.observe(table);
|
|
4908
|
-
const handleScroll = () => updateVisibleRowIds();
|
|
4909
|
-
table.addEventListener("scroll", handleScroll, true);
|
|
4910
|
-
updateVisibleRowIds();
|
|
4911
|
-
return () => {
|
|
4912
|
-
mutationObserver.disconnect();
|
|
4913
|
-
resizeObserver.disconnect();
|
|
4914
|
-
table.removeEventListener("scroll", handleScroll, true);
|
|
4915
|
-
};
|
|
4916
|
-
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4917
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4918
|
-
};
|
|
4919
|
-
|
|
4920
4954
|
// src/hooks/utils/use-click-outside.ts
|
|
4921
|
-
import { useEffect as
|
|
4955
|
+
import { useEffect as useEffect8, useRef as useRef3 } from "react";
|
|
4922
4956
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4923
4957
|
var useClickOutside = ({
|
|
4924
4958
|
handler,
|
|
@@ -4927,7 +4961,7 @@ var useClickOutside = ({
|
|
|
4927
4961
|
refs
|
|
4928
4962
|
}) => {
|
|
4929
4963
|
const ref = useRef3(null);
|
|
4930
|
-
|
|
4964
|
+
useEffect8(() => {
|
|
4931
4965
|
const listener = (event) => {
|
|
4932
4966
|
const { target } = event;
|
|
4933
4967
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4949,10 +4983,10 @@ var useClickOutside = ({
|
|
|
4949
4983
|
};
|
|
4950
4984
|
|
|
4951
4985
|
// src/hooks/utils/use-debounce.ts
|
|
4952
|
-
import { useEffect as
|
|
4986
|
+
import { useEffect as useEffect9, useState as useState7 } from "react";
|
|
4953
4987
|
function useDebounce(value, delay) {
|
|
4954
4988
|
const [debouncedValue, setDebouncedValue] = useState7(value);
|
|
4955
|
-
|
|
4989
|
+
useEffect9(() => {
|
|
4956
4990
|
const handler = setTimeout(() => {
|
|
4957
4991
|
setDebouncedValue(value);
|
|
4958
4992
|
}, delay);
|
|
@@ -4967,11 +5001,6 @@ function useDebounce(value, delay) {
|
|
|
4967
5001
|
__reExport(hooks_exports, hooks_star);
|
|
4968
5002
|
import * as hooks_star from "@fctc/interface-logic/hooks";
|
|
4969
5003
|
|
|
4970
|
-
// src/store.ts
|
|
4971
|
-
var store_exports = {};
|
|
4972
|
-
__reExport(store_exports, store_star);
|
|
4973
|
-
import * as store_star from "@fctc/interface-logic/store";
|
|
4974
|
-
|
|
4975
5004
|
// src/provider.ts
|
|
4976
5005
|
var provider_exports = {};
|
|
4977
5006
|
__reExport(provider_exports, provider_star);
|
|
@@ -5030,18 +5059,18 @@ var many2oneFieldController = (props) => {
|
|
|
5030
5059
|
queryKey,
|
|
5031
5060
|
enabled: false
|
|
5032
5061
|
});
|
|
5033
|
-
const selectOptions =
|
|
5062
|
+
const selectOptions = useMemo9(() => {
|
|
5034
5063
|
return dataOfSelection?.records?.map((val) => ({
|
|
5035
5064
|
value: val?.id,
|
|
5036
5065
|
label: val?.display_name || val?.name
|
|
5037
5066
|
})) || [];
|
|
5038
5067
|
}, [dataOfSelection]);
|
|
5039
|
-
|
|
5068
|
+
useEffect10(() => {
|
|
5040
5069
|
setOptions(selectOptions);
|
|
5041
5070
|
setDomainModal(domainObject);
|
|
5042
5071
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5043
5072
|
}, [selectOptions]);
|
|
5044
|
-
|
|
5073
|
+
useEffect10(() => {
|
|
5045
5074
|
setDomainObject(
|
|
5046
5075
|
(0, utils_exports.evalJSONDomain)(
|
|
5047
5076
|
domain,
|
|
@@ -5049,7 +5078,7 @@ var many2oneFieldController = (props) => {
|
|
|
5049
5078
|
)
|
|
5050
5079
|
);
|
|
5051
5080
|
}, [domain, formValues]);
|
|
5052
|
-
|
|
5081
|
+
useEffect10(() => {
|
|
5053
5082
|
if (!propValue && tempSelectedOption) {
|
|
5054
5083
|
methods.setValue(name, null);
|
|
5055
5084
|
setTempSelectedOption(null);
|
|
@@ -5060,10 +5089,10 @@ var many2oneFieldController = (props) => {
|
|
|
5060
5089
|
});
|
|
5061
5090
|
}
|
|
5062
5091
|
}, [propValue]);
|
|
5063
|
-
const fetchMoreOptions =
|
|
5092
|
+
const fetchMoreOptions = useCallback2(() => {
|
|
5064
5093
|
refetch();
|
|
5065
5094
|
}, [refetch]);
|
|
5066
|
-
|
|
5095
|
+
useEffect10(() => {
|
|
5067
5096
|
if (debouncedInputValue) {
|
|
5068
5097
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5069
5098
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5078,7 +5107,7 @@ var many2oneFieldController = (props) => {
|
|
|
5078
5107
|
}, 50);
|
|
5079
5108
|
}
|
|
5080
5109
|
}, [debouncedInputValue]);
|
|
5081
|
-
const handleChooseRecord =
|
|
5110
|
+
const handleChooseRecord = useCallback2(
|
|
5082
5111
|
(idRecord) => {
|
|
5083
5112
|
const newOption = options.find(
|
|
5084
5113
|
(option) => option.value === idRecord
|
|
@@ -5103,8 +5132,8 @@ var many2oneFieldController = (props) => {
|
|
|
5103
5132
|
},
|
|
5104
5133
|
[options, methods, name, onChange]
|
|
5105
5134
|
);
|
|
5106
|
-
const handleClose =
|
|
5107
|
-
const handleSelectChange =
|
|
5135
|
+
const handleClose = useCallback2(() => setIsShowModalMany2Many(false), []);
|
|
5136
|
+
const handleSelectChange = useCallback2(
|
|
5108
5137
|
(selectedOption) => {
|
|
5109
5138
|
if (!selectedOption) {
|
|
5110
5139
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5178,7 +5207,7 @@ var many2oneButtonController = (props) => {
|
|
|
5178
5207
|
};
|
|
5179
5208
|
|
|
5180
5209
|
// src/widget/basic/many2many-field/controller.ts
|
|
5181
|
-
import { useEffect as
|
|
5210
|
+
import { useEffect as useEffect11, useMemo as useMemo10, useState as useState9 } from "react";
|
|
5182
5211
|
import {
|
|
5183
5212
|
evalJSONContext as evalJSONContext4,
|
|
5184
5213
|
evalJSONDomain as evalJSONDomain4,
|
|
@@ -5197,7 +5226,7 @@ var many2manyFieldController = (props) => {
|
|
|
5197
5226
|
actionData
|
|
5198
5227
|
} = props;
|
|
5199
5228
|
const { env } = (0, provider_exports.useEnv)();
|
|
5200
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5229
|
+
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5201
5230
|
const [order, setOrder] = useState9();
|
|
5202
5231
|
const [page, setPage] = useState9(0);
|
|
5203
5232
|
const [domainMany2Many, setDomainMany2Many] = useState9(null);
|
|
@@ -5215,7 +5244,7 @@ var many2manyFieldController = (props) => {
|
|
|
5215
5244
|
context: contextObject
|
|
5216
5245
|
};
|
|
5217
5246
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5218
|
-
const baseModel =
|
|
5247
|
+
const baseModel = useMemo10(
|
|
5219
5248
|
() => ({
|
|
5220
5249
|
name: String(relation),
|
|
5221
5250
|
view: viewResponse || {},
|
|
@@ -5228,13 +5257,13 @@ var many2manyFieldController = (props) => {
|
|
|
5228
5257
|
[relation, viewResponse]
|
|
5229
5258
|
);
|
|
5230
5259
|
const initModel = (0, hooks_exports.useModel)();
|
|
5231
|
-
const modelInstance =
|
|
5260
|
+
const modelInstance = useMemo10(() => {
|
|
5232
5261
|
if (viewResponse) {
|
|
5233
5262
|
return initModel.initModel(baseModel);
|
|
5234
5263
|
}
|
|
5235
5264
|
return null;
|
|
5236
5265
|
}, [baseModel, viewResponse]);
|
|
5237
|
-
const specification =
|
|
5266
|
+
const specification = useMemo10(() => {
|
|
5238
5267
|
if (modelInstance) {
|
|
5239
5268
|
return modelInstance.getSpecification();
|
|
5240
5269
|
}
|
|
@@ -5276,8 +5305,8 @@ var many2manyFieldController = (props) => {
|
|
|
5276
5305
|
isLoading,
|
|
5277
5306
|
isFetched,
|
|
5278
5307
|
isPlaceholderData
|
|
5279
|
-
} =
|
|
5280
|
-
|
|
5308
|
+
} = useGetListData3(data, queryKey, enabled);
|
|
5309
|
+
useEffect11(() => {
|
|
5281
5310
|
if (viewResponse) {
|
|
5282
5311
|
fetchData();
|
|
5283
5312
|
}
|
|
@@ -5330,7 +5359,7 @@ var many2manyFieldController = (props) => {
|
|
|
5330
5359
|
};
|
|
5331
5360
|
|
|
5332
5361
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5333
|
-
import { useMemo as
|
|
5362
|
+
import { useMemo as useMemo11 } from "react";
|
|
5334
5363
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5335
5364
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
5336
5365
|
var many2manyTagsController = (props) => {
|
|
@@ -5346,7 +5375,7 @@ var many2manyTagsController = (props) => {
|
|
|
5346
5375
|
const { env } = (0, provider_exports.useEnv)();
|
|
5347
5376
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5348
5377
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
5349
|
-
const domainObject =
|
|
5378
|
+
const domainObject = useMemo11(
|
|
5350
5379
|
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5351
5380
|
[domain, formValues]
|
|
5352
5381
|
);
|
|
@@ -5397,7 +5426,7 @@ var durationController = (props) => {
|
|
|
5397
5426
|
name: "",
|
|
5398
5427
|
fold: ""
|
|
5399
5428
|
};
|
|
5400
|
-
const { useGetListData:
|
|
5429
|
+
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5401
5430
|
const { env } = (0, provider_exports.useEnv)();
|
|
5402
5431
|
const [disabled, setDisabled] = useState10(false);
|
|
5403
5432
|
const [modelStatus, setModalStatus] = useState10(false);
|
|
@@ -5415,7 +5444,7 @@ var durationController = (props) => {
|
|
|
5415
5444
|
},
|
|
5416
5445
|
sort: ""
|
|
5417
5446
|
};
|
|
5418
|
-
const { data: dataResponse } =
|
|
5447
|
+
const { data: dataResponse } = useGetListData3(
|
|
5419
5448
|
listDataProps,
|
|
5420
5449
|
queryKey,
|
|
5421
5450
|
enabled
|
|
@@ -6477,7 +6506,7 @@ var colorFieldController = (props) => {
|
|
|
6477
6506
|
};
|
|
6478
6507
|
|
|
6479
6508
|
// src/widget/basic/binary-field/controller.ts
|
|
6480
|
-
import { useEffect as
|
|
6509
|
+
import { useEffect as useEffect12, useId as useId2, useRef as useRef4, useState as useState13 } from "react";
|
|
6481
6510
|
import { isBase64Image } from "@fctc/interface-logic/utils";
|
|
6482
6511
|
var binaryFieldController = (props) => {
|
|
6483
6512
|
const { name, methods, readonly = false, value } = props;
|
|
@@ -6548,14 +6577,14 @@ var binaryFieldController = (props) => {
|
|
|
6548
6577
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6549
6578
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6550
6579
|
};
|
|
6551
|
-
|
|
6580
|
+
useEffect12(() => {
|
|
6552
6581
|
return () => {
|
|
6553
6582
|
if (selectedImage) {
|
|
6554
6583
|
URL.revokeObjectURL(selectedImage);
|
|
6555
6584
|
}
|
|
6556
6585
|
};
|
|
6557
6586
|
}, [selectedImage]);
|
|
6558
|
-
|
|
6587
|
+
useEffect12(() => {
|
|
6559
6588
|
if (binaryRef.current) {
|
|
6560
6589
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6561
6590
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6575,33 +6604,16 @@ var binaryFieldController = (props) => {
|
|
|
6575
6604
|
};
|
|
6576
6605
|
|
|
6577
6606
|
// src/widget/advance/table/table-head/controller.ts
|
|
6578
|
-
import {
|
|
6579
|
-
|
|
6607
|
+
import {
|
|
6608
|
+
useAppDispatch as useAppDispatch5,
|
|
6609
|
+
useAppSelector as useAppSelector4,
|
|
6610
|
+
selectSearch as selectSearch3,
|
|
6611
|
+
setSelectedRowKeys
|
|
6612
|
+
} from "@fctc/interface-logic/store";
|
|
6580
6613
|
var tableHeadController = (props) => {
|
|
6581
|
-
const { typeTable, rows,
|
|
6614
|
+
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6582
6615
|
const appDispatch = useAppDispatch5();
|
|
6583
|
-
const {
|
|
6584
|
-
const selectedRowKeysRef = useRef5(recordIds);
|
|
6585
|
-
const isGroupTable = typeTable === "group";
|
|
6586
|
-
const recordsCheckedGroup = useMemo11(() => {
|
|
6587
|
-
if (!rows || !groupByList) return 0;
|
|
6588
|
-
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6589
|
-
return countSum(rows, groupBy);
|
|
6590
|
-
}, [rows, groupByList]);
|
|
6591
|
-
const isAllGroupChecked = useMemo11(() => {
|
|
6592
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6593
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6594
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6595
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6596
|
-
return allGroupsSelected || allRecordsSelected;
|
|
6597
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6598
|
-
const isAllNormalChecked = useMemo11(() => {
|
|
6599
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6600
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6601
|
-
(id) => rows.some((record) => record.id === id)
|
|
6602
|
-
);
|
|
6603
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6604
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6616
|
+
const { groupByDomain } = useAppSelector4(selectSearch3);
|
|
6605
6617
|
const handleCheckBoxAll = (event) => {
|
|
6606
6618
|
if (event?.target?.checked && typeTable === "list") {
|
|
6607
6619
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
@@ -6616,7 +6628,7 @@ var tableHeadController = (props) => {
|
|
|
6616
6628
|
} else {
|
|
6617
6629
|
const sum = countSum(
|
|
6618
6630
|
rows,
|
|
6619
|
-
typeof
|
|
6631
|
+
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6620
6632
|
);
|
|
6621
6633
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6622
6634
|
appDispatch(setSelectedRowKeys(keys));
|
|
@@ -6629,19 +6641,22 @@ var tableHeadController = (props) => {
|
|
|
6629
6641
|
}
|
|
6630
6642
|
};
|
|
6631
6643
|
return {
|
|
6632
|
-
handleCheckBoxAll
|
|
6633
|
-
checkedAll,
|
|
6634
|
-
selectedRowKeysRef
|
|
6644
|
+
handleCheckBoxAll
|
|
6635
6645
|
};
|
|
6636
6646
|
};
|
|
6637
6647
|
|
|
6638
6648
|
// src/widget/advance/table/table-view/controller.ts
|
|
6639
|
-
import { useEffect as
|
|
6649
|
+
import { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef5, useState as useState14 } from "react";
|
|
6650
|
+
import {
|
|
6651
|
+
useAppSelector as useAppSelector5,
|
|
6652
|
+
selectSearch as selectSearch4,
|
|
6653
|
+
selectList as selectList3
|
|
6654
|
+
} from "@fctc/interface-logic/store";
|
|
6640
6655
|
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
6641
6656
|
var tableController = ({ data }) => {
|
|
6642
|
-
const [rows, setRows] = useState14(
|
|
6643
|
-
const [columns, setColumns] = useState14(
|
|
6644
|
-
const dataModelFields = data
|
|
6657
|
+
const [rows, setRows] = useState14(data.records || []);
|
|
6658
|
+
const [columns, setColumns] = useState14([]);
|
|
6659
|
+
const dataModelFields = data.fields?.map((field) => {
|
|
6645
6660
|
return {
|
|
6646
6661
|
...data.dataModel?.[field?.name],
|
|
6647
6662
|
...field,
|
|
@@ -6668,8 +6683,8 @@ var tableController = ({ data }) => {
|
|
|
6668
6683
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6669
6684
|
});
|
|
6670
6685
|
};
|
|
6671
|
-
|
|
6672
|
-
setRows(transformData(data.records));
|
|
6686
|
+
useEffect13(() => {
|
|
6687
|
+
setRows(transformData(data.records || null));
|
|
6673
6688
|
}, [data.records]);
|
|
6674
6689
|
const handleGetColumns = () => {
|
|
6675
6690
|
let cols = [];
|
|
@@ -6689,11 +6704,10 @@ var tableController = ({ data }) => {
|
|
|
6689
6704
|
}
|
|
6690
6705
|
return cols;
|
|
6691
6706
|
};
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
}, [data]);
|
|
6707
|
+
useEffect13(() => {
|
|
6708
|
+
const columns2 = handleGetColumns();
|
|
6709
|
+
setColumns(columns2);
|
|
6710
|
+
}, [data.records]);
|
|
6697
6711
|
const onToggleColumnOptional = (item) => {
|
|
6698
6712
|
const tempColumn = [...columns]?.map((val) => {
|
|
6699
6713
|
if (item?.name === val?.name) {
|
|
@@ -6706,14 +6720,6 @@ var tableController = ({ data }) => {
|
|
|
6706
6720
|
});
|
|
6707
6721
|
setColumns(tempColumn);
|
|
6708
6722
|
};
|
|
6709
|
-
useEffect14(() => {
|
|
6710
|
-
setRows(null);
|
|
6711
|
-
setColumns(null);
|
|
6712
|
-
return () => {
|
|
6713
|
-
setRows(null);
|
|
6714
|
-
setColumns(null);
|
|
6715
|
-
};
|
|
6716
|
-
}, [data?.fields]);
|
|
6717
6723
|
return {
|
|
6718
6724
|
rows,
|
|
6719
6725
|
columns,
|
|
@@ -6723,35 +6729,57 @@ var tableController = ({ data }) => {
|
|
|
6723
6729
|
};
|
|
6724
6730
|
|
|
6725
6731
|
// src/widget/advance/table/table-group/controller.ts
|
|
6726
|
-
import { useEffect as
|
|
6732
|
+
import { useEffect as useEffect14, useMemo as useMemo13, useState as useState15 } from "react";
|
|
6727
6733
|
import {
|
|
6728
|
-
|
|
6729
|
-
|
|
6734
|
+
useOdooDataTransform,
|
|
6735
|
+
useGetListData as useGetListData2
|
|
6736
|
+
} from "@fctc/interface-logic/hooks";
|
|
6737
|
+
import {
|
|
6738
|
+
useAppSelector as useAppSelector6,
|
|
6739
|
+
selectSearch as selectSearch5,
|
|
6740
|
+
selectList as selectList4,
|
|
6741
|
+
useAppDispatch as useAppDispatch6,
|
|
6742
|
+
setSelectedRowKeys as setSelectedRowKeys2
|
|
6730
6743
|
} from "@fctc/interface-logic/store";
|
|
6744
|
+
|
|
6745
|
+
// src/environment.ts
|
|
6746
|
+
var environment_exports = {};
|
|
6747
|
+
__reExport(environment_exports, environment_star);
|
|
6748
|
+
import * as environment_star from "@fctc/interface-logic/environment";
|
|
6749
|
+
|
|
6750
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
6731
6751
|
var tableGroupController = (props) => {
|
|
6732
|
-
const
|
|
6733
|
-
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6752
|
+
const env = (0, environment_exports.getEnv)();
|
|
6734
6753
|
const {
|
|
6754
|
+
rows,
|
|
6735
6755
|
columns,
|
|
6756
|
+
indexRow,
|
|
6736
6757
|
row,
|
|
6737
6758
|
model,
|
|
6738
6759
|
viewData,
|
|
6760
|
+
renderField,
|
|
6739
6761
|
level,
|
|
6740
6762
|
specification,
|
|
6763
|
+
domain,
|
|
6741
6764
|
context,
|
|
6742
6765
|
checkedAll,
|
|
6743
|
-
|
|
6744
|
-
|
|
6766
|
+
isDisplayCheckbox,
|
|
6767
|
+
isAutoSelect,
|
|
6768
|
+
setIsAutoSelect,
|
|
6769
|
+
selectedRowKeysRef
|
|
6745
6770
|
} = props;
|
|
6746
6771
|
const [pageGroup, setPageGroup] = useState15(0);
|
|
6747
|
-
const {
|
|
6772
|
+
const { groupByDomain, selectedTags } = useAppSelector6(selectSearch5);
|
|
6773
|
+
const { selectedRowKeys } = useAppSelector6(selectList4);
|
|
6774
|
+
const appDispatch = useAppDispatch6();
|
|
6775
|
+
const { toDataJS } = useOdooDataTransform();
|
|
6776
|
+
const initVal = toDataJS(row, viewData, model);
|
|
6748
6777
|
const [isShowGroup, setIsShowGroup] = useState15(false);
|
|
6749
6778
|
const [colEmptyGroup, setColEmptyGroup] = useState15({
|
|
6750
6779
|
fromStart: 1,
|
|
6751
6780
|
fromEnd: 1
|
|
6752
6781
|
});
|
|
6753
|
-
const
|
|
6754
|
-
const processedData = useMemo12(() => {
|
|
6782
|
+
const processedData = useMemo13(() => {
|
|
6755
6783
|
const calculateColSpanEmpty = () => {
|
|
6756
6784
|
const startIndex = columns.findIndex(
|
|
6757
6785
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6766,7 +6794,7 @@ var tableGroupController = (props) => {
|
|
|
6766
6794
|
};
|
|
6767
6795
|
return calculateColSpanEmpty();
|
|
6768
6796
|
}, [columns, row]);
|
|
6769
|
-
const shouldFetchData =
|
|
6797
|
+
const shouldFetchData = useMemo13(() => {
|
|
6770
6798
|
return !!isShowGroup;
|
|
6771
6799
|
}, [isShowGroup]);
|
|
6772
6800
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6776,21 +6804,21 @@ var tableGroupController = (props) => {
|
|
|
6776
6804
|
domain,
|
|
6777
6805
|
context,
|
|
6778
6806
|
offset: pageGroup * 10,
|
|
6779
|
-
fields:
|
|
6780
|
-
groupby: [
|
|
6807
|
+
fields: groupByDomain?.fields,
|
|
6808
|
+
groupby: [groupByDomain?.contexts[level]?.group_by]
|
|
6781
6809
|
};
|
|
6782
6810
|
const queryKey = [
|
|
6783
|
-
`data-${model}
|
|
6811
|
+
`data-${model}--${level}-row${indexRow}`,
|
|
6784
6812
|
specification,
|
|
6785
6813
|
domain,
|
|
6786
6814
|
pageGroup
|
|
6787
6815
|
];
|
|
6788
6816
|
const {
|
|
6789
|
-
data:
|
|
6790
|
-
isFetched:
|
|
6817
|
+
data: dataResponse,
|
|
6818
|
+
isFetched: isQueryFetched,
|
|
6819
|
+
isPlaceholderData,
|
|
6791
6820
|
isLoading,
|
|
6792
|
-
isFetching
|
|
6793
|
-
isPlaceholderData: isDataPlaceHolder
|
|
6821
|
+
isFetching
|
|
6794
6822
|
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
6795
6823
|
const {
|
|
6796
6824
|
columns: columnsGroup,
|
|
@@ -6799,21 +6827,27 @@ var tableGroupController = (props) => {
|
|
|
6799
6827
|
} = tableController({
|
|
6800
6828
|
data: {
|
|
6801
6829
|
fields: viewData?.views?.list?.fields,
|
|
6802
|
-
records:
|
|
6830
|
+
records: dataResponse?.records ?? dataResponse?.groups,
|
|
6803
6831
|
dataModel: viewData?.models?.[model],
|
|
6804
6832
|
context: env.context,
|
|
6805
|
-
typeTable:
|
|
6833
|
+
typeTable: dataResponse?.groups ? "group" : "list"
|
|
6806
6834
|
}
|
|
6807
6835
|
});
|
|
6808
|
-
const
|
|
6836
|
+
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6837
|
+
useEffect14(() => {
|
|
6838
|
+
if (isShowGroup && selectedTags?.length > 0) {
|
|
6839
|
+
setIsShowGroup(false);
|
|
6840
|
+
}
|
|
6841
|
+
}, [selectedTags]);
|
|
6842
|
+
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
6809
6843
|
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(
|
|
6810
6844
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6811
6845
|
)?.[1] : row[group_by_field_name];
|
|
6812
6846
|
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`]})`;
|
|
6813
6847
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6814
|
-
const
|
|
6815
|
-
const onExpandChildGroup = () => {
|
|
6848
|
+
const handleExpandChildGroup = () => {
|
|
6816
6849
|
if (isLoading || isFetching) return;
|
|
6850
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6817
6851
|
if (allIdsNull || typeTableGroup === "group") {
|
|
6818
6852
|
toggleShowGroup();
|
|
6819
6853
|
return;
|
|
@@ -6823,39 +6857,53 @@ var tableGroupController = (props) => {
|
|
|
6823
6857
|
const filteredIds = selectedRowKeys.filter(
|
|
6824
6858
|
(id) => !ids.includes(id)
|
|
6825
6859
|
);
|
|
6826
|
-
|
|
6827
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
6860
|
+
appDispatch(setSelectedRowKeys2(filteredIds));
|
|
6861
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6828
6862
|
const clonedKeys = [...selectedRowKeys];
|
|
6829
|
-
|
|
6830
|
-
setTimeout(() =>
|
|
6863
|
+
appDispatch(setSelectedRowKeys2([...clonedKeys, -1]));
|
|
6864
|
+
setTimeout(() => appDispatch(setSelectedRowKeys2(clonedKeys)), 500);
|
|
6831
6865
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6832
|
-
console.log("abc");
|
|
6833
6866
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6834
|
-
|
|
6867
|
+
appDispatch(setSelectedRowKeys2(filteredKeys));
|
|
6835
6868
|
}
|
|
6836
6869
|
toggleShowGroup();
|
|
6837
6870
|
};
|
|
6838
|
-
|
|
6839
|
-
if (!
|
|
6871
|
+
useEffect14(() => {
|
|
6872
|
+
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6840
6873
|
return;
|
|
6841
6874
|
}
|
|
6842
6875
|
const clonedKeys = [...selectedRowKeys];
|
|
6843
|
-
|
|
6844
|
-
setTimeout(() =>
|
|
6845
|
-
}, [
|
|
6876
|
+
setSelectedRowKeys2([...clonedKeys, -1]);
|
|
6877
|
+
setTimeout(() => setSelectedRowKeys2(clonedKeys), 500);
|
|
6878
|
+
}, [isQueryFetched]);
|
|
6846
6879
|
return {
|
|
6847
|
-
|
|
6880
|
+
handleExpandChildGroup,
|
|
6848
6881
|
colEmptyGroup,
|
|
6882
|
+
leftPadding,
|
|
6849
6883
|
isShowGroup,
|
|
6850
|
-
|
|
6851
|
-
isDataPlaceHolder,
|
|
6884
|
+
isQueryFetched,
|
|
6852
6885
|
nameGroupWithCount,
|
|
6886
|
+
columns,
|
|
6887
|
+
row,
|
|
6888
|
+
isPlaceholderData,
|
|
6853
6889
|
columnsGroup,
|
|
6890
|
+
indexRow,
|
|
6854
6891
|
rowsGroup,
|
|
6855
|
-
|
|
6892
|
+
model,
|
|
6893
|
+
viewData,
|
|
6894
|
+
renderField,
|
|
6895
|
+
level,
|
|
6896
|
+
specification,
|
|
6897
|
+
context,
|
|
6898
|
+
checkedAll,
|
|
6899
|
+
isDisplayCheckbox,
|
|
6900
|
+
isAutoSelect,
|
|
6901
|
+
setIsAutoSelect,
|
|
6902
|
+
selectedRowKeysRef,
|
|
6903
|
+
initVal,
|
|
6904
|
+
dataResponse,
|
|
6856
6905
|
pageGroup,
|
|
6857
|
-
setPageGroup
|
|
6858
|
-
typeTableGroup
|
|
6906
|
+
setPageGroup
|
|
6859
6907
|
};
|
|
6860
6908
|
};
|
|
6861
6909
|
|
|
@@ -6868,7 +6916,7 @@ import {
|
|
|
6868
6916
|
evalJSONDomain as evalJSONDomain7,
|
|
6869
6917
|
validateAndParseDate
|
|
6870
6918
|
} from "@fctc/interface-logic/utils";
|
|
6871
|
-
import { useCallback as
|
|
6919
|
+
import { useCallback as useCallback3, useEffect as useEffect15, useState as useState16 } from "react";
|
|
6872
6920
|
var searchController = ({
|
|
6873
6921
|
viewData,
|
|
6874
6922
|
model,
|
|
@@ -6929,7 +6977,7 @@ var searchController = ({
|
|
|
6929
6977
|
}
|
|
6930
6978
|
}
|
|
6931
6979
|
};
|
|
6932
|
-
|
|
6980
|
+
useEffect15(() => {
|
|
6933
6981
|
fetchData();
|
|
6934
6982
|
}, [model, viewData]);
|
|
6935
6983
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7011,7 +7059,7 @@ var searchController = ({
|
|
|
7011
7059
|
return [...domain2];
|
|
7012
7060
|
}
|
|
7013
7061
|
};
|
|
7014
|
-
const setTagSearch =
|
|
7062
|
+
const setTagSearch = useCallback3(
|
|
7015
7063
|
(updatedMap) => {
|
|
7016
7064
|
if (!updatedMap) return;
|
|
7017
7065
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7074,7 +7122,7 @@ var searchController = ({
|
|
|
7074
7122
|
},
|
|
7075
7123
|
[searchMap]
|
|
7076
7124
|
);
|
|
7077
|
-
|
|
7125
|
+
useEffect15(() => {
|
|
7078
7126
|
setTagSearch(searchMap);
|
|
7079
7127
|
}, [searchMap]);
|
|
7080
7128
|
const handleAddTagSearch = (tag) => {
|