@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.mjs
CHANGED
|
@@ -4087,6 +4087,7 @@ __export(index_exports, {
|
|
|
4087
4087
|
useMenu: () => useMenu,
|
|
4088
4088
|
useMenuItem: () => useMenuItem,
|
|
4089
4089
|
useProfile: () => useProfile,
|
|
4090
|
+
useSelectionState: () => useSelectionState,
|
|
4090
4091
|
useStorageState: () => useStorageState,
|
|
4091
4092
|
useUser: () => useUser,
|
|
4092
4093
|
useViewV2: () => useViewV2
|
|
@@ -4103,7 +4104,6 @@ __export(hooks_exports, {
|
|
|
4103
4104
|
useConfig: () => useConfig,
|
|
4104
4105
|
useDebounce: () => useDebounce,
|
|
4105
4106
|
useDetail: () => useDetail,
|
|
4106
|
-
useGetRowIds: () => useGetRowIds,
|
|
4107
4107
|
useListData: () => useListData,
|
|
4108
4108
|
useMenu: () => useMenu,
|
|
4109
4109
|
useMenuItem: () => useMenuItem,
|
|
@@ -4227,10 +4227,24 @@ var useDetail = (accessToken, sub) => {
|
|
|
4227
4227
|
};
|
|
4228
4228
|
|
|
4229
4229
|
// src/hooks/core/use-list-data.ts
|
|
4230
|
-
import { useMemo as
|
|
4230
|
+
import { useMemo as useMemo3, useState as useState3 } from "react";
|
|
4231
|
+
|
|
4232
|
+
// src/utils/function.ts
|
|
4233
|
+
import {
|
|
4234
|
+
useCallback,
|
|
4235
|
+
useEffect as useEffect3,
|
|
4236
|
+
useMemo as useMemo2,
|
|
4237
|
+
useReducer,
|
|
4238
|
+
useRef,
|
|
4239
|
+
useState as useState2
|
|
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";
|
|
4231
4246
|
|
|
4232
4247
|
// src/utils/function.ts
|
|
4233
|
-
import { useCallback, useEffect as useEffect3, useReducer } from "react";
|
|
4234
4248
|
var countSum = (data, field) => {
|
|
4235
4249
|
if (!data || !field) return 0;
|
|
4236
4250
|
return data.reduce(
|
|
@@ -4249,6 +4263,91 @@ function mergeButtons(fields) {
|
|
|
4249
4263
|
}
|
|
4250
4264
|
return others;
|
|
4251
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] = useState2([]);
|
|
4282
|
+
const lastRowIdsRef = useRef([]);
|
|
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
|
+
useEffect3(() => {
|
|
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 = useRef(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
|
+
};
|
|
4252
4351
|
var getDateRange = (currentDate, unit) => {
|
|
4253
4352
|
const date = new Date(currentDate);
|
|
4254
4353
|
let dateStart, dateEnd;
|
|
@@ -4390,9 +4489,9 @@ function useStorageState(key) {
|
|
|
4390
4489
|
// src/hooks/core/use-list-data.ts
|
|
4391
4490
|
import { useModel, useGetListData } from "@fctc/interface-logic/hooks";
|
|
4392
4491
|
import {
|
|
4393
|
-
useAppSelector,
|
|
4394
|
-
selectSearch,
|
|
4395
|
-
selectList
|
|
4492
|
+
useAppSelector as useAppSelector2,
|
|
4493
|
+
selectSearch as selectSearch2,
|
|
4494
|
+
selectList as selectList2
|
|
4396
4495
|
} from "@fctc/interface-logic/store";
|
|
4397
4496
|
import {
|
|
4398
4497
|
evalJSONDomain,
|
|
@@ -4403,13 +4502,13 @@ var useListData = ({
|
|
|
4403
4502
|
context,
|
|
4404
4503
|
viewResponse
|
|
4405
4504
|
}) => {
|
|
4406
|
-
const { groupByDomain } =
|
|
4505
|
+
const { groupByDomain } = useAppSelector2(selectSearch2);
|
|
4407
4506
|
const initModel = useModel();
|
|
4408
|
-
const [type, setType] =
|
|
4409
|
-
const [mode, setMode] =
|
|
4410
|
-
const [currentDate, setCurrentDate] =
|
|
4411
|
-
const { pageLimit, page, order } =
|
|
4412
|
-
const listDataProps =
|
|
4507
|
+
const [type, setType] = useState3("list");
|
|
4508
|
+
const [mode, setMode] = useState3("month");
|
|
4509
|
+
const [currentDate, setCurrentDate] = useState3(/* @__PURE__ */ new Date());
|
|
4510
|
+
const { pageLimit, page, order } = useAppSelector2(selectList2);
|
|
4511
|
+
const listDataProps = useMemo3(() => {
|
|
4413
4512
|
const actData = action?.result;
|
|
4414
4513
|
if (!viewResponse || !actData || !context) {
|
|
4415
4514
|
return null;
|
|
@@ -4470,7 +4569,7 @@ var useListData = ({
|
|
|
4470
4569
|
};
|
|
4471
4570
|
|
|
4472
4571
|
// src/hooks/core/use-menu.ts
|
|
4473
|
-
import { useEffect as useEffect4, useMemo as
|
|
4572
|
+
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState4 } from "react";
|
|
4474
4573
|
|
|
4475
4574
|
// src/utils/constants.ts
|
|
4476
4575
|
var languages = [
|
|
@@ -4490,9 +4589,9 @@ var API_APP_URL = {
|
|
|
4490
4589
|
import { useGetMenu } from "@fctc/interface-logic/hooks";
|
|
4491
4590
|
var useMenu = ({ context }) => {
|
|
4492
4591
|
const menuData = useGetMenu(context, !!context);
|
|
4493
|
-
const [menuid, setMenuId] =
|
|
4592
|
+
const [menuid, setMenuId] = useState4(void 0);
|
|
4494
4593
|
const [action, setAction] = useCallAction();
|
|
4495
|
-
const configedIconData =
|
|
4594
|
+
const configedIconData = useMemo4(() => {
|
|
4496
4595
|
const data = menuData.data;
|
|
4497
4596
|
return data?.map((item) => {
|
|
4498
4597
|
return {
|
|
@@ -4539,7 +4638,7 @@ var useMenu = ({ context }) => {
|
|
|
4539
4638
|
|
|
4540
4639
|
// src/hooks/core/use-profile.ts
|
|
4541
4640
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
4542
|
-
import { useEffect as useEffect5, useMemo as
|
|
4641
|
+
import { useEffect as useEffect5, useMemo as useMemo5 } from "react";
|
|
4543
4642
|
import { useTranslation } from "react-i18next";
|
|
4544
4643
|
import { getEnv as getEnv3 } from "@fctc/interface-logic/environment";
|
|
4545
4644
|
import { useGetProfile } from "@fctc/interface-logic/hooks";
|
|
@@ -4567,7 +4666,7 @@ var useProfile = (accessToken) => {
|
|
|
4567
4666
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
4568
4667
|
}
|
|
4569
4668
|
}, [dispatch, userInfoQuery.data]);
|
|
4570
|
-
const context =
|
|
4669
|
+
const context = useMemo5(() => {
|
|
4571
4670
|
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
4572
4671
|
return {
|
|
4573
4672
|
uid: Number(userInfoQuery.data.sub),
|
|
@@ -4589,13 +4688,13 @@ var useUser = (accessToken) => {
|
|
|
4589
4688
|
};
|
|
4590
4689
|
|
|
4591
4690
|
// src/hooks/core/use-view-v2.ts
|
|
4592
|
-
import { useMemo as
|
|
4691
|
+
import { useMemo as useMemo6 } from "react";
|
|
4593
4692
|
import { useGetView } from "@fctc/interface-logic/hooks";
|
|
4594
4693
|
var useViewV2 = ({
|
|
4595
4694
|
action,
|
|
4596
4695
|
context
|
|
4597
4696
|
}) => {
|
|
4598
|
-
const viewParams =
|
|
4697
|
+
const viewParams = useMemo6(() => {
|
|
4599
4698
|
if (!action?.result) {
|
|
4600
4699
|
return void 0;
|
|
4601
4700
|
}
|
|
@@ -4670,11 +4769,11 @@ var useAuth = () => {
|
|
|
4670
4769
|
};
|
|
4671
4770
|
|
|
4672
4771
|
// src/hooks/core/use-app-provider.tsx
|
|
4673
|
-
import { createContext, useContext, useMemo as
|
|
4772
|
+
import { createContext, useContext, useMemo as useMemo8 } from "react";
|
|
4674
4773
|
|
|
4675
4774
|
// src/hooks/core/use-company.ts
|
|
4676
4775
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
4677
|
-
import { useEffect as useEffect6, useMemo as
|
|
4776
|
+
import { useEffect as useEffect6, useMemo as useMemo7 } from "react";
|
|
4678
4777
|
import { getEnv as getEnv4 } from "@fctc/interface-logic/environment";
|
|
4679
4778
|
import {
|
|
4680
4779
|
useGetCurrentCompany,
|
|
@@ -4690,7 +4789,7 @@ var useCompany = (accessToken) => {
|
|
|
4690
4789
|
queryFn: fetchCurrentCompany,
|
|
4691
4790
|
enabled: !!accessToken
|
|
4692
4791
|
});
|
|
4693
|
-
const current_company_id =
|
|
4792
|
+
const current_company_id = useMemo7(() => {
|
|
4694
4793
|
return currentCompany.data?.current_company_id;
|
|
4695
4794
|
}, [currentCompany.data]);
|
|
4696
4795
|
useEffect6(() => {
|
|
@@ -4743,14 +4842,14 @@ var AppProvider = ({ children }) => {
|
|
|
4743
4842
|
const auth = useAuth();
|
|
4744
4843
|
const user = useUser(auth.accessToken);
|
|
4745
4844
|
const company = use_company_default(auth.accessToken);
|
|
4746
|
-
const menuContext =
|
|
4845
|
+
const menuContext = useMemo8(() => {
|
|
4747
4846
|
return combineContexts([user.context, company.context]);
|
|
4748
4847
|
}, [user.context, company.context]);
|
|
4749
4848
|
const menu = useMenu({ context: menuContext });
|
|
4750
|
-
const action =
|
|
4849
|
+
const action = useMemo8(() => {
|
|
4751
4850
|
return menu.state.action;
|
|
4752
4851
|
}, [menu.state.action]);
|
|
4753
|
-
const viewContext =
|
|
4852
|
+
const viewContext = useMemo8(() => {
|
|
4754
4853
|
return combineContexts([
|
|
4755
4854
|
menuContext,
|
|
4756
4855
|
{ ...evalJSONContext(action?.result?.context) }
|
|
@@ -4793,7 +4892,7 @@ var useAppProvider = () => {
|
|
|
4793
4892
|
// src/hooks/core/use-menu-item.tsx
|
|
4794
4893
|
import { getEnv as getEnv5 } from "@fctc/interface-logic/environment";
|
|
4795
4894
|
import { useGetActionDetail } from "@fctc/interface-logic/hooks";
|
|
4796
|
-
import { useState as
|
|
4895
|
+
import { useState as useState5 } from "react";
|
|
4797
4896
|
|
|
4798
4897
|
// src/utils.ts
|
|
4799
4898
|
var utils_exports = {};
|
|
@@ -4808,6 +4907,8 @@ __export(utils_exports, {
|
|
|
4808
4907
|
languages: () => languages,
|
|
4809
4908
|
mergeButtons: () => mergeButtons,
|
|
4810
4909
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4910
|
+
useGetRowIds: () => useGetRowIds,
|
|
4911
|
+
useSelectionState: () => useSelectionState,
|
|
4811
4912
|
useStorageState: () => useStorageState
|
|
4812
4913
|
});
|
|
4813
4914
|
__reExport(utils_exports, utils_star);
|
|
@@ -4828,7 +4929,7 @@ var useMenuItem = (props) => {
|
|
|
4828
4929
|
enabled: true,
|
|
4829
4930
|
queryKey: [`action-${aid}`]
|
|
4830
4931
|
}).data;
|
|
4831
|
-
const [path, setPath] =
|
|
4932
|
+
const [path, setPath] = useState5("");
|
|
4832
4933
|
const handleClick = () => {
|
|
4833
4934
|
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4834
4935
|
return;
|
|
@@ -4850,74 +4951,8 @@ var useMenuItem = (props) => {
|
|
|
4850
4951
|
return { handleClick, path, queryActionDetail };
|
|
4851
4952
|
};
|
|
4852
4953
|
|
|
4853
|
-
// src/hooks/core/use-get-rowids.ts
|
|
4854
|
-
import { useCallback as useCallback2, useEffect as useEffect7, useRef, useState as useState5 } from "react";
|
|
4855
|
-
var useGetRowIds = (tableRef) => {
|
|
4856
|
-
function isElementVisible(el) {
|
|
4857
|
-
const style = window.getComputedStyle(el);
|
|
4858
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4859
|
-
}
|
|
4860
|
-
function arraysAreEqual(a, b) {
|
|
4861
|
-
if (a.length !== b.length) return false;
|
|
4862
|
-
if (a.length === 0 && b.length === 0) return true;
|
|
4863
|
-
const setA = new Set(a);
|
|
4864
|
-
const setB = new Set(b);
|
|
4865
|
-
if (setA.size !== setB.size) return false;
|
|
4866
|
-
for (const val of setA) {
|
|
4867
|
-
if (!setB.has(val)) return false;
|
|
4868
|
-
}
|
|
4869
|
-
return true;
|
|
4870
|
-
}
|
|
4871
|
-
const [rowIds, setRowIds] = useState5([]);
|
|
4872
|
-
const lastRowIdsRef = useRef([]);
|
|
4873
|
-
const updateVisibleRowIds = useCallback2(() => {
|
|
4874
|
-
const table = tableRef.current;
|
|
4875
|
-
if (!table) return;
|
|
4876
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4877
|
-
const ids = [];
|
|
4878
|
-
rows.forEach((row) => {
|
|
4879
|
-
const el = row;
|
|
4880
|
-
if (isElementVisible(el)) {
|
|
4881
|
-
const id = el.getAttribute("data-row-id");
|
|
4882
|
-
if (id) ids.push(id);
|
|
4883
|
-
}
|
|
4884
|
-
});
|
|
4885
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4886
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4887
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4888
|
-
setRowIds(uniqueIds);
|
|
4889
|
-
}
|
|
4890
|
-
}, [tableRef]);
|
|
4891
|
-
useEffect7(() => {
|
|
4892
|
-
const table = tableRef.current;
|
|
4893
|
-
if (!table) return;
|
|
4894
|
-
const mutationObserver = new MutationObserver(() => {
|
|
4895
|
-
updateVisibleRowIds();
|
|
4896
|
-
});
|
|
4897
|
-
mutationObserver.observe(table, {
|
|
4898
|
-
childList: true,
|
|
4899
|
-
subtree: true,
|
|
4900
|
-
attributes: true,
|
|
4901
|
-
attributeFilter: ["style", "class"]
|
|
4902
|
-
});
|
|
4903
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
4904
|
-
updateVisibleRowIds();
|
|
4905
|
-
});
|
|
4906
|
-
resizeObserver.observe(table);
|
|
4907
|
-
const handleScroll = () => updateVisibleRowIds();
|
|
4908
|
-
table.addEventListener("scroll", handleScroll, true);
|
|
4909
|
-
updateVisibleRowIds();
|
|
4910
|
-
return () => {
|
|
4911
|
-
mutationObserver.disconnect();
|
|
4912
|
-
resizeObserver.disconnect();
|
|
4913
|
-
table.removeEventListener("scroll", handleScroll, true);
|
|
4914
|
-
};
|
|
4915
|
-
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4916
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4917
|
-
};
|
|
4918
|
-
|
|
4919
4954
|
// src/hooks/utils/use-click-outside.ts
|
|
4920
|
-
import { useEffect as
|
|
4955
|
+
import { useEffect as useEffect7, useRef as useRef2 } from "react";
|
|
4921
4956
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4922
4957
|
var useClickOutside = ({
|
|
4923
4958
|
handler,
|
|
@@ -4926,7 +4961,7 @@ var useClickOutside = ({
|
|
|
4926
4961
|
refs
|
|
4927
4962
|
}) => {
|
|
4928
4963
|
const ref = useRef2(null);
|
|
4929
|
-
|
|
4964
|
+
useEffect7(() => {
|
|
4930
4965
|
const listener = (event) => {
|
|
4931
4966
|
const { target } = event;
|
|
4932
4967
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4948,10 +4983,10 @@ var useClickOutside = ({
|
|
|
4948
4983
|
};
|
|
4949
4984
|
|
|
4950
4985
|
// src/hooks/utils/use-debounce.ts
|
|
4951
|
-
import { useEffect as
|
|
4986
|
+
import { useEffect as useEffect8, useState as useState6 } from "react";
|
|
4952
4987
|
function useDebounce(value, delay) {
|
|
4953
4988
|
const [debouncedValue, setDebouncedValue] = useState6(value);
|
|
4954
|
-
|
|
4989
|
+
useEffect8(() => {
|
|
4955
4990
|
const handler = setTimeout(() => {
|
|
4956
4991
|
setDebouncedValue(value);
|
|
4957
4992
|
}, delay);
|
|
@@ -5208,7 +5243,7 @@ var ChevronBottomIcon = ({
|
|
|
5208
5243
|
};
|
|
5209
5244
|
|
|
5210
5245
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
5211
|
-
import { useEffect as
|
|
5246
|
+
import { useEffect as useEffect9, useRef as useRef3, useState as useState7 } from "react";
|
|
5212
5247
|
import { getEnv as getEnv6 } from "@fctc/interface-logic/environment";
|
|
5213
5248
|
import { useSave } from "@fctc/interface-logic/hooks";
|
|
5214
5249
|
var statusDropdownController = (props) => {
|
|
@@ -5221,7 +5256,7 @@ var statusDropdownController = (props) => {
|
|
|
5221
5256
|
};
|
|
5222
5257
|
const [isOpen, setIsOpen] = useState7(false);
|
|
5223
5258
|
const buttonRef = useRef3(null);
|
|
5224
|
-
|
|
5259
|
+
useEffect9(() => {
|
|
5225
5260
|
const handleClickOutside = (event) => {
|
|
5226
5261
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
5227
5262
|
setIsOpen(false);
|
|
@@ -5262,12 +5297,7 @@ var statusDropdownController = (props) => {
|
|
|
5262
5297
|
};
|
|
5263
5298
|
|
|
5264
5299
|
// src/widget/basic/many2one-field/controller.ts
|
|
5265
|
-
import { useCallback as
|
|
5266
|
-
|
|
5267
|
-
// src/store.ts
|
|
5268
|
-
var store_exports = {};
|
|
5269
|
-
__reExport(store_exports, store_star);
|
|
5270
|
-
import * as store_star from "@fctc/interface-logic/store";
|
|
5300
|
+
import { useCallback as useCallback2, useEffect as useEffect10, useMemo as useMemo9, useState as useState8 } from "react";
|
|
5271
5301
|
|
|
5272
5302
|
// src/provider.ts
|
|
5273
5303
|
var provider_exports = {};
|
|
@@ -5327,18 +5357,18 @@ var many2oneFieldController = (props) => {
|
|
|
5327
5357
|
queryKey,
|
|
5328
5358
|
enabled: false
|
|
5329
5359
|
});
|
|
5330
|
-
const selectOptions =
|
|
5360
|
+
const selectOptions = useMemo9(() => {
|
|
5331
5361
|
return dataOfSelection?.records?.map((val) => ({
|
|
5332
5362
|
value: val?.id,
|
|
5333
5363
|
label: val?.display_name || val?.name
|
|
5334
5364
|
})) || [];
|
|
5335
5365
|
}, [dataOfSelection]);
|
|
5336
|
-
|
|
5366
|
+
useEffect10(() => {
|
|
5337
5367
|
setOptions(selectOptions);
|
|
5338
5368
|
setDomainModal(domainObject);
|
|
5339
5369
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5340
5370
|
}, [selectOptions]);
|
|
5341
|
-
|
|
5371
|
+
useEffect10(() => {
|
|
5342
5372
|
setDomainObject(
|
|
5343
5373
|
(0, utils_exports.evalJSONDomain)(
|
|
5344
5374
|
domain,
|
|
@@ -5346,7 +5376,7 @@ var many2oneFieldController = (props) => {
|
|
|
5346
5376
|
)
|
|
5347
5377
|
);
|
|
5348
5378
|
}, [domain, formValues]);
|
|
5349
|
-
|
|
5379
|
+
useEffect10(() => {
|
|
5350
5380
|
if (!propValue && tempSelectedOption) {
|
|
5351
5381
|
methods.setValue(name, null);
|
|
5352
5382
|
setTempSelectedOption(null);
|
|
@@ -5357,10 +5387,10 @@ var many2oneFieldController = (props) => {
|
|
|
5357
5387
|
});
|
|
5358
5388
|
}
|
|
5359
5389
|
}, [propValue]);
|
|
5360
|
-
const fetchMoreOptions =
|
|
5390
|
+
const fetchMoreOptions = useCallback2(() => {
|
|
5361
5391
|
refetch();
|
|
5362
5392
|
}, [refetch]);
|
|
5363
|
-
|
|
5393
|
+
useEffect10(() => {
|
|
5364
5394
|
if (debouncedInputValue) {
|
|
5365
5395
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5366
5396
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5375,7 +5405,7 @@ var many2oneFieldController = (props) => {
|
|
|
5375
5405
|
}, 50);
|
|
5376
5406
|
}
|
|
5377
5407
|
}, [debouncedInputValue]);
|
|
5378
|
-
const handleChooseRecord =
|
|
5408
|
+
const handleChooseRecord = useCallback2(
|
|
5379
5409
|
(idRecord) => {
|
|
5380
5410
|
const newOption = options.find(
|
|
5381
5411
|
(option) => option.value === idRecord
|
|
@@ -5400,8 +5430,8 @@ var many2oneFieldController = (props) => {
|
|
|
5400
5430
|
},
|
|
5401
5431
|
[options, methods, name, onChange]
|
|
5402
5432
|
);
|
|
5403
|
-
const handleClose =
|
|
5404
|
-
const handleSelectChange =
|
|
5433
|
+
const handleClose = useCallback2(() => setIsShowModalMany2Many(false), []);
|
|
5434
|
+
const handleSelectChange = useCallback2(
|
|
5405
5435
|
(selectedOption) => {
|
|
5406
5436
|
if (!selectedOption) {
|
|
5407
5437
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5475,7 +5505,7 @@ var many2oneButtonController = (props) => {
|
|
|
5475
5505
|
};
|
|
5476
5506
|
|
|
5477
5507
|
// src/widget/basic/many2many-field/controller.ts
|
|
5478
|
-
import { useEffect as
|
|
5508
|
+
import { useEffect as useEffect11, useMemo as useMemo10, useState as useState9 } from "react";
|
|
5479
5509
|
import {
|
|
5480
5510
|
evalJSONContext as evalJSONContext4,
|
|
5481
5511
|
evalJSONDomain as evalJSONDomain4,
|
|
@@ -5494,7 +5524,7 @@ var many2manyFieldController = (props) => {
|
|
|
5494
5524
|
actionData
|
|
5495
5525
|
} = props;
|
|
5496
5526
|
const { env } = (0, provider_exports.useEnv)();
|
|
5497
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5527
|
+
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5498
5528
|
const [order, setOrder] = useState9();
|
|
5499
5529
|
const [page, setPage] = useState9(0);
|
|
5500
5530
|
const [domainMany2Many, setDomainMany2Many] = useState9(null);
|
|
@@ -5512,7 +5542,7 @@ var many2manyFieldController = (props) => {
|
|
|
5512
5542
|
context: contextObject
|
|
5513
5543
|
};
|
|
5514
5544
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5515
|
-
const baseModel =
|
|
5545
|
+
const baseModel = useMemo10(
|
|
5516
5546
|
() => ({
|
|
5517
5547
|
name: String(relation),
|
|
5518
5548
|
view: viewResponse || {},
|
|
@@ -5525,13 +5555,13 @@ var many2manyFieldController = (props) => {
|
|
|
5525
5555
|
[relation, viewResponse]
|
|
5526
5556
|
);
|
|
5527
5557
|
const initModel = (0, hooks_exports.useModel)();
|
|
5528
|
-
const modelInstance =
|
|
5558
|
+
const modelInstance = useMemo10(() => {
|
|
5529
5559
|
if (viewResponse) {
|
|
5530
5560
|
return initModel.initModel(baseModel);
|
|
5531
5561
|
}
|
|
5532
5562
|
return null;
|
|
5533
5563
|
}, [baseModel, viewResponse]);
|
|
5534
|
-
const specification =
|
|
5564
|
+
const specification = useMemo10(() => {
|
|
5535
5565
|
if (modelInstance) {
|
|
5536
5566
|
return modelInstance.getSpecification();
|
|
5537
5567
|
}
|
|
@@ -5573,8 +5603,8 @@ var many2manyFieldController = (props) => {
|
|
|
5573
5603
|
isLoading,
|
|
5574
5604
|
isFetched,
|
|
5575
5605
|
isPlaceholderData
|
|
5576
|
-
} =
|
|
5577
|
-
|
|
5606
|
+
} = useGetListData3(data, queryKey, enabled);
|
|
5607
|
+
useEffect11(() => {
|
|
5578
5608
|
if (viewResponse) {
|
|
5579
5609
|
fetchData();
|
|
5580
5610
|
}
|
|
@@ -5627,7 +5657,7 @@ var many2manyFieldController = (props) => {
|
|
|
5627
5657
|
};
|
|
5628
5658
|
|
|
5629
5659
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5630
|
-
import { useMemo as
|
|
5660
|
+
import { useMemo as useMemo11 } from "react";
|
|
5631
5661
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5632
5662
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
5633
5663
|
var many2manyTagsController = (props) => {
|
|
@@ -5643,7 +5673,7 @@ var many2manyTagsController = (props) => {
|
|
|
5643
5673
|
const { env } = (0, provider_exports.useEnv)();
|
|
5644
5674
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5645
5675
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
5646
|
-
const domainObject =
|
|
5676
|
+
const domainObject = useMemo11(
|
|
5647
5677
|
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5648
5678
|
[domain, formValues]
|
|
5649
5679
|
);
|
|
@@ -5694,7 +5724,7 @@ var durationController = (props) => {
|
|
|
5694
5724
|
name: "",
|
|
5695
5725
|
fold: ""
|
|
5696
5726
|
};
|
|
5697
|
-
const { useGetListData:
|
|
5727
|
+
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5698
5728
|
const { env } = (0, provider_exports.useEnv)();
|
|
5699
5729
|
const [disabled, setDisabled] = useState10(false);
|
|
5700
5730
|
const [modelStatus, setModalStatus] = useState10(false);
|
|
@@ -5712,7 +5742,7 @@ var durationController = (props) => {
|
|
|
5712
5742
|
},
|
|
5713
5743
|
sort: ""
|
|
5714
5744
|
};
|
|
5715
|
-
const { data: dataResponse } =
|
|
5745
|
+
const { data: dataResponse } = useGetListData3(
|
|
5716
5746
|
listDataProps,
|
|
5717
5747
|
queryKey,
|
|
5718
5748
|
enabled
|
|
@@ -6774,7 +6804,7 @@ var colorFieldController = (props) => {
|
|
|
6774
6804
|
};
|
|
6775
6805
|
|
|
6776
6806
|
// src/widget/basic/binary-field/controller.ts
|
|
6777
|
-
import { useEffect as
|
|
6807
|
+
import { useEffect as useEffect12, useId as useId2, useRef as useRef4, useState as useState13 } from "react";
|
|
6778
6808
|
import { isBase64Image } from "@fctc/interface-logic/utils";
|
|
6779
6809
|
var binaryFieldController = (props) => {
|
|
6780
6810
|
const { name, methods, readonly = false, value } = props;
|
|
@@ -6845,14 +6875,14 @@ var binaryFieldController = (props) => {
|
|
|
6845
6875
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6846
6876
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6847
6877
|
};
|
|
6848
|
-
|
|
6878
|
+
useEffect12(() => {
|
|
6849
6879
|
return () => {
|
|
6850
6880
|
if (selectedImage) {
|
|
6851
6881
|
URL.revokeObjectURL(selectedImage);
|
|
6852
6882
|
}
|
|
6853
6883
|
};
|
|
6854
6884
|
}, [selectedImage]);
|
|
6855
|
-
|
|
6885
|
+
useEffect12(() => {
|
|
6856
6886
|
if (binaryRef.current) {
|
|
6857
6887
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6858
6888
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6872,33 +6902,16 @@ var binaryFieldController = (props) => {
|
|
|
6872
6902
|
};
|
|
6873
6903
|
|
|
6874
6904
|
// src/widget/advance/table/table-head/controller.ts
|
|
6875
|
-
import {
|
|
6876
|
-
|
|
6905
|
+
import {
|
|
6906
|
+
useAppDispatch as useAppDispatch5,
|
|
6907
|
+
useAppSelector as useAppSelector4,
|
|
6908
|
+
selectSearch as selectSearch3,
|
|
6909
|
+
setSelectedRowKeys
|
|
6910
|
+
} from "@fctc/interface-logic/store";
|
|
6877
6911
|
var tableHeadController = (props) => {
|
|
6878
|
-
const { typeTable, rows,
|
|
6912
|
+
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6879
6913
|
const appDispatch = useAppDispatch5();
|
|
6880
|
-
const {
|
|
6881
|
-
const selectedRowKeysRef = useRef5(recordIds);
|
|
6882
|
-
const isGroupTable = typeTable === "group";
|
|
6883
|
-
const recordsCheckedGroup = useMemo11(() => {
|
|
6884
|
-
if (!rows || !groupByList) return 0;
|
|
6885
|
-
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6886
|
-
return countSum(rows, groupBy);
|
|
6887
|
-
}, [rows, groupByList]);
|
|
6888
|
-
const isAllGroupChecked = useMemo11(() => {
|
|
6889
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6890
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6891
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6892
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6893
|
-
return allGroupsSelected || allRecordsSelected;
|
|
6894
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6895
|
-
const isAllNormalChecked = useMemo11(() => {
|
|
6896
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6897
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6898
|
-
(id) => rows.some((record) => record.id === id)
|
|
6899
|
-
);
|
|
6900
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6901
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6914
|
+
const { groupByDomain } = useAppSelector4(selectSearch3);
|
|
6902
6915
|
const handleCheckBoxAll = (event) => {
|
|
6903
6916
|
if (event?.target?.checked && typeTable === "list") {
|
|
6904
6917
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
@@ -6913,7 +6926,7 @@ var tableHeadController = (props) => {
|
|
|
6913
6926
|
} else {
|
|
6914
6927
|
const sum = countSum(
|
|
6915
6928
|
rows,
|
|
6916
|
-
typeof
|
|
6929
|
+
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6917
6930
|
);
|
|
6918
6931
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6919
6932
|
appDispatch(setSelectedRowKeys(keys));
|
|
@@ -6926,19 +6939,22 @@ var tableHeadController = (props) => {
|
|
|
6926
6939
|
}
|
|
6927
6940
|
};
|
|
6928
6941
|
return {
|
|
6929
|
-
handleCheckBoxAll
|
|
6930
|
-
checkedAll,
|
|
6931
|
-
selectedRowKeysRef
|
|
6942
|
+
handleCheckBoxAll
|
|
6932
6943
|
};
|
|
6933
6944
|
};
|
|
6934
6945
|
|
|
6935
6946
|
// src/widget/advance/table/table-view/controller.ts
|
|
6936
|
-
import { useEffect as
|
|
6947
|
+
import { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef5, useState as useState14 } from "react";
|
|
6948
|
+
import {
|
|
6949
|
+
useAppSelector as useAppSelector5,
|
|
6950
|
+
selectSearch as selectSearch4,
|
|
6951
|
+
selectList as selectList3
|
|
6952
|
+
} from "@fctc/interface-logic/store";
|
|
6937
6953
|
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
6938
6954
|
var tableController = ({ data }) => {
|
|
6939
|
-
const [rows, setRows] = useState14(
|
|
6940
|
-
const [columns, setColumns] = useState14(
|
|
6941
|
-
const dataModelFields = data
|
|
6955
|
+
const [rows, setRows] = useState14(data.records || []);
|
|
6956
|
+
const [columns, setColumns] = useState14([]);
|
|
6957
|
+
const dataModelFields = data.fields?.map((field) => {
|
|
6942
6958
|
return {
|
|
6943
6959
|
...data.dataModel?.[field?.name],
|
|
6944
6960
|
...field,
|
|
@@ -6965,8 +6981,8 @@ var tableController = ({ data }) => {
|
|
|
6965
6981
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6966
6982
|
});
|
|
6967
6983
|
};
|
|
6968
|
-
|
|
6969
|
-
setRows(transformData(data.records));
|
|
6984
|
+
useEffect13(() => {
|
|
6985
|
+
setRows(transformData(data.records || null));
|
|
6970
6986
|
}, [data.records]);
|
|
6971
6987
|
const handleGetColumns = () => {
|
|
6972
6988
|
let cols = [];
|
|
@@ -6986,11 +7002,10 @@ var tableController = ({ data }) => {
|
|
|
6986
7002
|
}
|
|
6987
7003
|
return cols;
|
|
6988
7004
|
};
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
}, [data]);
|
|
7005
|
+
useEffect13(() => {
|
|
7006
|
+
const columns2 = handleGetColumns();
|
|
7007
|
+
setColumns(columns2);
|
|
7008
|
+
}, [data.records]);
|
|
6994
7009
|
const onToggleColumnOptional = (item) => {
|
|
6995
7010
|
const tempColumn = [...columns]?.map((val) => {
|
|
6996
7011
|
if (item?.name === val?.name) {
|
|
@@ -7003,14 +7018,6 @@ var tableController = ({ data }) => {
|
|
|
7003
7018
|
});
|
|
7004
7019
|
setColumns(tempColumn);
|
|
7005
7020
|
};
|
|
7006
|
-
useEffect14(() => {
|
|
7007
|
-
setRows(null);
|
|
7008
|
-
setColumns(null);
|
|
7009
|
-
return () => {
|
|
7010
|
-
setRows(null);
|
|
7011
|
-
setColumns(null);
|
|
7012
|
-
};
|
|
7013
|
-
}, [data?.fields]);
|
|
7014
7021
|
return {
|
|
7015
7022
|
rows,
|
|
7016
7023
|
columns,
|
|
@@ -7020,35 +7027,57 @@ var tableController = ({ data }) => {
|
|
|
7020
7027
|
};
|
|
7021
7028
|
|
|
7022
7029
|
// src/widget/advance/table/table-group/controller.ts
|
|
7023
|
-
import { useEffect as
|
|
7030
|
+
import { useEffect as useEffect14, useMemo as useMemo13, useState as useState15 } from "react";
|
|
7024
7031
|
import {
|
|
7025
|
-
|
|
7026
|
-
|
|
7032
|
+
useOdooDataTransform,
|
|
7033
|
+
useGetListData as useGetListData2
|
|
7034
|
+
} from "@fctc/interface-logic/hooks";
|
|
7035
|
+
import {
|
|
7036
|
+
useAppSelector as useAppSelector6,
|
|
7037
|
+
selectSearch as selectSearch5,
|
|
7038
|
+
selectList as selectList4,
|
|
7039
|
+
useAppDispatch as useAppDispatch6,
|
|
7040
|
+
setSelectedRowKeys as setSelectedRowKeys2
|
|
7027
7041
|
} from "@fctc/interface-logic/store";
|
|
7042
|
+
|
|
7043
|
+
// src/environment.ts
|
|
7044
|
+
var environment_exports = {};
|
|
7045
|
+
__reExport(environment_exports, environment_star);
|
|
7046
|
+
import * as environment_star from "@fctc/interface-logic/environment";
|
|
7047
|
+
|
|
7048
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
7028
7049
|
var tableGroupController = (props) => {
|
|
7029
|
-
const
|
|
7030
|
-
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
7050
|
+
const env = (0, environment_exports.getEnv)();
|
|
7031
7051
|
const {
|
|
7052
|
+
rows,
|
|
7032
7053
|
columns,
|
|
7054
|
+
indexRow,
|
|
7033
7055
|
row,
|
|
7034
7056
|
model,
|
|
7035
7057
|
viewData,
|
|
7058
|
+
renderField,
|
|
7036
7059
|
level,
|
|
7037
7060
|
specification,
|
|
7061
|
+
domain,
|
|
7038
7062
|
context,
|
|
7039
7063
|
checkedAll,
|
|
7040
|
-
|
|
7041
|
-
|
|
7064
|
+
isDisplayCheckbox,
|
|
7065
|
+
isAutoSelect,
|
|
7066
|
+
setIsAutoSelect,
|
|
7067
|
+
selectedRowKeysRef
|
|
7042
7068
|
} = props;
|
|
7043
7069
|
const [pageGroup, setPageGroup] = useState15(0);
|
|
7044
|
-
const {
|
|
7070
|
+
const { groupByDomain, selectedTags } = useAppSelector6(selectSearch5);
|
|
7071
|
+
const { selectedRowKeys } = useAppSelector6(selectList4);
|
|
7072
|
+
const appDispatch = useAppDispatch6();
|
|
7073
|
+
const { toDataJS } = useOdooDataTransform();
|
|
7074
|
+
const initVal = toDataJS(row, viewData, model);
|
|
7045
7075
|
const [isShowGroup, setIsShowGroup] = useState15(false);
|
|
7046
7076
|
const [colEmptyGroup, setColEmptyGroup] = useState15({
|
|
7047
7077
|
fromStart: 1,
|
|
7048
7078
|
fromEnd: 1
|
|
7049
7079
|
});
|
|
7050
|
-
const
|
|
7051
|
-
const processedData = useMemo12(() => {
|
|
7080
|
+
const processedData = useMemo13(() => {
|
|
7052
7081
|
const calculateColSpanEmpty = () => {
|
|
7053
7082
|
const startIndex = columns.findIndex(
|
|
7054
7083
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -7063,7 +7092,7 @@ var tableGroupController = (props) => {
|
|
|
7063
7092
|
};
|
|
7064
7093
|
return calculateColSpanEmpty();
|
|
7065
7094
|
}, [columns, row]);
|
|
7066
|
-
const shouldFetchData =
|
|
7095
|
+
const shouldFetchData = useMemo13(() => {
|
|
7067
7096
|
return !!isShowGroup;
|
|
7068
7097
|
}, [isShowGroup]);
|
|
7069
7098
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -7073,21 +7102,21 @@ var tableGroupController = (props) => {
|
|
|
7073
7102
|
domain,
|
|
7074
7103
|
context,
|
|
7075
7104
|
offset: pageGroup * 10,
|
|
7076
|
-
fields:
|
|
7077
|
-
groupby: [
|
|
7105
|
+
fields: groupByDomain?.fields,
|
|
7106
|
+
groupby: [groupByDomain?.contexts[level]?.group_by]
|
|
7078
7107
|
};
|
|
7079
7108
|
const queryKey = [
|
|
7080
|
-
`data-${model}
|
|
7109
|
+
`data-${model}--${level}-row${indexRow}`,
|
|
7081
7110
|
specification,
|
|
7082
7111
|
domain,
|
|
7083
7112
|
pageGroup
|
|
7084
7113
|
];
|
|
7085
7114
|
const {
|
|
7086
|
-
data:
|
|
7087
|
-
isFetched:
|
|
7115
|
+
data: dataResponse,
|
|
7116
|
+
isFetched: isQueryFetched,
|
|
7117
|
+
isPlaceholderData,
|
|
7088
7118
|
isLoading,
|
|
7089
|
-
isFetching
|
|
7090
|
-
isPlaceholderData: isDataPlaceHolder
|
|
7119
|
+
isFetching
|
|
7091
7120
|
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
7092
7121
|
const {
|
|
7093
7122
|
columns: columnsGroup,
|
|
@@ -7096,21 +7125,27 @@ var tableGroupController = (props) => {
|
|
|
7096
7125
|
} = tableController({
|
|
7097
7126
|
data: {
|
|
7098
7127
|
fields: viewData?.views?.list?.fields,
|
|
7099
|
-
records:
|
|
7128
|
+
records: dataResponse?.records ?? dataResponse?.groups,
|
|
7100
7129
|
dataModel: viewData?.models?.[model],
|
|
7101
7130
|
context: env.context,
|
|
7102
|
-
typeTable:
|
|
7131
|
+
typeTable: dataResponse?.groups ? "group" : "list"
|
|
7103
7132
|
}
|
|
7104
7133
|
});
|
|
7105
|
-
const
|
|
7134
|
+
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
7135
|
+
useEffect14(() => {
|
|
7136
|
+
if (isShowGroup && selectedTags?.length > 0) {
|
|
7137
|
+
setIsShowGroup(false);
|
|
7138
|
+
}
|
|
7139
|
+
}, [selectedTags]);
|
|
7140
|
+
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
7106
7141
|
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(
|
|
7107
7142
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
7108
7143
|
)?.[1] : row[group_by_field_name];
|
|
7109
7144
|
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`]})`;
|
|
7110
7145
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
7111
|
-
const
|
|
7112
|
-
const onExpandChildGroup = () => {
|
|
7146
|
+
const handleExpandChildGroup = () => {
|
|
7113
7147
|
if (isLoading || isFetching) return;
|
|
7148
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7114
7149
|
if (allIdsNull || typeTableGroup === "group") {
|
|
7115
7150
|
toggleShowGroup();
|
|
7116
7151
|
return;
|
|
@@ -7120,39 +7155,53 @@ var tableGroupController = (props) => {
|
|
|
7120
7155
|
const filteredIds = selectedRowKeys.filter(
|
|
7121
7156
|
(id) => !ids.includes(id)
|
|
7122
7157
|
);
|
|
7123
|
-
|
|
7124
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
7158
|
+
appDispatch(setSelectedRowKeys2(filteredIds));
|
|
7159
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
7125
7160
|
const clonedKeys = [...selectedRowKeys];
|
|
7126
|
-
|
|
7127
|
-
setTimeout(() =>
|
|
7161
|
+
appDispatch(setSelectedRowKeys2([...clonedKeys, -1]));
|
|
7162
|
+
setTimeout(() => appDispatch(setSelectedRowKeys2(clonedKeys)), 500);
|
|
7128
7163
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7129
|
-
console.log("abc");
|
|
7130
7164
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7131
|
-
|
|
7165
|
+
appDispatch(setSelectedRowKeys2(filteredKeys));
|
|
7132
7166
|
}
|
|
7133
7167
|
toggleShowGroup();
|
|
7134
7168
|
};
|
|
7135
|
-
|
|
7136
|
-
if (!
|
|
7169
|
+
useEffect14(() => {
|
|
7170
|
+
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
7137
7171
|
return;
|
|
7138
7172
|
}
|
|
7139
7173
|
const clonedKeys = [...selectedRowKeys];
|
|
7140
|
-
|
|
7141
|
-
setTimeout(() =>
|
|
7142
|
-
}, [
|
|
7174
|
+
setSelectedRowKeys2([...clonedKeys, -1]);
|
|
7175
|
+
setTimeout(() => setSelectedRowKeys2(clonedKeys), 500);
|
|
7176
|
+
}, [isQueryFetched]);
|
|
7143
7177
|
return {
|
|
7144
|
-
|
|
7178
|
+
handleExpandChildGroup,
|
|
7145
7179
|
colEmptyGroup,
|
|
7180
|
+
leftPadding,
|
|
7146
7181
|
isShowGroup,
|
|
7147
|
-
|
|
7148
|
-
isDataPlaceHolder,
|
|
7182
|
+
isQueryFetched,
|
|
7149
7183
|
nameGroupWithCount,
|
|
7184
|
+
columns,
|
|
7185
|
+
row,
|
|
7186
|
+
isPlaceholderData,
|
|
7150
7187
|
columnsGroup,
|
|
7188
|
+
indexRow,
|
|
7151
7189
|
rowsGroup,
|
|
7152
|
-
|
|
7190
|
+
model,
|
|
7191
|
+
viewData,
|
|
7192
|
+
renderField,
|
|
7193
|
+
level,
|
|
7194
|
+
specification,
|
|
7195
|
+
context,
|
|
7196
|
+
checkedAll,
|
|
7197
|
+
isDisplayCheckbox,
|
|
7198
|
+
isAutoSelect,
|
|
7199
|
+
setIsAutoSelect,
|
|
7200
|
+
selectedRowKeysRef,
|
|
7201
|
+
initVal,
|
|
7202
|
+
dataResponse,
|
|
7153
7203
|
pageGroup,
|
|
7154
|
-
setPageGroup
|
|
7155
|
-
typeTableGroup
|
|
7204
|
+
setPageGroup
|
|
7156
7205
|
};
|
|
7157
7206
|
};
|
|
7158
7207
|
|
|
@@ -7165,7 +7214,7 @@ import {
|
|
|
7165
7214
|
evalJSONDomain as evalJSONDomain7,
|
|
7166
7215
|
validateAndParseDate
|
|
7167
7216
|
} from "@fctc/interface-logic/utils";
|
|
7168
|
-
import { useCallback as
|
|
7217
|
+
import { useCallback as useCallback3, useEffect as useEffect15, useState as useState16 } from "react";
|
|
7169
7218
|
var searchController = ({
|
|
7170
7219
|
viewData,
|
|
7171
7220
|
model,
|
|
@@ -7226,7 +7275,7 @@ var searchController = ({
|
|
|
7226
7275
|
}
|
|
7227
7276
|
}
|
|
7228
7277
|
};
|
|
7229
|
-
|
|
7278
|
+
useEffect15(() => {
|
|
7230
7279
|
fetchData();
|
|
7231
7280
|
}, [model, viewData]);
|
|
7232
7281
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7308,7 +7357,7 @@ var searchController = ({
|
|
|
7308
7357
|
return [...domain2];
|
|
7309
7358
|
}
|
|
7310
7359
|
};
|
|
7311
|
-
const setTagSearch =
|
|
7360
|
+
const setTagSearch = useCallback3(
|
|
7312
7361
|
(updatedMap) => {
|
|
7313
7362
|
if (!updatedMap) return;
|
|
7314
7363
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7371,7 +7420,7 @@ var searchController = ({
|
|
|
7371
7420
|
},
|
|
7372
7421
|
[searchMap]
|
|
7373
7422
|
);
|
|
7374
|
-
|
|
7423
|
+
useEffect15(() => {
|
|
7375
7424
|
setTagSearch(searchMap);
|
|
7376
7425
|
}, [searchMap]);
|
|
7377
7426
|
const handleAddTagSearch = (tag) => {
|
|
@@ -7439,13 +7488,6 @@ import * as constants_star from "@fctc/interface-logic/constants";
|
|
|
7439
7488
|
|
|
7440
7489
|
// src/index.ts
|
|
7441
7490
|
__reExport(index_exports, constants_exports);
|
|
7442
|
-
|
|
7443
|
-
// src/environment.ts
|
|
7444
|
-
var environment_exports = {};
|
|
7445
|
-
__reExport(environment_exports, environment_star);
|
|
7446
|
-
import * as environment_star from "@fctc/interface-logic/environment";
|
|
7447
|
-
|
|
7448
|
-
// src/index.ts
|
|
7449
7491
|
__reExport(index_exports, environment_exports);
|
|
7450
7492
|
__reExport(index_exports, provider_exports);
|
|
7451
7493
|
|
|
@@ -7513,6 +7555,7 @@ export {
|
|
|
7513
7555
|
useMenu,
|
|
7514
7556
|
useMenuItem,
|
|
7515
7557
|
useProfile,
|
|
7558
|
+
useSelectionState,
|
|
7516
7559
|
useStorageState,
|
|
7517
7560
|
useUser,
|
|
7518
7561
|
useViewV2
|