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