@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.js
CHANGED
|
@@ -37,7 +37,7 @@ var require_moment = __commonJS({
|
|
|
37
37
|
"use strict";
|
|
38
38
|
(function(global, factory) {
|
|
39
39
|
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.moment = factory();
|
|
40
|
-
})(exports2, function() {
|
|
40
|
+
})(exports2, (function() {
|
|
41
41
|
"use strict";
|
|
42
42
|
var hookCallback;
|
|
43
43
|
function hooks() {
|
|
@@ -4028,7 +4028,7 @@ var require_moment = __commonJS({
|
|
|
4028
4028
|
// <input type="month" />
|
|
4029
4029
|
};
|
|
4030
4030
|
return hooks;
|
|
4031
|
-
});
|
|
4031
|
+
}));
|
|
4032
4032
|
}
|
|
4033
4033
|
});
|
|
4034
4034
|
|
|
@@ -4075,6 +4075,7 @@ __export(index_exports, {
|
|
|
4075
4075
|
useAuth: () => useAuth,
|
|
4076
4076
|
useCallAction: () => useCallAction,
|
|
4077
4077
|
useClickOutside: () => useClickOutside,
|
|
4078
|
+
useCompany: () => useCompany,
|
|
4078
4079
|
useConfig: () => useConfig,
|
|
4079
4080
|
useDebounce: () => useDebounce,
|
|
4080
4081
|
useDetail: () => useDetail,
|
|
@@ -4083,7 +4084,6 @@ __export(index_exports, {
|
|
|
4083
4084
|
useMenu: () => useMenu,
|
|
4084
4085
|
useMenuItem: () => useMenuItem,
|
|
4085
4086
|
useProfile: () => useProfile,
|
|
4086
|
-
useSelectionState: () => useSelectionState,
|
|
4087
4087
|
useStorageState: () => useStorageState,
|
|
4088
4088
|
useUser: () => useUser,
|
|
4089
4089
|
useViewV2: () => useViewV2
|
|
@@ -4098,9 +4098,11 @@ __export(hooks_exports, {
|
|
|
4098
4098
|
useAuth: () => useAuth,
|
|
4099
4099
|
useCallAction: () => useCallAction,
|
|
4100
4100
|
useClickOutside: () => useClickOutside,
|
|
4101
|
+
useCompany: () => useCompany,
|
|
4101
4102
|
useConfig: () => useConfig,
|
|
4102
4103
|
useDebounce: () => useDebounce,
|
|
4103
4104
|
useDetail: () => useDetail,
|
|
4105
|
+
useGetRowIds: () => useGetRowIds,
|
|
4104
4106
|
useListData: () => useListData,
|
|
4105
4107
|
useMenu: () => useMenu,
|
|
4106
4108
|
useMenuItem: () => useMenuItem,
|
|
@@ -4228,12 +4230,6 @@ var import_react5 = require("react");
|
|
|
4228
4230
|
|
|
4229
4231
|
// src/utils/function.ts
|
|
4230
4232
|
var import_react4 = require("react");
|
|
4231
|
-
|
|
4232
|
-
// src/store.ts
|
|
4233
|
-
var store_exports = {};
|
|
4234
|
-
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4235
|
-
|
|
4236
|
-
// src/utils/function.ts
|
|
4237
4233
|
var countSum = (data, field) => {
|
|
4238
4234
|
if (!data || !field) return 0;
|
|
4239
4235
|
return data.reduce(
|
|
@@ -4252,91 +4248,6 @@ function mergeButtons(fields) {
|
|
|
4252
4248
|
}
|
|
4253
4249
|
return others;
|
|
4254
4250
|
}
|
|
4255
|
-
function isElementVisible(el) {
|
|
4256
|
-
const style = window.getComputedStyle(el);
|
|
4257
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4258
|
-
}
|
|
4259
|
-
function arraysAreEqual(a, b) {
|
|
4260
|
-
if (a.length !== b.length) return false;
|
|
4261
|
-
const setA = new Set(a);
|
|
4262
|
-
const setB = new Set(b);
|
|
4263
|
-
if (setA.size !== setB.size) return false;
|
|
4264
|
-
for (const val of setA) {
|
|
4265
|
-
if (!setB.has(val)) return false;
|
|
4266
|
-
}
|
|
4267
|
-
return true;
|
|
4268
|
-
}
|
|
4269
|
-
function useGetRowIds(tableRef) {
|
|
4270
|
-
const [rowIds, setRowIds] = (0, import_react4.useState)([]);
|
|
4271
|
-
const lastRowIdsRef = (0, import_react4.useRef)([]);
|
|
4272
|
-
const updateVisibleRowIds = (0, import_react4.useCallback)(() => {
|
|
4273
|
-
const table = tableRef?.current;
|
|
4274
|
-
if (!table) return;
|
|
4275
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4276
|
-
const ids = [];
|
|
4277
|
-
rows.forEach((row) => {
|
|
4278
|
-
const el = row;
|
|
4279
|
-
if (isElementVisible(el)) {
|
|
4280
|
-
const id = el.getAttribute("data-row-id");
|
|
4281
|
-
if (id) ids.push(id);
|
|
4282
|
-
}
|
|
4283
|
-
});
|
|
4284
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4285
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4286
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4287
|
-
setRowIds(uniqueIds);
|
|
4288
|
-
}
|
|
4289
|
-
}, [tableRef]);
|
|
4290
|
-
(0, import_react4.useEffect)(() => {
|
|
4291
|
-
const table = tableRef?.current;
|
|
4292
|
-
if (!table) return;
|
|
4293
|
-
const observer = new MutationObserver(() => {
|
|
4294
|
-
updateVisibleRowIds();
|
|
4295
|
-
});
|
|
4296
|
-
observer.observe(table, {
|
|
4297
|
-
childList: true,
|
|
4298
|
-
subtree: true,
|
|
4299
|
-
attributes: true,
|
|
4300
|
-
attributeFilter: ["style", "class"]
|
|
4301
|
-
});
|
|
4302
|
-
updateVisibleRowIds();
|
|
4303
|
-
return () => {
|
|
4304
|
-
observer.disconnect();
|
|
4305
|
-
};
|
|
4306
|
-
}, [updateVisibleRowIds, tableRef]);
|
|
4307
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4308
|
-
}
|
|
4309
|
-
var useSelectionState = ({
|
|
4310
|
-
typeTable,
|
|
4311
|
-
tableRef,
|
|
4312
|
-
rows
|
|
4313
|
-
}) => {
|
|
4314
|
-
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
4315
|
-
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
4316
|
-
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
4317
|
-
const selectedRowKeysRef = (0, import_react4.useRef)(recordIds);
|
|
4318
|
-
const isGroupTable = typeTable === "group";
|
|
4319
|
-
const recordsCheckedGroup = (0, import_react4.useMemo)(() => {
|
|
4320
|
-
if (!rows || !groupByDomain) return 0;
|
|
4321
|
-
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
4322
|
-
return countSum(rows, groupBy);
|
|
4323
|
-
}, [rows, groupByDomain]);
|
|
4324
|
-
const isAllGroupChecked = (0, import_react4.useMemo)(() => {
|
|
4325
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
4326
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
4327
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
4328
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
4329
|
-
return allGroupsSelected || allRecordsSelected;
|
|
4330
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
4331
|
-
const isAllNormalChecked = (0, import_react4.useMemo)(() => {
|
|
4332
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
4333
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
4334
|
-
(id) => rows.some((record) => record.id === id)
|
|
4335
|
-
);
|
|
4336
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
4337
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
4338
|
-
return { checkedAll, selectedRowKeysRef };
|
|
4339
|
-
};
|
|
4340
4251
|
var getDateRange = (currentDate, unit) => {
|
|
4341
4252
|
const date = new Date(currentDate);
|
|
4342
4253
|
let dateStart, dateEnd;
|
|
@@ -4477,19 +4388,19 @@ function useStorageState(key) {
|
|
|
4477
4388
|
|
|
4478
4389
|
// src/hooks/core/use-list-data.ts
|
|
4479
4390
|
var import_hooks3 = require("@fctc/interface-logic/hooks");
|
|
4480
|
-
var
|
|
4391
|
+
var import_store3 = require("@fctc/interface-logic/store");
|
|
4481
4392
|
var import_utils = require("@fctc/interface-logic/utils");
|
|
4482
4393
|
var useListData = ({
|
|
4483
4394
|
action,
|
|
4484
4395
|
context,
|
|
4485
4396
|
viewResponse
|
|
4486
4397
|
}) => {
|
|
4487
|
-
const { groupByDomain } = (0,
|
|
4398
|
+
const { groupByDomain } = (0, import_store3.useAppSelector)(import_store3.selectSearch);
|
|
4488
4399
|
const initModel = (0, import_hooks3.useModel)();
|
|
4489
4400
|
const [type, setType] = (0, import_react5.useState)("list");
|
|
4490
4401
|
const [mode, setMode] = (0, import_react5.useState)("month");
|
|
4491
4402
|
const [currentDate, setCurrentDate] = (0, import_react5.useState)(/* @__PURE__ */ new Date());
|
|
4492
|
-
const { pageLimit, page, order } = (0,
|
|
4403
|
+
const { pageLimit, page, order } = (0, import_store3.useAppSelector)(import_store3.selectList);
|
|
4493
4404
|
const listDataProps = (0, import_react5.useMemo)(() => {
|
|
4494
4405
|
const actData = action?.result;
|
|
4495
4406
|
if (!viewResponse || !actData || !context) {
|
|
@@ -4624,10 +4535,10 @@ var import_react7 = require("react");
|
|
|
4624
4535
|
var import_react_i18next = require("react-i18next");
|
|
4625
4536
|
var import_environment3 = require("@fctc/interface-logic/environment");
|
|
4626
4537
|
var import_hooks5 = require("@fctc/interface-logic/hooks");
|
|
4627
|
-
var
|
|
4538
|
+
var import_store4 = require("@fctc/interface-logic/store");
|
|
4628
4539
|
var useProfile = (accessToken) => {
|
|
4629
4540
|
const getProfile = (0, import_hooks5.useGetProfile)();
|
|
4630
|
-
const dispatch = (0,
|
|
4541
|
+
const dispatch = (0, import_store4.useAppDispatch)();
|
|
4631
4542
|
const { i18n: i18n2 } = (0, import_react_i18next.useTranslation)();
|
|
4632
4543
|
const fetchUserProfile = async () => {
|
|
4633
4544
|
return await getProfile.mutateAsync();
|
|
@@ -4642,7 +4553,7 @@ var useProfile = (accessToken) => {
|
|
|
4642
4553
|
const userInfo = userInfoQuery.data;
|
|
4643
4554
|
const env = (0, import_environment3.getEnv)();
|
|
4644
4555
|
env.setUid(userInfo?.sub);
|
|
4645
|
-
dispatch((0,
|
|
4556
|
+
dispatch((0, import_store4.setDataUser)(userInfo));
|
|
4646
4557
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
4647
4558
|
env.setLang(userLocale?.id);
|
|
4648
4559
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
@@ -4707,11 +4618,11 @@ var useViewV2 = ({
|
|
|
4707
4618
|
|
|
4708
4619
|
// src/hooks/core/use-auth.ts
|
|
4709
4620
|
var import_hooks7 = require("@fctc/interface-logic/hooks");
|
|
4710
|
-
var
|
|
4621
|
+
var import_store5 = require("@fctc/interface-logic/store");
|
|
4711
4622
|
var useAuth = () => {
|
|
4712
4623
|
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
4713
4624
|
const loginMutate = (0, import_hooks7.useLoginCredential)();
|
|
4714
|
-
const dispatch = (0,
|
|
4625
|
+
const dispatch = (0, import_store5.useAppDispatch)();
|
|
4715
4626
|
const signIn = async (email, password) => {
|
|
4716
4627
|
try {
|
|
4717
4628
|
loginMutate.mutate(
|
|
@@ -4732,9 +4643,9 @@ var useAuth = () => {
|
|
|
4732
4643
|
}
|
|
4733
4644
|
};
|
|
4734
4645
|
const signOut = async () => {
|
|
4735
|
-
dispatch((0,
|
|
4736
|
-
dispatch((0,
|
|
4737
|
-
dispatch((0,
|
|
4646
|
+
dispatch((0, import_store5.setMenuList)([]));
|
|
4647
|
+
dispatch((0, import_store5.setDataUser)({}));
|
|
4648
|
+
dispatch((0, import_store5.setProfile)({}));
|
|
4738
4649
|
setAccessToken(null);
|
|
4739
4650
|
};
|
|
4740
4651
|
return {
|
|
@@ -4747,6 +4658,7 @@ var useAuth = () => {
|
|
|
4747
4658
|
|
|
4748
4659
|
// src/hooks/core/use-app-provider.tsx
|
|
4749
4660
|
var import_react10 = require("react");
|
|
4661
|
+
var import_utils2 = require("@fctc/interface-logic/utils");
|
|
4750
4662
|
|
|
4751
4663
|
// src/hooks/core/use-company.ts
|
|
4752
4664
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -4795,10 +4707,8 @@ var useCompany = (accessToken) => {
|
|
|
4795
4707
|
context: { allowed_company_ids: [current_company_id] }
|
|
4796
4708
|
};
|
|
4797
4709
|
};
|
|
4798
|
-
var use_company_default = useCompany;
|
|
4799
4710
|
|
|
4800
4711
|
// src/hooks/core/use-app-provider.tsx
|
|
4801
|
-
var import_utils2 = require("@fctc/interface-logic/utils");
|
|
4802
4712
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
4803
4713
|
var AppProviderInitialValue = {
|
|
4804
4714
|
config: {},
|
|
@@ -4815,7 +4725,7 @@ var AppProvider = ({ children }) => {
|
|
|
4815
4725
|
const config = useConfig({});
|
|
4816
4726
|
const auth = useAuth();
|
|
4817
4727
|
const user = useUser(auth.accessToken);
|
|
4818
|
-
const company =
|
|
4728
|
+
const company = useCompany(auth.accessToken);
|
|
4819
4729
|
const menuContext = (0, import_react10.useMemo)(() => {
|
|
4820
4730
|
return combineContexts([user.context, company.context]);
|
|
4821
4731
|
}, [user.context, company.context]);
|
|
@@ -4881,8 +4791,6 @@ __export(utils_exports, {
|
|
|
4881
4791
|
languages: () => languages,
|
|
4882
4792
|
mergeButtons: () => mergeButtons,
|
|
4883
4793
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4884
|
-
useGetRowIds: () => useGetRowIds,
|
|
4885
|
-
useSelectionState: () => useSelectionState,
|
|
4886
4794
|
useStorageState: () => useStorageState
|
|
4887
4795
|
});
|
|
4888
4796
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
@@ -4924,8 +4832,74 @@ var useMenuItem = (props) => {
|
|
|
4924
4832
|
return { handleClick, path, queryActionDetail };
|
|
4925
4833
|
};
|
|
4926
4834
|
|
|
4927
|
-
// src/hooks/
|
|
4835
|
+
// src/hooks/core/use-get-rowids.ts
|
|
4928
4836
|
var import_react12 = require("react");
|
|
4837
|
+
var useGetRowIds = (tableRef) => {
|
|
4838
|
+
function isElementVisible(el) {
|
|
4839
|
+
const style = window.getComputedStyle(el);
|
|
4840
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4841
|
+
}
|
|
4842
|
+
function arraysAreEqual(a, b) {
|
|
4843
|
+
if (a.length !== b.length) return false;
|
|
4844
|
+
if (a.length === 0 && b.length === 0) return true;
|
|
4845
|
+
const setA = new Set(a);
|
|
4846
|
+
const setB = new Set(b);
|
|
4847
|
+
if (setA.size !== setB.size) return false;
|
|
4848
|
+
for (const val of setA) {
|
|
4849
|
+
if (!setB.has(val)) return false;
|
|
4850
|
+
}
|
|
4851
|
+
return true;
|
|
4852
|
+
}
|
|
4853
|
+
const [rowIds, setRowIds] = (0, import_react12.useState)([]);
|
|
4854
|
+
const lastRowIdsRef = (0, import_react12.useRef)([]);
|
|
4855
|
+
const updateVisibleRowIds = (0, import_react12.useCallback)(() => {
|
|
4856
|
+
const table = tableRef.current;
|
|
4857
|
+
if (!table) return;
|
|
4858
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4859
|
+
const ids = [];
|
|
4860
|
+
rows.forEach((row) => {
|
|
4861
|
+
const el = row;
|
|
4862
|
+
if (isElementVisible(el)) {
|
|
4863
|
+
const id = el.getAttribute("data-row-id");
|
|
4864
|
+
if (id) ids.push(id);
|
|
4865
|
+
}
|
|
4866
|
+
});
|
|
4867
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4868
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4869
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4870
|
+
setRowIds(uniqueIds);
|
|
4871
|
+
}
|
|
4872
|
+
}, [tableRef]);
|
|
4873
|
+
(0, import_react12.useEffect)(() => {
|
|
4874
|
+
const table = tableRef.current;
|
|
4875
|
+
if (!table) return;
|
|
4876
|
+
const mutationObserver = new MutationObserver(() => {
|
|
4877
|
+
updateVisibleRowIds();
|
|
4878
|
+
});
|
|
4879
|
+
mutationObserver.observe(table, {
|
|
4880
|
+
childList: true,
|
|
4881
|
+
subtree: true,
|
|
4882
|
+
attributes: true,
|
|
4883
|
+
attributeFilter: ["style", "class"]
|
|
4884
|
+
});
|
|
4885
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4886
|
+
updateVisibleRowIds();
|
|
4887
|
+
});
|
|
4888
|
+
resizeObserver.observe(table);
|
|
4889
|
+
const handleScroll = () => updateVisibleRowIds();
|
|
4890
|
+
table.addEventListener("scroll", handleScroll, true);
|
|
4891
|
+
updateVisibleRowIds();
|
|
4892
|
+
return () => {
|
|
4893
|
+
mutationObserver.disconnect();
|
|
4894
|
+
resizeObserver.disconnect();
|
|
4895
|
+
table.removeEventListener("scroll", handleScroll, true);
|
|
4896
|
+
};
|
|
4897
|
+
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4898
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4899
|
+
};
|
|
4900
|
+
|
|
4901
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4902
|
+
var import_react13 = require("react");
|
|
4929
4903
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4930
4904
|
var useClickOutside = ({
|
|
4931
4905
|
handler,
|
|
@@ -4933,8 +4907,8 @@ var useClickOutside = ({
|
|
|
4933
4907
|
nodes = [],
|
|
4934
4908
|
refs
|
|
4935
4909
|
}) => {
|
|
4936
|
-
const ref = (0,
|
|
4937
|
-
(0,
|
|
4910
|
+
const ref = (0, import_react13.useRef)(null);
|
|
4911
|
+
(0, import_react13.useEffect)(() => {
|
|
4938
4912
|
const listener = (event) => {
|
|
4939
4913
|
const { target } = event;
|
|
4940
4914
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4956,10 +4930,10 @@ var useClickOutside = ({
|
|
|
4956
4930
|
};
|
|
4957
4931
|
|
|
4958
4932
|
// src/hooks/utils/use-debounce.ts
|
|
4959
|
-
var
|
|
4933
|
+
var import_react14 = require("react");
|
|
4960
4934
|
function useDebounce(value, delay) {
|
|
4961
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4962
|
-
(0,
|
|
4935
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
4936
|
+
(0, import_react14.useEffect)(() => {
|
|
4963
4937
|
const handler = setTimeout(() => {
|
|
4964
4938
|
setDebouncedValue(value);
|
|
4965
4939
|
}, delay);
|
|
@@ -5214,7 +5188,7 @@ var ChevronBottomIcon = ({
|
|
|
5214
5188
|
};
|
|
5215
5189
|
|
|
5216
5190
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
5217
|
-
var
|
|
5191
|
+
var import_react15 = require("react");
|
|
5218
5192
|
var import_environment6 = require("@fctc/interface-logic/environment");
|
|
5219
5193
|
var import_hooks11 = require("@fctc/interface-logic/hooks");
|
|
5220
5194
|
var statusDropdownController = (props) => {
|
|
@@ -5225,9 +5199,9 @@ var statusDropdownController = (props) => {
|
|
|
5225
5199
|
done: "bg-primary",
|
|
5226
5200
|
blocked: "bg-red-500"
|
|
5227
5201
|
};
|
|
5228
|
-
const [isOpen, setIsOpen] = (0,
|
|
5229
|
-
const buttonRef = (0,
|
|
5230
|
-
(0,
|
|
5202
|
+
const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
|
|
5203
|
+
const buttonRef = (0, import_react15.useRef)(null);
|
|
5204
|
+
(0, import_react15.useEffect)(() => {
|
|
5231
5205
|
const handleClickOutside = (event) => {
|
|
5232
5206
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
5233
5207
|
setIsOpen(false);
|
|
@@ -5268,7 +5242,11 @@ var statusDropdownController = (props) => {
|
|
|
5268
5242
|
};
|
|
5269
5243
|
|
|
5270
5244
|
// src/widget/basic/many2one-field/controller.ts
|
|
5271
|
-
var
|
|
5245
|
+
var import_react16 = require("react");
|
|
5246
|
+
|
|
5247
|
+
// src/store.ts
|
|
5248
|
+
var store_exports = {};
|
|
5249
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
5272
5250
|
|
|
5273
5251
|
// src/provider.ts
|
|
5274
5252
|
var provider_exports = {};
|
|
@@ -5290,13 +5268,13 @@ var many2oneFieldController = (props) => {
|
|
|
5290
5268
|
showDetail
|
|
5291
5269
|
} = props;
|
|
5292
5270
|
const { env } = (0, provider_exports.useEnv)();
|
|
5293
|
-
const [options, setOptions] = (0,
|
|
5294
|
-
const [inputValue, setInputValue] = (0,
|
|
5271
|
+
const [options, setOptions] = (0, import_react16.useState)([]);
|
|
5272
|
+
const [inputValue, setInputValue] = (0, import_react16.useState)("");
|
|
5295
5273
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
5296
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
5297
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
5298
|
-
const [domainModal, setDomainModal] = (0,
|
|
5299
|
-
const [domainObject, setDomainObject] = (0,
|
|
5274
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react16.useState)(false);
|
|
5275
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react16.useState)(null);
|
|
5276
|
+
const [domainModal, setDomainModal] = (0, import_react16.useState)(null);
|
|
5277
|
+
const [domainObject, setDomainObject] = (0, import_react16.useState)(null);
|
|
5300
5278
|
const actionData = sessionStorageUtils.getActionData();
|
|
5301
5279
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5302
5280
|
const initValue = methods?.getValues(name);
|
|
@@ -5327,18 +5305,18 @@ var many2oneFieldController = (props) => {
|
|
|
5327
5305
|
queryKey,
|
|
5328
5306
|
enabled: false
|
|
5329
5307
|
});
|
|
5330
|
-
const selectOptions = (0,
|
|
5308
|
+
const selectOptions = (0, import_react16.useMemo)(() => {
|
|
5331
5309
|
return dataOfSelection?.records?.map((val) => ({
|
|
5332
5310
|
value: val?.id,
|
|
5333
5311
|
label: val?.display_name || val?.name
|
|
5334
5312
|
})) || [];
|
|
5335
5313
|
}, [dataOfSelection]);
|
|
5336
|
-
(0,
|
|
5314
|
+
(0, import_react16.useEffect)(() => {
|
|
5337
5315
|
setOptions(selectOptions);
|
|
5338
5316
|
setDomainModal(domainObject);
|
|
5339
5317
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5340
5318
|
}, [selectOptions]);
|
|
5341
|
-
(0,
|
|
5319
|
+
(0, import_react16.useEffect)(() => {
|
|
5342
5320
|
setDomainObject(
|
|
5343
5321
|
(0, utils_exports.evalJSONDomain)(
|
|
5344
5322
|
domain,
|
|
@@ -5346,7 +5324,7 @@ var many2oneFieldController = (props) => {
|
|
|
5346
5324
|
)
|
|
5347
5325
|
);
|
|
5348
5326
|
}, [domain, formValues]);
|
|
5349
|
-
(0,
|
|
5327
|
+
(0, import_react16.useEffect)(() => {
|
|
5350
5328
|
if (!propValue && tempSelectedOption) {
|
|
5351
5329
|
methods.setValue(name, null);
|
|
5352
5330
|
setTempSelectedOption(null);
|
|
@@ -5357,10 +5335,10 @@ var many2oneFieldController = (props) => {
|
|
|
5357
5335
|
});
|
|
5358
5336
|
}
|
|
5359
5337
|
}, [propValue]);
|
|
5360
|
-
const fetchMoreOptions = (0,
|
|
5338
|
+
const fetchMoreOptions = (0, import_react16.useCallback)(() => {
|
|
5361
5339
|
refetch();
|
|
5362
5340
|
}, [refetch]);
|
|
5363
|
-
(0,
|
|
5341
|
+
(0, import_react16.useEffect)(() => {
|
|
5364
5342
|
if (debouncedInputValue) {
|
|
5365
5343
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5366
5344
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5375,7 +5353,7 @@ var many2oneFieldController = (props) => {
|
|
|
5375
5353
|
}, 50);
|
|
5376
5354
|
}
|
|
5377
5355
|
}, [debouncedInputValue]);
|
|
5378
|
-
const handleChooseRecord = (0,
|
|
5356
|
+
const handleChooseRecord = (0, import_react16.useCallback)(
|
|
5379
5357
|
(idRecord) => {
|
|
5380
5358
|
const newOption = options.find(
|
|
5381
5359
|
(option) => option.value === idRecord
|
|
@@ -5400,8 +5378,8 @@ var many2oneFieldController = (props) => {
|
|
|
5400
5378
|
},
|
|
5401
5379
|
[options, methods, name, onChange]
|
|
5402
5380
|
);
|
|
5403
|
-
const handleClose = (0,
|
|
5404
|
-
const handleSelectChange = (0,
|
|
5381
|
+
const handleClose = (0, import_react16.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5382
|
+
const handleSelectChange = (0, import_react16.useCallback)(
|
|
5405
5383
|
(selectedOption) => {
|
|
5406
5384
|
if (!selectedOption) {
|
|
5407
5385
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5475,7 +5453,7 @@ var many2oneButtonController = (props) => {
|
|
|
5475
5453
|
};
|
|
5476
5454
|
|
|
5477
5455
|
// src/widget/basic/many2many-field/controller.ts
|
|
5478
|
-
var
|
|
5456
|
+
var import_react17 = require("react");
|
|
5479
5457
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5480
5458
|
var many2manyFieldController = (props) => {
|
|
5481
5459
|
const {
|
|
@@ -5490,10 +5468,10 @@ var many2manyFieldController = (props) => {
|
|
|
5490
5468
|
actionData
|
|
5491
5469
|
} = props;
|
|
5492
5470
|
const { env } = (0, provider_exports.useEnv)();
|
|
5493
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5494
|
-
const [order, setOrder] = (0,
|
|
5495
|
-
const [page, setPage] = (0,
|
|
5496
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
5471
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView } = (0, provider_exports.useService)();
|
|
5472
|
+
const [order, setOrder] = (0, import_react17.useState)();
|
|
5473
|
+
const [page, setPage] = (0, import_react17.useState)(0);
|
|
5474
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
5497
5475
|
const [debouncedPage] = useDebounce(page, 500);
|
|
5498
5476
|
const contextObject = {
|
|
5499
5477
|
...env.context,
|
|
@@ -5508,7 +5486,7 @@ var many2manyFieldController = (props) => {
|
|
|
5508
5486
|
context: contextObject
|
|
5509
5487
|
};
|
|
5510
5488
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5511
|
-
const baseModel = (0,
|
|
5489
|
+
const baseModel = (0, import_react17.useMemo)(
|
|
5512
5490
|
() => ({
|
|
5513
5491
|
name: String(relation),
|
|
5514
5492
|
view: viewResponse || {},
|
|
@@ -5521,13 +5499,13 @@ var many2manyFieldController = (props) => {
|
|
|
5521
5499
|
[relation, viewResponse]
|
|
5522
5500
|
);
|
|
5523
5501
|
const initModel = (0, hooks_exports.useModel)();
|
|
5524
|
-
const modelInstance = (0,
|
|
5502
|
+
const modelInstance = (0, import_react17.useMemo)(() => {
|
|
5525
5503
|
if (viewResponse) {
|
|
5526
5504
|
return initModel.initModel(baseModel);
|
|
5527
5505
|
}
|
|
5528
5506
|
return null;
|
|
5529
5507
|
}, [baseModel, viewResponse]);
|
|
5530
|
-
const specification = (0,
|
|
5508
|
+
const specification = (0, import_react17.useMemo)(() => {
|
|
5531
5509
|
if (modelInstance) {
|
|
5532
5510
|
return modelInstance.getSpecification();
|
|
5533
5511
|
}
|
|
@@ -5569,8 +5547,8 @@ var many2manyFieldController = (props) => {
|
|
|
5569
5547
|
isLoading,
|
|
5570
5548
|
isFetched,
|
|
5571
5549
|
isPlaceholderData
|
|
5572
|
-
} =
|
|
5573
|
-
(0,
|
|
5550
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5551
|
+
(0, import_react17.useEffect)(() => {
|
|
5574
5552
|
if (viewResponse) {
|
|
5575
5553
|
fetchData();
|
|
5576
5554
|
}
|
|
@@ -5623,7 +5601,7 @@ var many2manyFieldController = (props) => {
|
|
|
5623
5601
|
};
|
|
5624
5602
|
|
|
5625
5603
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5626
|
-
var
|
|
5604
|
+
var import_react18 = require("react");
|
|
5627
5605
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5628
5606
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5629
5607
|
var many2manyTagsController = (props) => {
|
|
@@ -5639,7 +5617,7 @@ var many2manyTagsController = (props) => {
|
|
|
5639
5617
|
const { env } = (0, provider_exports.useEnv)();
|
|
5640
5618
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5641
5619
|
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5642
|
-
const domainObject = (0,
|
|
5620
|
+
const domainObject = (0, import_react18.useMemo)(
|
|
5643
5621
|
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5644
5622
|
[domain, formValues]
|
|
5645
5623
|
);
|
|
@@ -5681,7 +5659,7 @@ var many2manyTagsController = (props) => {
|
|
|
5681
5659
|
};
|
|
5682
5660
|
|
|
5683
5661
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5684
|
-
var
|
|
5662
|
+
var import_react19 = require("react");
|
|
5685
5663
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5686
5664
|
var durationController = (props) => {
|
|
5687
5665
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
@@ -5690,10 +5668,10 @@ var durationController = (props) => {
|
|
|
5690
5668
|
name: "",
|
|
5691
5669
|
fold: ""
|
|
5692
5670
|
};
|
|
5693
|
-
const { useGetListData:
|
|
5671
|
+
const { useGetListData: useGetListData2, useChangeStatus } = (0, provider_exports.useService)();
|
|
5694
5672
|
const { env } = (0, provider_exports.useEnv)();
|
|
5695
|
-
const [disabled, setDisabled] = (0,
|
|
5696
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5673
|
+
const [disabled, setDisabled] = (0, import_react19.useState)(false);
|
|
5674
|
+
const [modelStatus, setModalStatus] = (0, import_react19.useState)(false);
|
|
5697
5675
|
const queryKey = [`data-status-duration`, specification];
|
|
5698
5676
|
const listDataProps = {
|
|
5699
5677
|
model: relation,
|
|
@@ -5708,7 +5686,7 @@ var durationController = (props) => {
|
|
|
5708
5686
|
},
|
|
5709
5687
|
sort: ""
|
|
5710
5688
|
};
|
|
5711
|
-
const { data: dataResponse } =
|
|
5689
|
+
const { data: dataResponse } = useGetListData2(
|
|
5712
5690
|
listDataProps,
|
|
5713
5691
|
queryKey,
|
|
5714
5692
|
enabled
|
|
@@ -5783,10 +5761,10 @@ var priorityFieldController = (props) => {
|
|
|
5783
5761
|
};
|
|
5784
5762
|
|
|
5785
5763
|
// src/widget/basic/download-file-field/controller.ts
|
|
5786
|
-
var
|
|
5764
|
+
var import_react20 = require("react");
|
|
5787
5765
|
var downloadFileController = () => {
|
|
5788
|
-
const inputId = (0,
|
|
5789
|
-
const [file, setFile] = (0,
|
|
5766
|
+
const inputId = (0, import_react20.useId)();
|
|
5767
|
+
const [file, setFile] = (0, import_react20.useState)(null);
|
|
5790
5768
|
const handleFileChange = (e) => {
|
|
5791
5769
|
setFile(e.target.files[0]);
|
|
5792
5770
|
};
|
|
@@ -6718,11 +6696,11 @@ var dateFieldController = (props) => {
|
|
|
6718
6696
|
};
|
|
6719
6697
|
|
|
6720
6698
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6721
|
-
var
|
|
6699
|
+
var import_react21 = require("react");
|
|
6722
6700
|
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6723
6701
|
var copyLinkButtonController = (props) => {
|
|
6724
6702
|
const { value, defaultValue } = props;
|
|
6725
|
-
const [isCopied, setIsCopied] = (0,
|
|
6703
|
+
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6726
6704
|
const handleCopyToClipboard = async (value2) => {
|
|
6727
6705
|
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6728
6706
|
setIsCopied(true);
|
|
@@ -6770,16 +6748,16 @@ var colorFieldController = (props) => {
|
|
|
6770
6748
|
};
|
|
6771
6749
|
|
|
6772
6750
|
// src/widget/basic/binary-field/controller.ts
|
|
6773
|
-
var
|
|
6751
|
+
var import_react22 = require("react");
|
|
6774
6752
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6775
6753
|
var binaryFieldController = (props) => {
|
|
6776
6754
|
const { name, methods, readonly = false, value } = props;
|
|
6777
|
-
const inputId = (0,
|
|
6778
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6779
|
-
const [initialImage, setInitialImage] = (0,
|
|
6780
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6755
|
+
const inputId = (0, import_react22.useId)();
|
|
6756
|
+
const [selectedImage, setSelectedImage] = (0, import_react22.useState)(null);
|
|
6757
|
+
const [initialImage, setInitialImage] = (0, import_react22.useState)(value || null);
|
|
6758
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react22.useState)(false);
|
|
6781
6759
|
const { setValue } = methods;
|
|
6782
|
-
const binaryRef = (0,
|
|
6760
|
+
const binaryRef = (0, import_react22.useRef)(null);
|
|
6783
6761
|
const convertUrlToBase64 = async (url) => {
|
|
6784
6762
|
try {
|
|
6785
6763
|
const response = await fetch(url);
|
|
@@ -6841,14 +6819,14 @@ var binaryFieldController = (props) => {
|
|
|
6841
6819
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6842
6820
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6843
6821
|
};
|
|
6844
|
-
(0,
|
|
6822
|
+
(0, import_react22.useEffect)(() => {
|
|
6845
6823
|
return () => {
|
|
6846
6824
|
if (selectedImage) {
|
|
6847
6825
|
URL.revokeObjectURL(selectedImage);
|
|
6848
6826
|
}
|
|
6849
6827
|
};
|
|
6850
6828
|
}, [selectedImage]);
|
|
6851
|
-
(0,
|
|
6829
|
+
(0, import_react22.useEffect)(() => {
|
|
6852
6830
|
if (binaryRef.current) {
|
|
6853
6831
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6854
6832
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6868,50 +6846,73 @@ var binaryFieldController = (props) => {
|
|
|
6868
6846
|
};
|
|
6869
6847
|
|
|
6870
6848
|
// src/widget/advance/table/table-head/controller.ts
|
|
6871
|
-
var
|
|
6849
|
+
var import_store7 = require("@fctc/interface-logic/store");
|
|
6850
|
+
var import_react23 = require("react");
|
|
6872
6851
|
var tableHeadController = (props) => {
|
|
6873
|
-
const { typeTable, rows,
|
|
6874
|
-
const appDispatch = (0,
|
|
6875
|
-
const {
|
|
6852
|
+
const { typeTable, rows, tableRef, groupByList, selectedRowKeys } = props;
|
|
6853
|
+
const appDispatch = (0, import_store7.useAppDispatch)();
|
|
6854
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6855
|
+
const selectedRowKeysRef = (0, import_react23.useRef)(recordIds);
|
|
6856
|
+
const isGroupTable = typeTable === "group";
|
|
6857
|
+
const recordsCheckedGroup = (0, import_react23.useMemo)(() => {
|
|
6858
|
+
if (!rows || !groupByList) return 0;
|
|
6859
|
+
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6860
|
+
return countSum(rows, groupBy);
|
|
6861
|
+
}, [rows, groupByList]);
|
|
6862
|
+
const isAllGroupChecked = (0, import_react23.useMemo)(() => {
|
|
6863
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6864
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6865
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6866
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6867
|
+
return allGroupsSelected || allRecordsSelected;
|
|
6868
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6869
|
+
const isAllNormalChecked = (0, import_react23.useMemo)(() => {
|
|
6870
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6871
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6872
|
+
(id) => rows.some((record) => record.id === id)
|
|
6873
|
+
);
|
|
6874
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6875
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6876
6876
|
const handleCheckBoxAll = (event) => {
|
|
6877
6877
|
if (event?.target?.checked && typeTable === "list") {
|
|
6878
6878
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6879
|
-
appDispatch((0,
|
|
6879
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(allRowKeys));
|
|
6880
6880
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6881
6881
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6882
6882
|
const ids = Array.from(rowsIDs)?.map(
|
|
6883
6883
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6884
6884
|
);
|
|
6885
6885
|
if (ids?.length > 0) {
|
|
6886
|
-
appDispatch((0,
|
|
6886
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(ids));
|
|
6887
6887
|
} else {
|
|
6888
6888
|
const sum = countSum(
|
|
6889
6889
|
rows,
|
|
6890
|
-
typeof
|
|
6890
|
+
typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0
|
|
6891
6891
|
);
|
|
6892
6892
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6893
|
-
appDispatch((0,
|
|
6893
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(keys));
|
|
6894
6894
|
}
|
|
6895
6895
|
if (selectedRowKeysRef) {
|
|
6896
6896
|
selectedRowKeysRef.current = [];
|
|
6897
6897
|
}
|
|
6898
6898
|
} else {
|
|
6899
|
-
appDispatch((0,
|
|
6899
|
+
appDispatch((0, import_store7.setSelectedRowKeys)([]));
|
|
6900
6900
|
}
|
|
6901
6901
|
};
|
|
6902
6902
|
return {
|
|
6903
|
-
handleCheckBoxAll
|
|
6903
|
+
handleCheckBoxAll,
|
|
6904
|
+
checkedAll,
|
|
6905
|
+
selectedRowKeysRef
|
|
6904
6906
|
};
|
|
6905
6907
|
};
|
|
6906
6908
|
|
|
6907
6909
|
// src/widget/advance/table/table-view/controller.ts
|
|
6908
|
-
var
|
|
6909
|
-
var import_store9 = require("@fctc/interface-logic/store");
|
|
6910
|
+
var import_react24 = require("react");
|
|
6910
6911
|
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6911
6912
|
var tableController = ({ data }) => {
|
|
6912
|
-
const [rows, setRows] = (0,
|
|
6913
|
-
const [columns, setColumns] = (0,
|
|
6914
|
-
const dataModelFields = data
|
|
6913
|
+
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6914
|
+
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
6915
|
+
const dataModelFields = data?.fields?.map((field) => {
|
|
6915
6916
|
return {
|
|
6916
6917
|
...data.dataModel?.[field?.name],
|
|
6917
6918
|
...field,
|
|
@@ -6938,8 +6939,8 @@ var tableController = ({ data }) => {
|
|
|
6938
6939
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6939
6940
|
});
|
|
6940
6941
|
};
|
|
6941
|
-
(0,
|
|
6942
|
-
setRows(transformData(data.records
|
|
6942
|
+
(0, import_react24.useEffect)(() => {
|
|
6943
|
+
setRows(transformData(data.records));
|
|
6943
6944
|
}, [data.records]);
|
|
6944
6945
|
const handleGetColumns = () => {
|
|
6945
6946
|
let cols = [];
|
|
@@ -6959,10 +6960,11 @@ var tableController = ({ data }) => {
|
|
|
6959
6960
|
}
|
|
6960
6961
|
return cols;
|
|
6961
6962
|
};
|
|
6962
|
-
(0,
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6963
|
+
(0, import_react24.useEffect)(() => {
|
|
6964
|
+
if (!columns) {
|
|
6965
|
+
setColumns(handleGetColumns());
|
|
6966
|
+
}
|
|
6967
|
+
}, [data]);
|
|
6966
6968
|
const onToggleColumnOptional = (item) => {
|
|
6967
6969
|
const tempColumn = [...columns]?.map((val) => {
|
|
6968
6970
|
if (item?.name === val?.name) {
|
|
@@ -6975,6 +6977,14 @@ var tableController = ({ data }) => {
|
|
|
6975
6977
|
});
|
|
6976
6978
|
setColumns(tempColumn);
|
|
6977
6979
|
};
|
|
6980
|
+
(0, import_react24.useEffect)(() => {
|
|
6981
|
+
setRows(null);
|
|
6982
|
+
setColumns(null);
|
|
6983
|
+
return () => {
|
|
6984
|
+
setRows(null);
|
|
6985
|
+
setColumns(null);
|
|
6986
|
+
};
|
|
6987
|
+
}, [data?.fields]);
|
|
6978
6988
|
return {
|
|
6979
6989
|
rows,
|
|
6980
6990
|
columns,
|
|
@@ -6984,47 +6994,32 @@ var tableController = ({ data }) => {
|
|
|
6984
6994
|
};
|
|
6985
6995
|
|
|
6986
6996
|
// src/widget/advance/table/table-group/controller.ts
|
|
6987
|
-
var
|
|
6988
|
-
var
|
|
6989
|
-
var import_store10 = require("@fctc/interface-logic/store");
|
|
6990
|
-
|
|
6991
|
-
// src/environment.ts
|
|
6992
|
-
var environment_exports = {};
|
|
6993
|
-
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
6994
|
-
|
|
6995
|
-
// src/widget/advance/table/table-group/controller.ts
|
|
6997
|
+
var import_react25 = require("react");
|
|
6998
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6996
6999
|
var tableGroupController = (props) => {
|
|
6997
|
-
const env = (0,
|
|
7000
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
7001
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6998
7002
|
const {
|
|
6999
|
-
rows,
|
|
7000
7003
|
columns,
|
|
7001
|
-
indexRow,
|
|
7002
7004
|
row,
|
|
7003
7005
|
model,
|
|
7004
7006
|
viewData,
|
|
7005
|
-
renderField,
|
|
7006
7007
|
level,
|
|
7007
7008
|
specification,
|
|
7008
|
-
domain,
|
|
7009
7009
|
context,
|
|
7010
7010
|
checkedAll,
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
setIsAutoSelect,
|
|
7014
|
-
selectedRowKeysRef
|
|
7011
|
+
groupByList,
|
|
7012
|
+
setSelectedRowKeys: setSelectedRowKeys3
|
|
7015
7013
|
} = props;
|
|
7016
|
-
const [pageGroup, setPageGroup] = (0,
|
|
7017
|
-
const {
|
|
7018
|
-
const
|
|
7019
|
-
const
|
|
7020
|
-
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
7021
|
-
const initVal = toDataJS(row, viewData, model);
|
|
7022
|
-
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
7023
|
-
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
7014
|
+
const [pageGroup, setPageGroup] = (0, import_react25.useState)(0);
|
|
7015
|
+
const { selectedRowKeys } = (0, import_store8.useAppSelector)(import_store8.selectList);
|
|
7016
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react25.useState)(false);
|
|
7017
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react25.useState)({
|
|
7024
7018
|
fromStart: 1,
|
|
7025
7019
|
fromEnd: 1
|
|
7026
7020
|
});
|
|
7027
|
-
const
|
|
7021
|
+
const domain = row?.__domain;
|
|
7022
|
+
const processedData = (0, import_react25.useMemo)(() => {
|
|
7028
7023
|
const calculateColSpanEmpty = () => {
|
|
7029
7024
|
const startIndex = columns.findIndex(
|
|
7030
7025
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -7039,7 +7034,7 @@ var tableGroupController = (props) => {
|
|
|
7039
7034
|
};
|
|
7040
7035
|
return calculateColSpanEmpty();
|
|
7041
7036
|
}, [columns, row]);
|
|
7042
|
-
const shouldFetchData = (0,
|
|
7037
|
+
const shouldFetchData = (0, import_react25.useMemo)(() => {
|
|
7043
7038
|
return !!isShowGroup;
|
|
7044
7039
|
}, [isShowGroup]);
|
|
7045
7040
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -7049,22 +7044,22 @@ var tableGroupController = (props) => {
|
|
|
7049
7044
|
domain,
|
|
7050
7045
|
context,
|
|
7051
7046
|
offset: pageGroup * 10,
|
|
7052
|
-
fields:
|
|
7053
|
-
groupby: [
|
|
7047
|
+
fields: groupByList?.fields,
|
|
7048
|
+
groupby: [groupByList?.contexts[level]?.group_by]
|
|
7054
7049
|
};
|
|
7055
7050
|
const queryKey = [
|
|
7056
|
-
`data-${model}
|
|
7051
|
+
`data-${model}-level_${level}-row-${row?.id}`,
|
|
7057
7052
|
specification,
|
|
7058
7053
|
domain,
|
|
7059
7054
|
pageGroup
|
|
7060
7055
|
];
|
|
7061
7056
|
const {
|
|
7062
|
-
data:
|
|
7063
|
-
isFetched:
|
|
7064
|
-
isPlaceholderData,
|
|
7057
|
+
data: dataGroup,
|
|
7058
|
+
isFetched: isDataGroupFetched,
|
|
7065
7059
|
isLoading,
|
|
7066
|
-
isFetching
|
|
7067
|
-
|
|
7060
|
+
isFetching,
|
|
7061
|
+
isPlaceholderData: isDataPlaceHolder
|
|
7062
|
+
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
7068
7063
|
const {
|
|
7069
7064
|
columns: columnsGroup,
|
|
7070
7065
|
rows: rowsGroup,
|
|
@@ -7072,27 +7067,21 @@ var tableGroupController = (props) => {
|
|
|
7072
7067
|
} = tableController({
|
|
7073
7068
|
data: {
|
|
7074
7069
|
fields: viewData?.views?.list?.fields,
|
|
7075
|
-
records:
|
|
7070
|
+
records: dataGroup?.records ?? dataGroup?.groups,
|
|
7076
7071
|
dataModel: viewData?.models?.[model],
|
|
7077
7072
|
context: env.context,
|
|
7078
|
-
typeTable:
|
|
7073
|
+
typeTable: dataGroup?.groups ? "group" : "list"
|
|
7079
7074
|
}
|
|
7080
7075
|
});
|
|
7081
|
-
const
|
|
7082
|
-
(0, import_react23.useEffect)(() => {
|
|
7083
|
-
if (isShowGroup && selectedTags?.length > 0) {
|
|
7084
|
-
setIsShowGroup(false);
|
|
7085
|
-
}
|
|
7086
|
-
}, [selectedTags]);
|
|
7087
|
-
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
7076
|
+
const group_by_field_name = groupByList?.contexts[level - 1]?.group_by;
|
|
7088
7077
|
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(
|
|
7089
7078
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
7090
7079
|
)?.[1] : row[group_by_field_name];
|
|
7091
7080
|
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`]})`;
|
|
7092
7081
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
7093
|
-
const
|
|
7082
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7083
|
+
const onExpandChildGroup = () => {
|
|
7094
7084
|
if (isLoading || isFetching) return;
|
|
7095
|
-
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
7096
7085
|
if (allIdsNull || typeTableGroup === "group") {
|
|
7097
7086
|
toggleShowGroup();
|
|
7098
7087
|
return;
|
|
@@ -7102,53 +7091,39 @@ var tableGroupController = (props) => {
|
|
|
7102
7091
|
const filteredIds = selectedRowKeys.filter(
|
|
7103
7092
|
(id) => !ids.includes(id)
|
|
7104
7093
|
);
|
|
7105
|
-
|
|
7106
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull
|
|
7094
|
+
setSelectedRowKeys3(filteredIds);
|
|
7095
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
7107
7096
|
const clonedKeys = [...selectedRowKeys];
|
|
7108
|
-
|
|
7109
|
-
setTimeout(() =>
|
|
7097
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7098
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7110
7099
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
7100
|
+
console.log("abc");
|
|
7111
7101
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
7112
|
-
|
|
7102
|
+
setSelectedRowKeys3(filteredKeys);
|
|
7113
7103
|
}
|
|
7114
7104
|
toggleShowGroup();
|
|
7115
7105
|
};
|
|
7116
|
-
(0,
|
|
7117
|
-
if (!
|
|
7106
|
+
(0, import_react25.useEffect)(() => {
|
|
7107
|
+
if (!isDataGroupFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
7118
7108
|
return;
|
|
7119
7109
|
}
|
|
7120
7110
|
const clonedKeys = [...selectedRowKeys];
|
|
7121
|
-
(
|
|
7122
|
-
setTimeout(() => (
|
|
7123
|
-
}, [
|
|
7111
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
7112
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
7113
|
+
}, [isDataGroupFetched]);
|
|
7124
7114
|
return {
|
|
7125
|
-
|
|
7115
|
+
onExpandChildGroup,
|
|
7126
7116
|
colEmptyGroup,
|
|
7127
|
-
leftPadding,
|
|
7128
7117
|
isShowGroup,
|
|
7129
|
-
|
|
7118
|
+
isDataGroupFetched,
|
|
7119
|
+
isDataPlaceHolder,
|
|
7130
7120
|
nameGroupWithCount,
|
|
7131
|
-
columns,
|
|
7132
|
-
row,
|
|
7133
|
-
isPlaceholderData,
|
|
7134
7121
|
columnsGroup,
|
|
7135
|
-
indexRow,
|
|
7136
7122
|
rowsGroup,
|
|
7137
|
-
|
|
7138
|
-
viewData,
|
|
7139
|
-
renderField,
|
|
7140
|
-
level,
|
|
7141
|
-
specification,
|
|
7142
|
-
context,
|
|
7143
|
-
checkedAll,
|
|
7144
|
-
isDisplayCheckbox,
|
|
7145
|
-
isAutoSelect,
|
|
7146
|
-
setIsAutoSelect,
|
|
7147
|
-
selectedRowKeysRef,
|
|
7148
|
-
initVal,
|
|
7149
|
-
dataResponse,
|
|
7123
|
+
dataGroup,
|
|
7150
7124
|
pageGroup,
|
|
7151
|
-
setPageGroup
|
|
7125
|
+
setPageGroup,
|
|
7126
|
+
typeTableGroup
|
|
7152
7127
|
};
|
|
7153
7128
|
};
|
|
7154
7129
|
|
|
@@ -7156,7 +7131,7 @@ var tableGroupController = (props) => {
|
|
|
7156
7131
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
7157
7132
|
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
7158
7133
|
var import_moment2 = __toESM(require_moment());
|
|
7159
|
-
var
|
|
7134
|
+
var import_react26 = require("react");
|
|
7160
7135
|
var searchController = ({
|
|
7161
7136
|
viewData,
|
|
7162
7137
|
model,
|
|
@@ -7165,12 +7140,12 @@ var searchController = ({
|
|
|
7165
7140
|
fieldsList
|
|
7166
7141
|
}) => {
|
|
7167
7142
|
const { env } = (0, provider_exports.useEnv)();
|
|
7168
|
-
const [filterBy, setFilterBy] = (0,
|
|
7169
|
-
const [searchBy, setSearchBy] = (0,
|
|
7170
|
-
const [groupBy, setGroupBy] = (0,
|
|
7171
|
-
const [selectedTags, setSelectedTags] = (0,
|
|
7172
|
-
const [searchString, setSearchString] = (0,
|
|
7173
|
-
const [searchMap, setSearchMap] = (0,
|
|
7143
|
+
const [filterBy, setFilterBy] = (0, import_react26.useState)(null);
|
|
7144
|
+
const [searchBy, setSearchBy] = (0, import_react26.useState)(null);
|
|
7145
|
+
const [groupBy, setGroupBy] = (0, import_react26.useState)(null);
|
|
7146
|
+
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
7147
|
+
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
7148
|
+
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
7174
7149
|
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
7175
7150
|
const contextSearch = { ...env.context, ...actionContext };
|
|
7176
7151
|
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
@@ -7217,7 +7192,7 @@ var searchController = ({
|
|
|
7217
7192
|
}
|
|
7218
7193
|
}
|
|
7219
7194
|
};
|
|
7220
|
-
(0,
|
|
7195
|
+
(0, import_react26.useEffect)(() => {
|
|
7221
7196
|
fetchData();
|
|
7222
7197
|
}, [model, viewData]);
|
|
7223
7198
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7299,7 +7274,7 @@ var searchController = ({
|
|
|
7299
7274
|
return [...domain2];
|
|
7300
7275
|
}
|
|
7301
7276
|
};
|
|
7302
|
-
const setTagSearch = (0,
|
|
7277
|
+
const setTagSearch = (0, import_react26.useCallback)(
|
|
7303
7278
|
(updatedMap) => {
|
|
7304
7279
|
if (!updatedMap) return;
|
|
7305
7280
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7362,7 +7337,7 @@ var searchController = ({
|
|
|
7362
7337
|
},
|
|
7363
7338
|
[searchMap]
|
|
7364
7339
|
);
|
|
7365
|
-
(0,
|
|
7340
|
+
(0, import_react26.useEffect)(() => {
|
|
7366
7341
|
setTagSearch(searchMap);
|
|
7367
7342
|
}, [searchMap]);
|
|
7368
7343
|
const handleAddTagSearch = (tag) => {
|
|
@@ -7429,6 +7404,12 @@ __reExport(constants_exports, require("@fctc/interface-logic/constants"));
|
|
|
7429
7404
|
|
|
7430
7405
|
// src/index.ts
|
|
7431
7406
|
__reExport(index_exports, constants_exports, module.exports);
|
|
7407
|
+
|
|
7408
|
+
// src/environment.ts
|
|
7409
|
+
var environment_exports = {};
|
|
7410
|
+
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
7411
|
+
|
|
7412
|
+
// src/index.ts
|
|
7432
7413
|
__reExport(index_exports, environment_exports, module.exports);
|
|
7433
7414
|
__reExport(index_exports, provider_exports, module.exports);
|
|
7434
7415
|
|
|
@@ -7487,6 +7468,7 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
7487
7468
|
useAuth,
|
|
7488
7469
|
useCallAction,
|
|
7489
7470
|
useClickOutside,
|
|
7471
|
+
useCompany,
|
|
7490
7472
|
useConfig,
|
|
7491
7473
|
useDebounce,
|
|
7492
7474
|
useDetail,
|
|
@@ -7495,7 +7477,6 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
7495
7477
|
useMenu,
|
|
7496
7478
|
useMenuItem,
|
|
7497
7479
|
useProfile,
|
|
7498
|
-
useSelectionState,
|
|
7499
7480
|
useStorageState,
|
|
7500
7481
|
useUser,
|
|
7501
7482
|
useViewV2
|