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