@fctc/widget-logic 2.3.8 → 2.4.0
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 -3
- package/dist/hooks.d.ts +7 -3
- package/dist/hooks.js +87 -113
- package/dist/hooks.mjs +99 -134
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +254 -276
- package/dist/index.mjs +231 -275
- 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 +244 -270
- package/dist/widget.mjs +222 -271
- package/package.json +96 -96
package/dist/widget.mjs
CHANGED
|
@@ -41,7 +41,7 @@ var require_moment = __commonJS({
|
|
|
41
41
|
"use strict";
|
|
42
42
|
(function(global, factory) {
|
|
43
43
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.moment = factory();
|
|
44
|
-
})(exports, function() {
|
|
44
|
+
})(exports, (function() {
|
|
45
45
|
"use strict";
|
|
46
46
|
var hookCallback;
|
|
47
47
|
function hooks() {
|
|
@@ -4032,7 +4032,7 @@ var require_moment = __commonJS({
|
|
|
4032
4032
|
// <input type="month" />
|
|
4033
4033
|
};
|
|
4034
4034
|
return hooks;
|
|
4035
|
-
});
|
|
4035
|
+
}));
|
|
4036
4036
|
}
|
|
4037
4037
|
});
|
|
4038
4038
|
|
|
@@ -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,12 @@ 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";
|
|
4675
|
+
import { evalJSONContext } from "@fctc/interface-logic/utils";
|
|
4773
4676
|
|
|
4774
4677
|
// src/hooks/core/use-company.ts
|
|
4775
4678
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
4776
|
-
import { useEffect as useEffect7, useMemo as
|
|
4679
|
+
import { useEffect as useEffect7, useMemo as useMemo6 } from "react";
|
|
4777
4680
|
import { getEnv as getEnv5 } from "@fctc/interface-logic/environment";
|
|
4778
4681
|
import {
|
|
4779
4682
|
useGetCurrentCompany,
|
|
@@ -4789,7 +4692,7 @@ var useCompany = (accessToken) => {
|
|
|
4789
4692
|
queryFn: fetchCurrentCompany,
|
|
4790
4693
|
enabled: !!accessToken
|
|
4791
4694
|
});
|
|
4792
|
-
const current_company_id =
|
|
4695
|
+
const current_company_id = useMemo6(() => {
|
|
4793
4696
|
return currentCompany.data?.current_company_id;
|
|
4794
4697
|
}, [currentCompany.data]);
|
|
4795
4698
|
useEffect7(() => {
|
|
@@ -4821,10 +4724,8 @@ var useCompany = (accessToken) => {
|
|
|
4821
4724
|
context: { allowed_company_ids: [current_company_id] }
|
|
4822
4725
|
};
|
|
4823
4726
|
};
|
|
4824
|
-
var use_company_default = useCompany;
|
|
4825
4727
|
|
|
4826
4728
|
// src/hooks/core/use-app-provider.tsx
|
|
4827
|
-
import { evalJSONContext } from "@fctc/interface-logic/utils";
|
|
4828
4729
|
import { jsx } from "react/jsx-runtime";
|
|
4829
4730
|
var AppProviderInitialValue = {
|
|
4830
4731
|
config: {},
|
|
@@ -4841,15 +4742,15 @@ var AppProvider = ({ children }) => {
|
|
|
4841
4742
|
const config = useConfig({});
|
|
4842
4743
|
const auth = useAuth();
|
|
4843
4744
|
const user = useUser(auth.accessToken);
|
|
4844
|
-
const company =
|
|
4845
|
-
const menuContext =
|
|
4745
|
+
const company = useCompany(auth.accessToken);
|
|
4746
|
+
const menuContext = useMemo7(() => {
|
|
4846
4747
|
return combineContexts([user.context, company.context]);
|
|
4847
4748
|
}, [user.context, company.context]);
|
|
4848
4749
|
const menu = useMenu({ context: menuContext });
|
|
4849
|
-
const action =
|
|
4750
|
+
const action = useMemo7(() => {
|
|
4850
4751
|
return menu.state.action;
|
|
4851
4752
|
}, [menu.state.action]);
|
|
4852
|
-
const viewContext =
|
|
4753
|
+
const viewContext = useMemo7(() => {
|
|
4853
4754
|
return combineContexts([
|
|
4854
4755
|
menuContext,
|
|
4855
4756
|
{ ...evalJSONContext(action?.result?.context) }
|
|
@@ -4892,7 +4793,7 @@ var useAppProvider = () => {
|
|
|
4892
4793
|
// src/hooks/core/use-menu-item.tsx
|
|
4893
4794
|
import { getEnv as getEnv6 } from "@fctc/interface-logic/environment";
|
|
4894
4795
|
import { useGetActionDetail } from "@fctc/interface-logic/hooks";
|
|
4895
|
-
import { useState as
|
|
4796
|
+
import { useState as useState5 } from "react";
|
|
4896
4797
|
|
|
4897
4798
|
// src/utils.ts
|
|
4898
4799
|
var utils_exports = {};
|
|
@@ -4907,8 +4808,6 @@ __export(utils_exports, {
|
|
|
4907
4808
|
languages: () => languages,
|
|
4908
4809
|
mergeButtons: () => mergeButtons,
|
|
4909
4810
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4910
|
-
useGetRowIds: () => useGetRowIds,
|
|
4911
|
-
useSelectionState: () => useSelectionState,
|
|
4912
4811
|
useStorageState: () => useStorageState
|
|
4913
4812
|
});
|
|
4914
4813
|
__reExport(utils_exports, utils_star);
|
|
@@ -4929,7 +4828,7 @@ var useMenuItem = (props) => {
|
|
|
4929
4828
|
enabled: true,
|
|
4930
4829
|
queryKey: [`action-${aid}`]
|
|
4931
4830
|
}).data;
|
|
4932
|
-
const [path, setPath] =
|
|
4831
|
+
const [path, setPath] = useState5("");
|
|
4933
4832
|
const handleClick = () => {
|
|
4934
4833
|
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4935
4834
|
return;
|
|
@@ -4951,8 +4850,74 @@ var useMenuItem = (props) => {
|
|
|
4951
4850
|
return { handleClick, path, queryActionDetail };
|
|
4952
4851
|
};
|
|
4953
4852
|
|
|
4853
|
+
// src/hooks/core/use-get-rowids.ts
|
|
4854
|
+
import { useCallback as useCallback2, useEffect as useEffect8, useRef as useRef2, useState as useState6 } 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] = useState6([]);
|
|
4872
|
+
const lastRowIdsRef = useRef2([]);
|
|
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
|
+
useEffect8(() => {
|
|
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
|
+
|
|
4954
4919
|
// src/hooks/utils/use-click-outside.ts
|
|
4955
|
-
import { useEffect as
|
|
4920
|
+
import { useEffect as useEffect9, useRef as useRef3 } from "react";
|
|
4956
4921
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4957
4922
|
var useClickOutside = ({
|
|
4958
4923
|
handler,
|
|
@@ -4961,7 +4926,7 @@ var useClickOutside = ({
|
|
|
4961
4926
|
refs
|
|
4962
4927
|
}) => {
|
|
4963
4928
|
const ref = useRef3(null);
|
|
4964
|
-
|
|
4929
|
+
useEffect9(() => {
|
|
4965
4930
|
const listener = (event) => {
|
|
4966
4931
|
const { target } = event;
|
|
4967
4932
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4983,10 +4948,10 @@ var useClickOutside = ({
|
|
|
4983
4948
|
};
|
|
4984
4949
|
|
|
4985
4950
|
// src/hooks/utils/use-debounce.ts
|
|
4986
|
-
import { useEffect as
|
|
4951
|
+
import { useEffect as useEffect10, useState as useState7 } from "react";
|
|
4987
4952
|
function useDebounce(value, delay) {
|
|
4988
4953
|
const [debouncedValue, setDebouncedValue] = useState7(value);
|
|
4989
|
-
|
|
4954
|
+
useEffect10(() => {
|
|
4990
4955
|
const handler = setTimeout(() => {
|
|
4991
4956
|
setDebouncedValue(value);
|
|
4992
4957
|
}, delay);
|
|
@@ -5001,6 +4966,11 @@ function useDebounce(value, delay) {
|
|
|
5001
4966
|
__reExport(hooks_exports, hooks_star);
|
|
5002
4967
|
import * as hooks_star from "@fctc/interface-logic/hooks";
|
|
5003
4968
|
|
|
4969
|
+
// src/store.ts
|
|
4970
|
+
var store_exports = {};
|
|
4971
|
+
__reExport(store_exports, store_star);
|
|
4972
|
+
import * as store_star from "@fctc/interface-logic/store";
|
|
4973
|
+
|
|
5004
4974
|
// src/provider.ts
|
|
5005
4975
|
var provider_exports = {};
|
|
5006
4976
|
__reExport(provider_exports, provider_star);
|
|
@@ -5059,18 +5029,18 @@ var many2oneFieldController = (props) => {
|
|
|
5059
5029
|
queryKey,
|
|
5060
5030
|
enabled: false
|
|
5061
5031
|
});
|
|
5062
|
-
const selectOptions =
|
|
5032
|
+
const selectOptions = useMemo8(() => {
|
|
5063
5033
|
return dataOfSelection?.records?.map((val) => ({
|
|
5064
5034
|
value: val?.id,
|
|
5065
5035
|
label: val?.display_name || val?.name
|
|
5066
5036
|
})) || [];
|
|
5067
5037
|
}, [dataOfSelection]);
|
|
5068
|
-
|
|
5038
|
+
useEffect11(() => {
|
|
5069
5039
|
setOptions(selectOptions);
|
|
5070
5040
|
setDomainModal(domainObject);
|
|
5071
5041
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5072
5042
|
}, [selectOptions]);
|
|
5073
|
-
|
|
5043
|
+
useEffect11(() => {
|
|
5074
5044
|
setDomainObject(
|
|
5075
5045
|
(0, utils_exports.evalJSONDomain)(
|
|
5076
5046
|
domain,
|
|
@@ -5078,7 +5048,7 @@ var many2oneFieldController = (props) => {
|
|
|
5078
5048
|
)
|
|
5079
5049
|
);
|
|
5080
5050
|
}, [domain, formValues]);
|
|
5081
|
-
|
|
5051
|
+
useEffect11(() => {
|
|
5082
5052
|
if (!propValue && tempSelectedOption) {
|
|
5083
5053
|
methods.setValue(name, null);
|
|
5084
5054
|
setTempSelectedOption(null);
|
|
@@ -5089,10 +5059,10 @@ var many2oneFieldController = (props) => {
|
|
|
5089
5059
|
});
|
|
5090
5060
|
}
|
|
5091
5061
|
}, [propValue]);
|
|
5092
|
-
const fetchMoreOptions =
|
|
5062
|
+
const fetchMoreOptions = useCallback3(() => {
|
|
5093
5063
|
refetch();
|
|
5094
5064
|
}, [refetch]);
|
|
5095
|
-
|
|
5065
|
+
useEffect11(() => {
|
|
5096
5066
|
if (debouncedInputValue) {
|
|
5097
5067
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5098
5068
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5107,7 +5077,7 @@ var many2oneFieldController = (props) => {
|
|
|
5107
5077
|
}, 50);
|
|
5108
5078
|
}
|
|
5109
5079
|
}, [debouncedInputValue]);
|
|
5110
|
-
const handleChooseRecord =
|
|
5080
|
+
const handleChooseRecord = useCallback3(
|
|
5111
5081
|
(idRecord) => {
|
|
5112
5082
|
const newOption = options.find(
|
|
5113
5083
|
(option) => option.value === idRecord
|
|
@@ -5132,8 +5102,8 @@ var many2oneFieldController = (props) => {
|
|
|
5132
5102
|
},
|
|
5133
5103
|
[options, methods, name, onChange]
|
|
5134
5104
|
);
|
|
5135
|
-
const handleClose =
|
|
5136
|
-
const handleSelectChange =
|
|
5105
|
+
const handleClose = useCallback3(() => setIsShowModalMany2Many(false), []);
|
|
5106
|
+
const handleSelectChange = useCallback3(
|
|
5137
5107
|
(selectedOption) => {
|
|
5138
5108
|
if (!selectedOption) {
|
|
5139
5109
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5207,7 +5177,7 @@ var many2oneButtonController = (props) => {
|
|
|
5207
5177
|
};
|
|
5208
5178
|
|
|
5209
5179
|
// src/widget/basic/many2many-field/controller.ts
|
|
5210
|
-
import { useEffect as
|
|
5180
|
+
import { useEffect as useEffect12, useMemo as useMemo9, useState as useState9 } from "react";
|
|
5211
5181
|
import {
|
|
5212
5182
|
evalJSONContext as evalJSONContext4,
|
|
5213
5183
|
evalJSONDomain as evalJSONDomain4,
|
|
@@ -5226,7 +5196,7 @@ var many2manyFieldController = (props) => {
|
|
|
5226
5196
|
actionData
|
|
5227
5197
|
} = props;
|
|
5228
5198
|
const { env } = (0, provider_exports.useEnv)();
|
|
5229
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5199
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView } = (0, provider_exports.useService)();
|
|
5230
5200
|
const [order, setOrder] = useState9();
|
|
5231
5201
|
const [page, setPage] = useState9(0);
|
|
5232
5202
|
const [domainMany2Many, setDomainMany2Many] = useState9(null);
|
|
@@ -5244,7 +5214,7 @@ var many2manyFieldController = (props) => {
|
|
|
5244
5214
|
context: contextObject
|
|
5245
5215
|
};
|
|
5246
5216
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5247
|
-
const baseModel =
|
|
5217
|
+
const baseModel = useMemo9(
|
|
5248
5218
|
() => ({
|
|
5249
5219
|
name: String(relation),
|
|
5250
5220
|
view: viewResponse || {},
|
|
@@ -5257,13 +5227,13 @@ var many2manyFieldController = (props) => {
|
|
|
5257
5227
|
[relation, viewResponse]
|
|
5258
5228
|
);
|
|
5259
5229
|
const initModel = (0, hooks_exports.useModel)();
|
|
5260
|
-
const modelInstance =
|
|
5230
|
+
const modelInstance = useMemo9(() => {
|
|
5261
5231
|
if (viewResponse) {
|
|
5262
5232
|
return initModel.initModel(baseModel);
|
|
5263
5233
|
}
|
|
5264
5234
|
return null;
|
|
5265
5235
|
}, [baseModel, viewResponse]);
|
|
5266
|
-
const specification =
|
|
5236
|
+
const specification = useMemo9(() => {
|
|
5267
5237
|
if (modelInstance) {
|
|
5268
5238
|
return modelInstance.getSpecification();
|
|
5269
5239
|
}
|
|
@@ -5305,8 +5275,8 @@ var many2manyFieldController = (props) => {
|
|
|
5305
5275
|
isLoading,
|
|
5306
5276
|
isFetched,
|
|
5307
5277
|
isPlaceholderData
|
|
5308
|
-
} =
|
|
5309
|
-
|
|
5278
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5279
|
+
useEffect12(() => {
|
|
5310
5280
|
if (viewResponse) {
|
|
5311
5281
|
fetchData();
|
|
5312
5282
|
}
|
|
@@ -5359,7 +5329,7 @@ var many2manyFieldController = (props) => {
|
|
|
5359
5329
|
};
|
|
5360
5330
|
|
|
5361
5331
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5362
|
-
import { useMemo as
|
|
5332
|
+
import { useMemo as useMemo10 } from "react";
|
|
5363
5333
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5364
5334
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
5365
5335
|
var many2manyTagsController = (props) => {
|
|
@@ -5375,7 +5345,7 @@ var many2manyTagsController = (props) => {
|
|
|
5375
5345
|
const { env } = (0, provider_exports.useEnv)();
|
|
5376
5346
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5377
5347
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
5378
|
-
const domainObject =
|
|
5348
|
+
const domainObject = useMemo10(
|
|
5379
5349
|
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5380
5350
|
[domain, formValues]
|
|
5381
5351
|
);
|
|
@@ -5426,7 +5396,7 @@ var durationController = (props) => {
|
|
|
5426
5396
|
name: "",
|
|
5427
5397
|
fold: ""
|
|
5428
5398
|
};
|
|
5429
|
-
const { useGetListData:
|
|
5399
|
+
const { useGetListData: useGetListData2, useChangeStatus } = (0, provider_exports.useService)();
|
|
5430
5400
|
const { env } = (0, provider_exports.useEnv)();
|
|
5431
5401
|
const [disabled, setDisabled] = useState10(false);
|
|
5432
5402
|
const [modelStatus, setModalStatus] = useState10(false);
|
|
@@ -5444,7 +5414,7 @@ var durationController = (props) => {
|
|
|
5444
5414
|
},
|
|
5445
5415
|
sort: ""
|
|
5446
5416
|
};
|
|
5447
|
-
const { data: dataResponse } =
|
|
5417
|
+
const { data: dataResponse } = useGetListData2(
|
|
5448
5418
|
listDataProps,
|
|
5449
5419
|
queryKey,
|
|
5450
5420
|
enabled
|
|
@@ -6506,7 +6476,7 @@ var colorFieldController = (props) => {
|
|
|
6506
6476
|
};
|
|
6507
6477
|
|
|
6508
6478
|
// src/widget/basic/binary-field/controller.ts
|
|
6509
|
-
import { useEffect as
|
|
6479
|
+
import { useEffect as useEffect13, useId as useId2, useRef as useRef4, useState as useState13 } from "react";
|
|
6510
6480
|
import { isBase64Image } from "@fctc/interface-logic/utils";
|
|
6511
6481
|
var binaryFieldController = (props) => {
|
|
6512
6482
|
const { name, methods, readonly = false, value } = props;
|
|
@@ -6577,14 +6547,14 @@ var binaryFieldController = (props) => {
|
|
|
6577
6547
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6578
6548
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6579
6549
|
};
|
|
6580
|
-
|
|
6550
|
+
useEffect13(() => {
|
|
6581
6551
|
return () => {
|
|
6582
6552
|
if (selectedImage) {
|
|
6583
6553
|
URL.revokeObjectURL(selectedImage);
|
|
6584
6554
|
}
|
|
6585
6555
|
};
|
|
6586
6556
|
}, [selectedImage]);
|
|
6587
|
-
|
|
6557
|
+
useEffect13(() => {
|
|
6588
6558
|
if (binaryRef.current) {
|
|
6589
6559
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6590
6560
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6604,16 +6574,33 @@ var binaryFieldController = (props) => {
|
|
|
6604
6574
|
};
|
|
6605
6575
|
|
|
6606
6576
|
// 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";
|
|
6577
|
+
import { useAppDispatch as useAppDispatch5, setSelectedRowKeys } from "@fctc/interface-logic/store";
|
|
6578
|
+
import { useMemo as useMemo11, useRef as useRef5 } from "react";
|
|
6613
6579
|
var tableHeadController = (props) => {
|
|
6614
|
-
const { typeTable, rows,
|
|
6580
|
+
const { typeTable, rows, tableRef, groupByList, selectedRowKeys } = props;
|
|
6615
6581
|
const appDispatch = useAppDispatch5();
|
|
6616
|
-
const {
|
|
6582
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6583
|
+
const selectedRowKeysRef = useRef5(recordIds);
|
|
6584
|
+
const isGroupTable = typeTable === "group";
|
|
6585
|
+
const recordsCheckedGroup = useMemo11(() => {
|
|
6586
|
+
if (!rows || !groupByList) return 0;
|
|
6587
|
+
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6588
|
+
return countSum(rows, groupBy);
|
|
6589
|
+
}, [rows, groupByList]);
|
|
6590
|
+
const isAllGroupChecked = useMemo11(() => {
|
|
6591
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6592
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6593
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6594
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6595
|
+
return allGroupsSelected || allRecordsSelected;
|
|
6596
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6597
|
+
const isAllNormalChecked = useMemo11(() => {
|
|
6598
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6599
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6600
|
+
(id) => rows.some((record) => record.id === id)
|
|
6601
|
+
);
|
|
6602
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6603
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6617
6604
|
const handleCheckBoxAll = (event) => {
|
|
6618
6605
|
if (event?.target?.checked && typeTable === "list") {
|
|
6619
6606
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
@@ -6628,7 +6615,7 @@ var tableHeadController = (props) => {
|
|
|
6628
6615
|
} else {
|
|
6629
6616
|
const sum = countSum(
|
|
6630
6617
|
rows,
|
|
6631
|
-
typeof
|
|
6618
|
+
typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0
|
|
6632
6619
|
);
|
|
6633
6620
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6634
6621
|
appDispatch(setSelectedRowKeys(keys));
|
|
@@ -6641,22 +6628,19 @@ var tableHeadController = (props) => {
|
|
|
6641
6628
|
}
|
|
6642
6629
|
};
|
|
6643
6630
|
return {
|
|
6644
|
-
handleCheckBoxAll
|
|
6631
|
+
handleCheckBoxAll,
|
|
6632
|
+
checkedAll,
|
|
6633
|
+
selectedRowKeysRef
|
|
6645
6634
|
};
|
|
6646
6635
|
};
|
|
6647
6636
|
|
|
6648
6637
|
// 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";
|
|
6638
|
+
import { useEffect as useEffect14, useState as useState14 } from "react";
|
|
6655
6639
|
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
6656
6640
|
var tableController = ({ data }) => {
|
|
6657
|
-
const [rows, setRows] = useState14(
|
|
6658
|
-
const [columns, setColumns] = useState14(
|
|
6659
|
-
const dataModelFields = data
|
|
6641
|
+
const [rows, setRows] = useState14(null);
|
|
6642
|
+
const [columns, setColumns] = useState14(null);
|
|
6643
|
+
const dataModelFields = data?.fields?.map((field) => {
|
|
6660
6644
|
return {
|
|
6661
6645
|
...data.dataModel?.[field?.name],
|
|
6662
6646
|
...field,
|
|
@@ -6683,8 +6667,8 @@ var tableController = ({ data }) => {
|
|
|
6683
6667
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6684
6668
|
});
|
|
6685
6669
|
};
|
|
6686
|
-
|
|
6687
|
-
setRows(transformData(data.records
|
|
6670
|
+
useEffect14(() => {
|
|
6671
|
+
setRows(transformData(data.records));
|
|
6688
6672
|
}, [data.records]);
|
|
6689
6673
|
const handleGetColumns = () => {
|
|
6690
6674
|
let cols = [];
|
|
@@ -6704,10 +6688,11 @@ var tableController = ({ data }) => {
|
|
|
6704
6688
|
}
|
|
6705
6689
|
return cols;
|
|
6706
6690
|
};
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6691
|
+
useEffect14(() => {
|
|
6692
|
+
if (!columns) {
|
|
6693
|
+
setColumns(handleGetColumns());
|
|
6694
|
+
}
|
|
6695
|
+
}, [data]);
|
|
6711
6696
|
const onToggleColumnOptional = (item) => {
|
|
6712
6697
|
const tempColumn = [...columns]?.map((val) => {
|
|
6713
6698
|
if (item?.name === val?.name) {
|
|
@@ -6720,6 +6705,14 @@ var tableController = ({ data }) => {
|
|
|
6720
6705
|
});
|
|
6721
6706
|
setColumns(tempColumn);
|
|
6722
6707
|
};
|
|
6708
|
+
useEffect14(() => {
|
|
6709
|
+
setRows(null);
|
|
6710
|
+
setColumns(null);
|
|
6711
|
+
return () => {
|
|
6712
|
+
setRows(null);
|
|
6713
|
+
setColumns(null);
|
|
6714
|
+
};
|
|
6715
|
+
}, [data?.fields]);
|
|
6723
6716
|
return {
|
|
6724
6717
|
rows,
|
|
6725
6718
|
columns,
|
|
@@ -6729,57 +6722,35 @@ var tableController = ({ data }) => {
|
|
|
6729
6722
|
};
|
|
6730
6723
|
|
|
6731
6724
|
// 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";
|
|
6725
|
+
import { useEffect as useEffect15, useMemo as useMemo12, useState as useState15 } from "react";
|
|
6737
6726
|
import {
|
|
6738
|
-
useAppSelector as
|
|
6739
|
-
|
|
6740
|
-
selectList as selectList4,
|
|
6741
|
-
useAppDispatch as useAppDispatch6,
|
|
6742
|
-
setSelectedRowKeys as setSelectedRowKeys2
|
|
6727
|
+
useAppSelector as useAppSelector3,
|
|
6728
|
+
selectList as selectList2
|
|
6743
6729
|
} 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
6730
|
var tableGroupController = (props) => {
|
|
6752
|
-
const env = (0,
|
|
6731
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
6732
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6753
6733
|
const {
|
|
6754
|
-
rows,
|
|
6755
6734
|
columns,
|
|
6756
|
-
indexRow,
|
|
6757
6735
|
row,
|
|
6758
6736
|
model,
|
|
6759
6737
|
viewData,
|
|
6760
|
-
renderField,
|
|
6761
6738
|
level,
|
|
6762
6739
|
specification,
|
|
6763
|
-
domain,
|
|
6764
6740
|
context,
|
|
6765
6741
|
checkedAll,
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
setIsAutoSelect,
|
|
6769
|
-
selectedRowKeysRef
|
|
6742
|
+
groupByList,
|
|
6743
|
+
setSelectedRowKeys: setSelectedRowKeys3
|
|
6770
6744
|
} = props;
|
|
6771
6745
|
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);
|
|
6746
|
+
const { selectedRowKeys } = useAppSelector3(selectList2);
|
|
6777
6747
|
const [isShowGroup, setIsShowGroup] = useState15(false);
|
|
6778
6748
|
const [colEmptyGroup, setColEmptyGroup] = useState15({
|
|
6779
6749
|
fromStart: 1,
|
|
6780
6750
|
fromEnd: 1
|
|
6781
6751
|
});
|
|
6782
|
-
const
|
|
6752
|
+
const domain = row?.__domain;
|
|
6753
|
+
const processedData = useMemo12(() => {
|
|
6783
6754
|
const calculateColSpanEmpty = () => {
|
|
6784
6755
|
const startIndex = columns.findIndex(
|
|
6785
6756
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6794,7 +6765,7 @@ var tableGroupController = (props) => {
|
|
|
6794
6765
|
};
|
|
6795
6766
|
return calculateColSpanEmpty();
|
|
6796
6767
|
}, [columns, row]);
|
|
6797
|
-
const shouldFetchData =
|
|
6768
|
+
const shouldFetchData = useMemo12(() => {
|
|
6798
6769
|
return !!isShowGroup;
|
|
6799
6770
|
}, [isShowGroup]);
|
|
6800
6771
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6804,21 +6775,21 @@ var tableGroupController = (props) => {
|
|
|
6804
6775
|
domain,
|
|
6805
6776
|
context,
|
|
6806
6777
|
offset: pageGroup * 10,
|
|
6807
|
-
fields:
|
|
6808
|
-
groupby: [
|
|
6778
|
+
fields: groupByList?.fields,
|
|
6779
|
+
groupby: [groupByList?.contexts[level]?.group_by]
|
|
6809
6780
|
};
|
|
6810
6781
|
const queryKey = [
|
|
6811
|
-
`data-${model}
|
|
6782
|
+
`data-${model}-level_${level}-row-${row?.id}`,
|
|
6812
6783
|
specification,
|
|
6813
6784
|
domain,
|
|
6814
6785
|
pageGroup
|
|
6815
6786
|
];
|
|
6816
6787
|
const {
|
|
6817
|
-
data:
|
|
6818
|
-
isFetched:
|
|
6819
|
-
isPlaceholderData,
|
|
6788
|
+
data: dataGroup,
|
|
6789
|
+
isFetched: isDataGroupFetched,
|
|
6820
6790
|
isLoading,
|
|
6821
|
-
isFetching
|
|
6791
|
+
isFetching,
|
|
6792
|
+
isPlaceholderData: isDataPlaceHolder
|
|
6822
6793
|
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
6823
6794
|
const {
|
|
6824
6795
|
columns: columnsGroup,
|
|
@@ -6827,27 +6798,21 @@ var tableGroupController = (props) => {
|
|
|
6827
6798
|
} = tableController({
|
|
6828
6799
|
data: {
|
|
6829
6800
|
fields: viewData?.views?.list?.fields,
|
|
6830
|
-
records:
|
|
6801
|
+
records: dataGroup?.records ?? dataGroup?.groups,
|
|
6831
6802
|
dataModel: viewData?.models?.[model],
|
|
6832
6803
|
context: env.context,
|
|
6833
|
-
typeTable:
|
|
6804
|
+
typeTable: dataGroup?.groups ? "group" : "list"
|
|
6834
6805
|
}
|
|
6835
6806
|
});
|
|
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;
|
|
6807
|
+
const group_by_field_name = groupByList?.contexts[level - 1]?.group_by;
|
|
6843
6808
|
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
6809
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6845
6810
|
)?.[1] : row[group_by_field_name];
|
|
6846
6811
|
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
6812
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6848
|
-
const
|
|
6813
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6814
|
+
const onExpandChildGroup = () => {
|
|
6849
6815
|
if (isLoading || isFetching) return;
|
|
6850
|
-
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6851
6816
|
if (allIdsNull || typeTableGroup === "group") {
|
|
6852
6817
|
toggleShowGroup();
|
|
6853
6818
|
return;
|
|
@@ -6857,53 +6822,39 @@ var tableGroupController = (props) => {
|
|
|
6857
6822
|
const filteredIds = selectedRowKeys.filter(
|
|
6858
6823
|
(id) => !ids.includes(id)
|
|
6859
6824
|
);
|
|
6860
|
-
|
|
6861
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull
|
|
6825
|
+
setSelectedRowKeys3(filteredIds);
|
|
6826
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
6862
6827
|
const clonedKeys = [...selectedRowKeys];
|
|
6863
|
-
|
|
6864
|
-
setTimeout(() =>
|
|
6828
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
6829
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
6865
6830
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6831
|
+
console.log("abc");
|
|
6866
6832
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6867
|
-
|
|
6833
|
+
setSelectedRowKeys3(filteredKeys);
|
|
6868
6834
|
}
|
|
6869
6835
|
toggleShowGroup();
|
|
6870
6836
|
};
|
|
6871
|
-
|
|
6872
|
-
if (!
|
|
6837
|
+
useEffect15(() => {
|
|
6838
|
+
if (!isDataGroupFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6873
6839
|
return;
|
|
6874
6840
|
}
|
|
6875
6841
|
const clonedKeys = [...selectedRowKeys];
|
|
6876
|
-
|
|
6877
|
-
setTimeout(() =>
|
|
6878
|
-
}, [
|
|
6842
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
6843
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
6844
|
+
}, [isDataGroupFetched]);
|
|
6879
6845
|
return {
|
|
6880
|
-
|
|
6846
|
+
onExpandChildGroup,
|
|
6881
6847
|
colEmptyGroup,
|
|
6882
|
-
leftPadding,
|
|
6883
6848
|
isShowGroup,
|
|
6884
|
-
|
|
6849
|
+
isDataGroupFetched,
|
|
6850
|
+
isDataPlaceHolder,
|
|
6885
6851
|
nameGroupWithCount,
|
|
6886
|
-
columns,
|
|
6887
|
-
row,
|
|
6888
|
-
isPlaceholderData,
|
|
6889
6852
|
columnsGroup,
|
|
6890
|
-
indexRow,
|
|
6891
6853
|
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,
|
|
6854
|
+
dataGroup,
|
|
6905
6855
|
pageGroup,
|
|
6906
|
-
setPageGroup
|
|
6856
|
+
setPageGroup,
|
|
6857
|
+
typeTableGroup
|
|
6907
6858
|
};
|
|
6908
6859
|
};
|
|
6909
6860
|
|
|
@@ -6916,7 +6867,7 @@ import {
|
|
|
6916
6867
|
evalJSONDomain as evalJSONDomain7,
|
|
6917
6868
|
validateAndParseDate
|
|
6918
6869
|
} from "@fctc/interface-logic/utils";
|
|
6919
|
-
import { useCallback as
|
|
6870
|
+
import { useCallback as useCallback4, useEffect as useEffect16, useState as useState16 } from "react";
|
|
6920
6871
|
var searchController = ({
|
|
6921
6872
|
viewData,
|
|
6922
6873
|
model,
|
|
@@ -6977,7 +6928,7 @@ var searchController = ({
|
|
|
6977
6928
|
}
|
|
6978
6929
|
}
|
|
6979
6930
|
};
|
|
6980
|
-
|
|
6931
|
+
useEffect16(() => {
|
|
6981
6932
|
fetchData();
|
|
6982
6933
|
}, [model, viewData]);
|
|
6983
6934
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7059,7 +7010,7 @@ var searchController = ({
|
|
|
7059
7010
|
return [...domain2];
|
|
7060
7011
|
}
|
|
7061
7012
|
};
|
|
7062
|
-
const setTagSearch =
|
|
7013
|
+
const setTagSearch = useCallback4(
|
|
7063
7014
|
(updatedMap) => {
|
|
7064
7015
|
if (!updatedMap) return;
|
|
7065
7016
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7122,7 +7073,7 @@ var searchController = ({
|
|
|
7122
7073
|
},
|
|
7123
7074
|
[searchMap]
|
|
7124
7075
|
);
|
|
7125
|
-
|
|
7076
|
+
useEffect16(() => {
|
|
7126
7077
|
setTagSearch(searchMap);
|
|
7127
7078
|
}, [searchMap]);
|
|
7128
7079
|
const handleAddTagSearch = (tag) => {
|