@fctc/widget-logic 2.3.8 → 2.3.10
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 +89 -113
- package/dist/hooks.mjs +100 -134
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +257 -276
- package/dist/index.mjs +234 -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 +245 -270
- package/dist/widget.mjs +223 -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
|
|
|
@@ -4079,6 +4079,7 @@ __export(index_exports, {
|
|
|
4079
4079
|
useAuth: () => useAuth,
|
|
4080
4080
|
useCallAction: () => useCallAction,
|
|
4081
4081
|
useClickOutside: () => useClickOutside,
|
|
4082
|
+
useCompany: () => useCompany,
|
|
4082
4083
|
useConfig: () => useConfig,
|
|
4083
4084
|
useDebounce: () => useDebounce,
|
|
4084
4085
|
useDetail: () => useDetail,
|
|
@@ -4087,7 +4088,6 @@ __export(index_exports, {
|
|
|
4087
4088
|
useMenu: () => useMenu,
|
|
4088
4089
|
useMenuItem: () => useMenuItem,
|
|
4089
4090
|
useProfile: () => useProfile,
|
|
4090
|
-
useSelectionState: () => useSelectionState,
|
|
4091
4091
|
useStorageState: () => useStorageState,
|
|
4092
4092
|
useUser: () => useUser,
|
|
4093
4093
|
useViewV2: () => useViewV2
|
|
@@ -4101,9 +4101,11 @@ __export(hooks_exports, {
|
|
|
4101
4101
|
useAuth: () => useAuth,
|
|
4102
4102
|
useCallAction: () => useCallAction,
|
|
4103
4103
|
useClickOutside: () => useClickOutside,
|
|
4104
|
+
useCompany: () => useCompany,
|
|
4104
4105
|
useConfig: () => useConfig,
|
|
4105
4106
|
useDebounce: () => useDebounce,
|
|
4106
4107
|
useDetail: () => useDetail,
|
|
4108
|
+
useGetRowIds: () => useGetRowIds,
|
|
4107
4109
|
useListData: () => useListData,
|
|
4108
4110
|
useMenu: () => useMenu,
|
|
4109
4111
|
useMenuItem: () => useMenuItem,
|
|
@@ -4227,24 +4229,10 @@ var useDetail = (accessToken, sub) => {
|
|
|
4227
4229
|
};
|
|
4228
4230
|
|
|
4229
4231
|
// 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";
|
|
4232
|
+
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
4246
4233
|
|
|
4247
4234
|
// src/utils/function.ts
|
|
4235
|
+
import { useCallback, useEffect as useEffect3, useReducer } from "react";
|
|
4248
4236
|
var countSum = (data, field) => {
|
|
4249
4237
|
if (!data || !field) return 0;
|
|
4250
4238
|
return data.reduce(
|
|
@@ -4263,91 +4251,6 @@ function mergeButtons(fields) {
|
|
|
4263
4251
|
}
|
|
4264
4252
|
return others;
|
|
4265
4253
|
}
|
|
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
4254
|
var getDateRange = (currentDate, unit) => {
|
|
4352
4255
|
const date = new Date(currentDate);
|
|
4353
4256
|
let dateStart, dateEnd;
|
|
@@ -4489,9 +4392,9 @@ function useStorageState(key) {
|
|
|
4489
4392
|
// src/hooks/core/use-list-data.ts
|
|
4490
4393
|
import { useModel, useGetListData } from "@fctc/interface-logic/hooks";
|
|
4491
4394
|
import {
|
|
4492
|
-
useAppSelector
|
|
4493
|
-
selectSearch
|
|
4494
|
-
selectList
|
|
4395
|
+
useAppSelector,
|
|
4396
|
+
selectSearch,
|
|
4397
|
+
selectList
|
|
4495
4398
|
} from "@fctc/interface-logic/store";
|
|
4496
4399
|
import {
|
|
4497
4400
|
evalJSONDomain,
|
|
@@ -4502,13 +4405,13 @@ var useListData = ({
|
|
|
4502
4405
|
context,
|
|
4503
4406
|
viewResponse
|
|
4504
4407
|
}) => {
|
|
4505
|
-
const { groupByDomain } =
|
|
4408
|
+
const { groupByDomain } = useAppSelector(selectSearch);
|
|
4506
4409
|
const initModel = useModel();
|
|
4507
|
-
const [type, setType] =
|
|
4508
|
-
const [mode, setMode] =
|
|
4509
|
-
const [currentDate, setCurrentDate] =
|
|
4510
|
-
const { pageLimit, page, order } =
|
|
4511
|
-
const listDataProps =
|
|
4410
|
+
const [type, setType] = useState2("list");
|
|
4411
|
+
const [mode, setMode] = useState2("month");
|
|
4412
|
+
const [currentDate, setCurrentDate] = useState2(/* @__PURE__ */ new Date());
|
|
4413
|
+
const { pageLimit, page, order } = useAppSelector(selectList);
|
|
4414
|
+
const listDataProps = useMemo2(() => {
|
|
4512
4415
|
const actData = action?.result;
|
|
4513
4416
|
if (!viewResponse || !actData || !context) {
|
|
4514
4417
|
return null;
|
|
@@ -4569,7 +4472,7 @@ var useListData = ({
|
|
|
4569
4472
|
};
|
|
4570
4473
|
|
|
4571
4474
|
// src/hooks/core/use-menu.ts
|
|
4572
|
-
import { useEffect as useEffect4, useMemo as
|
|
4475
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useState as useState3 } from "react";
|
|
4573
4476
|
|
|
4574
4477
|
// src/utils/constants.ts
|
|
4575
4478
|
var languages = [
|
|
@@ -4589,9 +4492,9 @@ var API_APP_URL = {
|
|
|
4589
4492
|
import { useGetMenu } from "@fctc/interface-logic/hooks";
|
|
4590
4493
|
var useMenu = ({ context }) => {
|
|
4591
4494
|
const menuData = useGetMenu(context, !!context);
|
|
4592
|
-
const [menuid, setMenuId] =
|
|
4495
|
+
const [menuid, setMenuId] = useState3(void 0);
|
|
4593
4496
|
const [action, setAction] = useCallAction();
|
|
4594
|
-
const configedIconData =
|
|
4497
|
+
const configedIconData = useMemo3(() => {
|
|
4595
4498
|
const data = menuData.data;
|
|
4596
4499
|
return data?.map((item) => {
|
|
4597
4500
|
return {
|
|
@@ -4638,7 +4541,7 @@ var useMenu = ({ context }) => {
|
|
|
4638
4541
|
|
|
4639
4542
|
// src/hooks/core/use-profile.ts
|
|
4640
4543
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
4641
|
-
import { useEffect as useEffect5, useMemo as
|
|
4544
|
+
import { useEffect as useEffect5, useMemo as useMemo4 } from "react";
|
|
4642
4545
|
import { useTranslation } from "react-i18next";
|
|
4643
4546
|
import { getEnv as getEnv3 } from "@fctc/interface-logic/environment";
|
|
4644
4547
|
import { useGetProfile } from "@fctc/interface-logic/hooks";
|
|
@@ -4666,7 +4569,7 @@ var useProfile = (accessToken) => {
|
|
|
4666
4569
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
4667
4570
|
}
|
|
4668
4571
|
}, [dispatch, userInfoQuery.data]);
|
|
4669
|
-
const context =
|
|
4572
|
+
const context = useMemo4(() => {
|
|
4670
4573
|
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
4671
4574
|
return {
|
|
4672
4575
|
uid: Number(userInfoQuery.data.sub),
|
|
@@ -4688,13 +4591,13 @@ var useUser = (accessToken) => {
|
|
|
4688
4591
|
};
|
|
4689
4592
|
|
|
4690
4593
|
// src/hooks/core/use-view-v2.ts
|
|
4691
|
-
import { useMemo as
|
|
4594
|
+
import { useMemo as useMemo5 } from "react";
|
|
4692
4595
|
import { useGetView } from "@fctc/interface-logic/hooks";
|
|
4693
4596
|
var useViewV2 = ({
|
|
4694
4597
|
action,
|
|
4695
4598
|
context
|
|
4696
4599
|
}) => {
|
|
4697
|
-
const viewParams =
|
|
4600
|
+
const viewParams = useMemo5(() => {
|
|
4698
4601
|
if (!action?.result) {
|
|
4699
4602
|
return void 0;
|
|
4700
4603
|
}
|
|
@@ -4769,11 +4672,12 @@ var useAuth = () => {
|
|
|
4769
4672
|
};
|
|
4770
4673
|
|
|
4771
4674
|
// src/hooks/core/use-app-provider.tsx
|
|
4772
|
-
import { createContext, useContext, useMemo as
|
|
4675
|
+
import { createContext, useContext, useMemo as useMemo7 } from "react";
|
|
4676
|
+
import { evalJSONContext } from "@fctc/interface-logic/utils";
|
|
4773
4677
|
|
|
4774
4678
|
// src/hooks/core/use-company.ts
|
|
4775
4679
|
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
4776
|
-
import { useEffect as useEffect6, useMemo as
|
|
4680
|
+
import { useEffect as useEffect6, useMemo as useMemo6 } from "react";
|
|
4777
4681
|
import { getEnv as getEnv4 } from "@fctc/interface-logic/environment";
|
|
4778
4682
|
import {
|
|
4779
4683
|
useGetCurrentCompany,
|
|
@@ -4789,7 +4693,7 @@ var useCompany = (accessToken) => {
|
|
|
4789
4693
|
queryFn: fetchCurrentCompany,
|
|
4790
4694
|
enabled: !!accessToken
|
|
4791
4695
|
});
|
|
4792
|
-
const current_company_id =
|
|
4696
|
+
const current_company_id = useMemo6(() => {
|
|
4793
4697
|
return currentCompany.data?.current_company_id;
|
|
4794
4698
|
}, [currentCompany.data]);
|
|
4795
4699
|
useEffect6(() => {
|
|
@@ -4821,10 +4725,8 @@ var useCompany = (accessToken) => {
|
|
|
4821
4725
|
context: { allowed_company_ids: [current_company_id] }
|
|
4822
4726
|
};
|
|
4823
4727
|
};
|
|
4824
|
-
var use_company_default = useCompany;
|
|
4825
4728
|
|
|
4826
4729
|
// src/hooks/core/use-app-provider.tsx
|
|
4827
|
-
import { evalJSONContext } from "@fctc/interface-logic/utils";
|
|
4828
4730
|
import { jsx } from "react/jsx-runtime";
|
|
4829
4731
|
var AppProviderInitialValue = {
|
|
4830
4732
|
config: {},
|
|
@@ -4841,15 +4743,15 @@ var AppProvider = ({ children }) => {
|
|
|
4841
4743
|
const config = useConfig({});
|
|
4842
4744
|
const auth = useAuth();
|
|
4843
4745
|
const user = useUser(auth.accessToken);
|
|
4844
|
-
const company =
|
|
4845
|
-
const menuContext =
|
|
4746
|
+
const company = useCompany(auth.accessToken);
|
|
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 getEnv5 } from "@fctc/interface-logic/environment";
|
|
4894
4796
|
import { useGetActionDetail } from "@fctc/interface-logic/hooks";
|
|
4895
|
-
import { useState as
|
|
4797
|
+
import { useState as useState4 } 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] = useState4("");
|
|
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 useEffect7, useRef, useState as useState5 } 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] = useState5([]);
|
|
4873
|
+
const lastRowIdsRef = useRef([]);
|
|
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
|
+
useEffect7(() => {
|
|
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 useEffect8, useRef as useRef2 } 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 = useRef2(null);
|
|
4964
|
-
|
|
4930
|
+
useEffect8(() => {
|
|
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 useEffect9, useState as useState6 } from "react";
|
|
4987
4953
|
function useDebounce(value, delay) {
|
|
4988
4954
|
const [debouncedValue, setDebouncedValue] = useState6(value);
|
|
4989
|
-
|
|
4955
|
+
useEffect9(() => {
|
|
4990
4956
|
const handler = setTimeout(() => {
|
|
4991
4957
|
setDebouncedValue(value);
|
|
4992
4958
|
}, delay);
|
|
@@ -5243,7 +5209,7 @@ var ChevronBottomIcon = ({
|
|
|
5243
5209
|
};
|
|
5244
5210
|
|
|
5245
5211
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
5246
|
-
import { useEffect as
|
|
5212
|
+
import { useEffect as useEffect10, useRef as useRef3, useState as useState7 } from "react";
|
|
5247
5213
|
import { getEnv as getEnv6 } from "@fctc/interface-logic/environment";
|
|
5248
5214
|
import { useSave } from "@fctc/interface-logic/hooks";
|
|
5249
5215
|
var statusDropdownController = (props) => {
|
|
@@ -5256,7 +5222,7 @@ var statusDropdownController = (props) => {
|
|
|
5256
5222
|
};
|
|
5257
5223
|
const [isOpen, setIsOpen] = useState7(false);
|
|
5258
5224
|
const buttonRef = useRef3(null);
|
|
5259
|
-
|
|
5225
|
+
useEffect10(() => {
|
|
5260
5226
|
const handleClickOutside = (event) => {
|
|
5261
5227
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
5262
5228
|
setIsOpen(false);
|
|
@@ -5297,7 +5263,12 @@ var statusDropdownController = (props) => {
|
|
|
5297
5263
|
};
|
|
5298
5264
|
|
|
5299
5265
|
// src/widget/basic/many2one-field/controller.ts
|
|
5300
|
-
import { useCallback as
|
|
5266
|
+
import { useCallback as useCallback3, useEffect as useEffect11, useMemo as useMemo8, useState as useState8 } from "react";
|
|
5267
|
+
|
|
5268
|
+
// src/store.ts
|
|
5269
|
+
var store_exports = {};
|
|
5270
|
+
__reExport(store_exports, store_star);
|
|
5271
|
+
import * as store_star from "@fctc/interface-logic/store";
|
|
5301
5272
|
|
|
5302
5273
|
// src/provider.ts
|
|
5303
5274
|
var provider_exports = {};
|
|
@@ -5357,18 +5328,18 @@ var many2oneFieldController = (props) => {
|
|
|
5357
5328
|
queryKey,
|
|
5358
5329
|
enabled: false
|
|
5359
5330
|
});
|
|
5360
|
-
const selectOptions =
|
|
5331
|
+
const selectOptions = useMemo8(() => {
|
|
5361
5332
|
return dataOfSelection?.records?.map((val) => ({
|
|
5362
5333
|
value: val?.id,
|
|
5363
5334
|
label: val?.display_name || val?.name
|
|
5364
5335
|
})) || [];
|
|
5365
5336
|
}, [dataOfSelection]);
|
|
5366
|
-
|
|
5337
|
+
useEffect11(() => {
|
|
5367
5338
|
setOptions(selectOptions);
|
|
5368
5339
|
setDomainModal(domainObject);
|
|
5369
5340
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5370
5341
|
}, [selectOptions]);
|
|
5371
|
-
|
|
5342
|
+
useEffect11(() => {
|
|
5372
5343
|
setDomainObject(
|
|
5373
5344
|
(0, utils_exports.evalJSONDomain)(
|
|
5374
5345
|
domain,
|
|
@@ -5376,7 +5347,7 @@ var many2oneFieldController = (props) => {
|
|
|
5376
5347
|
)
|
|
5377
5348
|
);
|
|
5378
5349
|
}, [domain, formValues]);
|
|
5379
|
-
|
|
5350
|
+
useEffect11(() => {
|
|
5380
5351
|
if (!propValue && tempSelectedOption) {
|
|
5381
5352
|
methods.setValue(name, null);
|
|
5382
5353
|
setTempSelectedOption(null);
|
|
@@ -5387,10 +5358,10 @@ var many2oneFieldController = (props) => {
|
|
|
5387
5358
|
});
|
|
5388
5359
|
}
|
|
5389
5360
|
}, [propValue]);
|
|
5390
|
-
const fetchMoreOptions =
|
|
5361
|
+
const fetchMoreOptions = useCallback3(() => {
|
|
5391
5362
|
refetch();
|
|
5392
5363
|
}, [refetch]);
|
|
5393
|
-
|
|
5364
|
+
useEffect11(() => {
|
|
5394
5365
|
if (debouncedInputValue) {
|
|
5395
5366
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5396
5367
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5405,7 +5376,7 @@ var many2oneFieldController = (props) => {
|
|
|
5405
5376
|
}, 50);
|
|
5406
5377
|
}
|
|
5407
5378
|
}, [debouncedInputValue]);
|
|
5408
|
-
const handleChooseRecord =
|
|
5379
|
+
const handleChooseRecord = useCallback3(
|
|
5409
5380
|
(idRecord) => {
|
|
5410
5381
|
const newOption = options.find(
|
|
5411
5382
|
(option) => option.value === idRecord
|
|
@@ -5430,8 +5401,8 @@ var many2oneFieldController = (props) => {
|
|
|
5430
5401
|
},
|
|
5431
5402
|
[options, methods, name, onChange]
|
|
5432
5403
|
);
|
|
5433
|
-
const handleClose =
|
|
5434
|
-
const handleSelectChange =
|
|
5404
|
+
const handleClose = useCallback3(() => setIsShowModalMany2Many(false), []);
|
|
5405
|
+
const handleSelectChange = useCallback3(
|
|
5435
5406
|
(selectedOption) => {
|
|
5436
5407
|
if (!selectedOption) {
|
|
5437
5408
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5505,7 +5476,7 @@ var many2oneButtonController = (props) => {
|
|
|
5505
5476
|
};
|
|
5506
5477
|
|
|
5507
5478
|
// src/widget/basic/many2many-field/controller.ts
|
|
5508
|
-
import { useEffect as
|
|
5479
|
+
import { useEffect as useEffect12, useMemo as useMemo9, useState as useState9 } from "react";
|
|
5509
5480
|
import {
|
|
5510
5481
|
evalJSONContext as evalJSONContext4,
|
|
5511
5482
|
evalJSONDomain as evalJSONDomain4,
|
|
@@ -5524,7 +5495,7 @@ var many2manyFieldController = (props) => {
|
|
|
5524
5495
|
actionData
|
|
5525
5496
|
} = props;
|
|
5526
5497
|
const { env } = (0, provider_exports.useEnv)();
|
|
5527
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5498
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView } = (0, provider_exports.useService)();
|
|
5528
5499
|
const [order, setOrder] = useState9();
|
|
5529
5500
|
const [page, setPage] = useState9(0);
|
|
5530
5501
|
const [domainMany2Many, setDomainMany2Many] = useState9(null);
|
|
@@ -5542,7 +5513,7 @@ var many2manyFieldController = (props) => {
|
|
|
5542
5513
|
context: contextObject
|
|
5543
5514
|
};
|
|
5544
5515
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5545
|
-
const baseModel =
|
|
5516
|
+
const baseModel = useMemo9(
|
|
5546
5517
|
() => ({
|
|
5547
5518
|
name: String(relation),
|
|
5548
5519
|
view: viewResponse || {},
|
|
@@ -5555,13 +5526,13 @@ var many2manyFieldController = (props) => {
|
|
|
5555
5526
|
[relation, viewResponse]
|
|
5556
5527
|
);
|
|
5557
5528
|
const initModel = (0, hooks_exports.useModel)();
|
|
5558
|
-
const modelInstance =
|
|
5529
|
+
const modelInstance = useMemo9(() => {
|
|
5559
5530
|
if (viewResponse) {
|
|
5560
5531
|
return initModel.initModel(baseModel);
|
|
5561
5532
|
}
|
|
5562
5533
|
return null;
|
|
5563
5534
|
}, [baseModel, viewResponse]);
|
|
5564
|
-
const specification =
|
|
5535
|
+
const specification = useMemo9(() => {
|
|
5565
5536
|
if (modelInstance) {
|
|
5566
5537
|
return modelInstance.getSpecification();
|
|
5567
5538
|
}
|
|
@@ -5603,8 +5574,8 @@ var many2manyFieldController = (props) => {
|
|
|
5603
5574
|
isLoading,
|
|
5604
5575
|
isFetched,
|
|
5605
5576
|
isPlaceholderData
|
|
5606
|
-
} =
|
|
5607
|
-
|
|
5577
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5578
|
+
useEffect12(() => {
|
|
5608
5579
|
if (viewResponse) {
|
|
5609
5580
|
fetchData();
|
|
5610
5581
|
}
|
|
@@ -5657,7 +5628,7 @@ var many2manyFieldController = (props) => {
|
|
|
5657
5628
|
};
|
|
5658
5629
|
|
|
5659
5630
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5660
|
-
import { useMemo as
|
|
5631
|
+
import { useMemo as useMemo10 } from "react";
|
|
5661
5632
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
5662
5633
|
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
5663
5634
|
var many2manyTagsController = (props) => {
|
|
@@ -5673,7 +5644,7 @@ var many2manyTagsController = (props) => {
|
|
|
5673
5644
|
const { env } = (0, provider_exports.useEnv)();
|
|
5674
5645
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5675
5646
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
5676
|
-
const domainObject =
|
|
5647
|
+
const domainObject = useMemo10(
|
|
5677
5648
|
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5678
5649
|
[domain, formValues]
|
|
5679
5650
|
);
|
|
@@ -5724,7 +5695,7 @@ var durationController = (props) => {
|
|
|
5724
5695
|
name: "",
|
|
5725
5696
|
fold: ""
|
|
5726
5697
|
};
|
|
5727
|
-
const { useGetListData:
|
|
5698
|
+
const { useGetListData: useGetListData2, useChangeStatus } = (0, provider_exports.useService)();
|
|
5728
5699
|
const { env } = (0, provider_exports.useEnv)();
|
|
5729
5700
|
const [disabled, setDisabled] = useState10(false);
|
|
5730
5701
|
const [modelStatus, setModalStatus] = useState10(false);
|
|
@@ -5742,7 +5713,7 @@ var durationController = (props) => {
|
|
|
5742
5713
|
},
|
|
5743
5714
|
sort: ""
|
|
5744
5715
|
};
|
|
5745
|
-
const { data: dataResponse } =
|
|
5716
|
+
const { data: dataResponse } = useGetListData2(
|
|
5746
5717
|
listDataProps,
|
|
5747
5718
|
queryKey,
|
|
5748
5719
|
enabled
|
|
@@ -6804,7 +6775,7 @@ var colorFieldController = (props) => {
|
|
|
6804
6775
|
};
|
|
6805
6776
|
|
|
6806
6777
|
// src/widget/basic/binary-field/controller.ts
|
|
6807
|
-
import { useEffect as
|
|
6778
|
+
import { useEffect as useEffect13, useId as useId2, useRef as useRef4, useState as useState13 } from "react";
|
|
6808
6779
|
import { isBase64Image } from "@fctc/interface-logic/utils";
|
|
6809
6780
|
var binaryFieldController = (props) => {
|
|
6810
6781
|
const { name, methods, readonly = false, value } = props;
|
|
@@ -6875,14 +6846,14 @@ var binaryFieldController = (props) => {
|
|
|
6875
6846
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6876
6847
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6877
6848
|
};
|
|
6878
|
-
|
|
6849
|
+
useEffect13(() => {
|
|
6879
6850
|
return () => {
|
|
6880
6851
|
if (selectedImage) {
|
|
6881
6852
|
URL.revokeObjectURL(selectedImage);
|
|
6882
6853
|
}
|
|
6883
6854
|
};
|
|
6884
6855
|
}, [selectedImage]);
|
|
6885
|
-
|
|
6856
|
+
useEffect13(() => {
|
|
6886
6857
|
if (binaryRef.current) {
|
|
6887
6858
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6888
6859
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6902,16 +6873,33 @@ var binaryFieldController = (props) => {
|
|
|
6902
6873
|
};
|
|
6903
6874
|
|
|
6904
6875
|
// 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";
|
|
6876
|
+
import { useAppDispatch as useAppDispatch5, setSelectedRowKeys } from "@fctc/interface-logic/store";
|
|
6877
|
+
import { useMemo as useMemo11, useRef as useRef5 } from "react";
|
|
6911
6878
|
var tableHeadController = (props) => {
|
|
6912
|
-
const { typeTable, rows,
|
|
6879
|
+
const { typeTable, rows, tableRef, groupByList, selectedRowKeys } = props;
|
|
6913
6880
|
const appDispatch = useAppDispatch5();
|
|
6914
|
-
const {
|
|
6881
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6882
|
+
const selectedRowKeysRef = useRef5(recordIds);
|
|
6883
|
+
const isGroupTable = typeTable === "group";
|
|
6884
|
+
const recordsCheckedGroup = useMemo11(() => {
|
|
6885
|
+
if (!rows || !groupByList) return 0;
|
|
6886
|
+
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6887
|
+
return countSum(rows, groupBy);
|
|
6888
|
+
}, [rows, groupByList]);
|
|
6889
|
+
const isAllGroupChecked = useMemo11(() => {
|
|
6890
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6891
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6892
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6893
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6894
|
+
return allGroupsSelected || allRecordsSelected;
|
|
6895
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6896
|
+
const isAllNormalChecked = useMemo11(() => {
|
|
6897
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6898
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6899
|
+
(id) => rows.some((record) => record.id === id)
|
|
6900
|
+
);
|
|
6901
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6902
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6915
6903
|
const handleCheckBoxAll = (event) => {
|
|
6916
6904
|
if (event?.target?.checked && typeTable === "list") {
|
|
6917
6905
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
@@ -6926,7 +6914,7 @@ var tableHeadController = (props) => {
|
|
|
6926
6914
|
} else {
|
|
6927
6915
|
const sum = countSum(
|
|
6928
6916
|
rows,
|
|
6929
|
-
typeof
|
|
6917
|
+
typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0
|
|
6930
6918
|
);
|
|
6931
6919
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6932
6920
|
appDispatch(setSelectedRowKeys(keys));
|
|
@@ -6939,22 +6927,19 @@ var tableHeadController = (props) => {
|
|
|
6939
6927
|
}
|
|
6940
6928
|
};
|
|
6941
6929
|
return {
|
|
6942
|
-
handleCheckBoxAll
|
|
6930
|
+
handleCheckBoxAll,
|
|
6931
|
+
checkedAll,
|
|
6932
|
+
selectedRowKeysRef
|
|
6943
6933
|
};
|
|
6944
6934
|
};
|
|
6945
6935
|
|
|
6946
6936
|
// 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";
|
|
6937
|
+
import { useEffect as useEffect14, useState as useState14 } from "react";
|
|
6953
6938
|
import { domainHelper } from "@fctc/interface-logic/utils";
|
|
6954
6939
|
var tableController = ({ data }) => {
|
|
6955
|
-
const [rows, setRows] = useState14(
|
|
6956
|
-
const [columns, setColumns] = useState14(
|
|
6957
|
-
const dataModelFields = data
|
|
6940
|
+
const [rows, setRows] = useState14(null);
|
|
6941
|
+
const [columns, setColumns] = useState14(null);
|
|
6942
|
+
const dataModelFields = data?.fields?.map((field) => {
|
|
6958
6943
|
return {
|
|
6959
6944
|
...data.dataModel?.[field?.name],
|
|
6960
6945
|
...field,
|
|
@@ -6981,8 +6966,8 @@ var tableController = ({ data }) => {
|
|
|
6981
6966
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6982
6967
|
});
|
|
6983
6968
|
};
|
|
6984
|
-
|
|
6985
|
-
setRows(transformData(data.records
|
|
6969
|
+
useEffect14(() => {
|
|
6970
|
+
setRows(transformData(data.records));
|
|
6986
6971
|
}, [data.records]);
|
|
6987
6972
|
const handleGetColumns = () => {
|
|
6988
6973
|
let cols = [];
|
|
@@ -7002,10 +6987,11 @@ var tableController = ({ data }) => {
|
|
|
7002
6987
|
}
|
|
7003
6988
|
return cols;
|
|
7004
6989
|
};
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
6990
|
+
useEffect14(() => {
|
|
6991
|
+
if (!columns) {
|
|
6992
|
+
setColumns(handleGetColumns());
|
|
6993
|
+
}
|
|
6994
|
+
}, [data]);
|
|
7009
6995
|
const onToggleColumnOptional = (item) => {
|
|
7010
6996
|
const tempColumn = [...columns]?.map((val) => {
|
|
7011
6997
|
if (item?.name === val?.name) {
|
|
@@ -7018,6 +7004,14 @@ var tableController = ({ data }) => {
|
|
|
7018
7004
|
});
|
|
7019
7005
|
setColumns(tempColumn);
|
|
7020
7006
|
};
|
|
7007
|
+
useEffect14(() => {
|
|
7008
|
+
setRows(null);
|
|
7009
|
+
setColumns(null);
|
|
7010
|
+
return () => {
|
|
7011
|
+
setRows(null);
|
|
7012
|
+
setColumns(null);
|
|
7013
|
+
};
|
|
7014
|
+
}, [data?.fields]);
|
|
7021
7015
|
return {
|
|
7022
7016
|
rows,
|
|
7023
7017
|
columns,
|
|
@@ -7027,57 +7021,35 @@ var tableController = ({ data }) => {
|
|
|
7027
7021
|
};
|
|
7028
7022
|
|
|
7029
7023
|
// src/widget/advance/table/table-group/controller.ts
|
|
7030
|
-
import { useEffect as
|
|
7024
|
+
import { useEffect as useEffect15, useMemo as useMemo12, useState as useState15 } from "react";
|
|
7031
7025
|
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
|
|
7026
|
+
useAppSelector as useAppSelector3,
|
|
7027
|
+
selectList as selectList2
|
|
7041
7028
|
} 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
7029
|
var tableGroupController = (props) => {
|
|
7050
|
-
const env = (0,
|
|
7030
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
7031
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
7051
7032
|
const {
|
|
7052
|
-
rows,
|
|
7053
7033
|
columns,
|
|
7054
|
-
indexRow,
|
|
7055
7034
|
row,
|
|
7056
7035
|
model,
|
|
7057
7036
|
viewData,
|
|
7058
|
-
renderField,
|
|
7059
7037
|
level,
|
|
7060
7038
|
specification,
|
|
7061
|
-
domain,
|
|
7062
7039
|
context,
|
|
7063
7040
|
checkedAll,
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
setIsAutoSelect,
|
|
7067
|
-
selectedRowKeysRef
|
|
7041
|
+
groupByList,
|
|
7042
|
+
setSelectedRowKeys: setSelectedRowKeys3
|
|
7068
7043
|
} = props;
|
|
7069
7044
|
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);
|
|
7045
|
+
const { selectedRowKeys } = useAppSelector3(selectList2);
|
|
7075
7046
|
const [isShowGroup, setIsShowGroup] = useState15(false);
|
|
7076
7047
|
const [colEmptyGroup, setColEmptyGroup] = useState15({
|
|
7077
7048
|
fromStart: 1,
|
|
7078
7049
|
fromEnd: 1
|
|
7079
7050
|
});
|
|
7080
|
-
const
|
|
7051
|
+
const domain = row?.__domain;
|
|
7052
|
+
const processedData = useMemo12(() => {
|
|
7081
7053
|
const calculateColSpanEmpty = () => {
|
|
7082
7054
|
const startIndex = columns.findIndex(
|
|
7083
7055
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -7092,7 +7064,7 @@ var tableGroupController = (props) => {
|
|
|
7092
7064
|
};
|
|
7093
7065
|
return calculateColSpanEmpty();
|
|
7094
7066
|
}, [columns, row]);
|
|
7095
|
-
const shouldFetchData =
|
|
7067
|
+
const shouldFetchData = useMemo12(() => {
|
|
7096
7068
|
return !!isShowGroup;
|
|
7097
7069
|
}, [isShowGroup]);
|
|
7098
7070
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -7102,21 +7074,21 @@ var tableGroupController = (props) => {
|
|
|
7102
7074
|
domain,
|
|
7103
7075
|
context,
|
|
7104
7076
|
offset: pageGroup * 10,
|
|
7105
|
-
fields:
|
|
7106
|
-
groupby: [
|
|
7077
|
+
fields: groupByList?.fields,
|
|
7078
|
+
groupby: [groupByList?.contexts[level]?.group_by]
|
|
7107
7079
|
};
|
|
7108
7080
|
const queryKey = [
|
|
7109
|
-
`data-${model}
|
|
7081
|
+
`data-${model}-level_${level}-row-${row?.id}`,
|
|
7110
7082
|
specification,
|
|
7111
7083
|
domain,
|
|
7112
7084
|
pageGroup
|
|
7113
7085
|
];
|
|
7114
7086
|
const {
|
|
7115
|
-
data:
|
|
7116
|
-
isFetched:
|
|
7117
|
-
isPlaceholderData,
|
|
7087
|
+
data: dataGroup,
|
|
7088
|
+
isFetched: isDataGroupFetched,
|
|
7118
7089
|
isLoading,
|
|
7119
|
-
isFetching
|
|
7090
|
+
isFetching,
|
|
7091
|
+
isPlaceholderData: isDataPlaceHolder
|
|
7120
7092
|
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
7121
7093
|
const {
|
|
7122
7094
|
columns: columnsGroup,
|
|
@@ -7125,27 +7097,21 @@ var tableGroupController = (props) => {
|
|
|
7125
7097
|
} = tableController({
|
|
7126
7098
|
data: {
|
|
7127
7099
|
fields: viewData?.views?.list?.fields,
|
|
7128
|
-
records:
|
|
7100
|
+
records: dataGroup?.records ?? dataGroup?.groups,
|
|
7129
7101
|
dataModel: viewData?.models?.[model],
|
|
7130
7102
|
context: env.context,
|
|
7131
|
-
typeTable:
|
|
7103
|
+
typeTable: dataGroup?.groups ? "group" : "list"
|
|
7132
7104
|
}
|
|
7133
7105
|
});
|
|
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;
|
|
7106
|
+
const group_by_field_name = groupByList?.contexts[level - 1]?.group_by;
|
|
7141
7107
|
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
7108
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
7143
7109
|
)?.[1] : row[group_by_field_name];
|
|
7144
7110
|
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
7111
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
7146
|
-
const
|
|
7112
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7113
|
+
const onExpandChildGroup = () => {
|
|
7147
7114
|
if (isLoading || isFetching) return;
|
|
7148
|
-
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7149
7115
|
if (allIdsNull || typeTableGroup === "group") {
|
|
7150
7116
|
toggleShowGroup();
|
|
7151
7117
|
return;
|
|
@@ -7155,53 +7121,39 @@ var tableGroupController = (props) => {
|
|
|
7155
7121
|
const filteredIds = selectedRowKeys.filter(
|
|
7156
7122
|
(id) => !ids.includes(id)
|
|
7157
7123
|
);
|
|
7158
|
-
|
|
7159
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull
|
|
7124
|
+
setSelectedRowKeys3(filteredIds);
|
|
7125
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
7160
7126
|
const clonedKeys = [...selectedRowKeys];
|
|
7161
|
-
|
|
7162
|
-
setTimeout(() =>
|
|
7127
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7128
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7163
7129
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7130
|
+
console.log("abc");
|
|
7164
7131
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7165
|
-
|
|
7132
|
+
setSelectedRowKeys3(filteredKeys);
|
|
7166
7133
|
}
|
|
7167
7134
|
toggleShowGroup();
|
|
7168
7135
|
};
|
|
7169
|
-
|
|
7170
|
-
if (!
|
|
7136
|
+
useEffect15(() => {
|
|
7137
|
+
if (!isDataGroupFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
7171
7138
|
return;
|
|
7172
7139
|
}
|
|
7173
7140
|
const clonedKeys = [...selectedRowKeys];
|
|
7174
|
-
|
|
7175
|
-
setTimeout(() =>
|
|
7176
|
-
}, [
|
|
7141
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7142
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7143
|
+
}, [isDataGroupFetched]);
|
|
7177
7144
|
return {
|
|
7178
|
-
|
|
7145
|
+
onExpandChildGroup,
|
|
7179
7146
|
colEmptyGroup,
|
|
7180
|
-
leftPadding,
|
|
7181
7147
|
isShowGroup,
|
|
7182
|
-
|
|
7148
|
+
isDataGroupFetched,
|
|
7149
|
+
isDataPlaceHolder,
|
|
7183
7150
|
nameGroupWithCount,
|
|
7184
|
-
columns,
|
|
7185
|
-
row,
|
|
7186
|
-
isPlaceholderData,
|
|
7187
7151
|
columnsGroup,
|
|
7188
|
-
indexRow,
|
|
7189
7152
|
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,
|
|
7153
|
+
dataGroup,
|
|
7203
7154
|
pageGroup,
|
|
7204
|
-
setPageGroup
|
|
7155
|
+
setPageGroup,
|
|
7156
|
+
typeTableGroup
|
|
7205
7157
|
};
|
|
7206
7158
|
};
|
|
7207
7159
|
|
|
@@ -7214,7 +7166,7 @@ import {
|
|
|
7214
7166
|
evalJSONDomain as evalJSONDomain7,
|
|
7215
7167
|
validateAndParseDate
|
|
7216
7168
|
} from "@fctc/interface-logic/utils";
|
|
7217
|
-
import { useCallback as
|
|
7169
|
+
import { useCallback as useCallback4, useEffect as useEffect16, useState as useState16 } from "react";
|
|
7218
7170
|
var searchController = ({
|
|
7219
7171
|
viewData,
|
|
7220
7172
|
model,
|
|
@@ -7275,7 +7227,7 @@ var searchController = ({
|
|
|
7275
7227
|
}
|
|
7276
7228
|
}
|
|
7277
7229
|
};
|
|
7278
|
-
|
|
7230
|
+
useEffect16(() => {
|
|
7279
7231
|
fetchData();
|
|
7280
7232
|
}, [model, viewData]);
|
|
7281
7233
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7357,7 +7309,7 @@ var searchController = ({
|
|
|
7357
7309
|
return [...domain2];
|
|
7358
7310
|
}
|
|
7359
7311
|
};
|
|
7360
|
-
const setTagSearch =
|
|
7312
|
+
const setTagSearch = useCallback4(
|
|
7361
7313
|
(updatedMap) => {
|
|
7362
7314
|
if (!updatedMap) return;
|
|
7363
7315
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7420,7 +7372,7 @@ var searchController = ({
|
|
|
7420
7372
|
},
|
|
7421
7373
|
[searchMap]
|
|
7422
7374
|
);
|
|
7423
|
-
|
|
7375
|
+
useEffect16(() => {
|
|
7424
7376
|
setTagSearch(searchMap);
|
|
7425
7377
|
}, [searchMap]);
|
|
7426
7378
|
const handleAddTagSearch = (tag) => {
|
|
@@ -7488,6 +7440,13 @@ import * as constants_star from "@fctc/interface-logic/constants";
|
|
|
7488
7440
|
|
|
7489
7441
|
// src/index.ts
|
|
7490
7442
|
__reExport(index_exports, constants_exports);
|
|
7443
|
+
|
|
7444
|
+
// src/environment.ts
|
|
7445
|
+
var environment_exports = {};
|
|
7446
|
+
__reExport(environment_exports, environment_star);
|
|
7447
|
+
import * as environment_star from "@fctc/interface-logic/environment";
|
|
7448
|
+
|
|
7449
|
+
// src/index.ts
|
|
7491
7450
|
__reExport(index_exports, environment_exports);
|
|
7492
7451
|
__reExport(index_exports, provider_exports);
|
|
7493
7452
|
|
|
@@ -7547,6 +7506,7 @@ export {
|
|
|
7547
7506
|
useAuth,
|
|
7548
7507
|
useCallAction,
|
|
7549
7508
|
useClickOutside,
|
|
7509
|
+
useCompany,
|
|
7550
7510
|
useConfig,
|
|
7551
7511
|
useDebounce,
|
|
7552
7512
|
useDetail,
|
|
@@ -7555,7 +7515,6 @@ export {
|
|
|
7555
7515
|
useMenu,
|
|
7556
7516
|
useMenuItem,
|
|
7557
7517
|
useProfile,
|
|
7558
|
-
useSelectionState,
|
|
7559
7518
|
useStorageState,
|
|
7560
7519
|
useUser,
|
|
7561
7520
|
useViewV2
|