@fctc/widget-logic 2.3.8 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.mts +7 -3
- package/dist/hooks.d.ts +7 -3
- package/dist/hooks.js +87 -113
- package/dist/hooks.mjs +99 -134
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +254 -276
- package/dist/index.mjs +231 -275
- package/dist/utils.d.mts +1 -14
- package/dist/utils.d.ts +1 -14
- package/dist/utils.js +0 -95
- package/dist/utils.mjs +1 -116
- package/dist/widget.d.mts +15 -28
- package/dist/widget.d.ts +15 -28
- package/dist/widget.js +244 -270
- package/dist/widget.mjs +222 -271
- package/package.json +96 -96
package/dist/widget.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
|
|
|
@@ -4110,7 +4110,7 @@ var statusDropdownController = (props) => {
|
|
|
4110
4110
|
};
|
|
4111
4111
|
|
|
4112
4112
|
// src/widget/basic/many2one-field/controller.ts
|
|
4113
|
-
var
|
|
4113
|
+
var import_react16 = require("react");
|
|
4114
4114
|
|
|
4115
4115
|
// src/hooks.ts
|
|
4116
4116
|
var hooks_exports = {};
|
|
@@ -4123,6 +4123,7 @@ __export(hooks_exports, {
|
|
|
4123
4123
|
useConfig: () => useConfig,
|
|
4124
4124
|
useDebounce: () => useDebounce,
|
|
4125
4125
|
useDetail: () => useDetail,
|
|
4126
|
+
useGetRowIds: () => useGetRowIds,
|
|
4126
4127
|
useListData: () => useListData,
|
|
4127
4128
|
useMenu: () => useMenu,
|
|
4128
4129
|
useMenuItem: () => useMenuItem,
|
|
@@ -4250,12 +4251,6 @@ var import_react6 = require("react");
|
|
|
4250
4251
|
|
|
4251
4252
|
// src/utils/function.ts
|
|
4252
4253
|
var import_react5 = require("react");
|
|
4253
|
-
|
|
4254
|
-
// src/store.ts
|
|
4255
|
-
var store_exports = {};
|
|
4256
|
-
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4257
|
-
|
|
4258
|
-
// src/utils/function.ts
|
|
4259
4254
|
var countSum = (data, field) => {
|
|
4260
4255
|
if (!data || !field) return 0;
|
|
4261
4256
|
return data.reduce(
|
|
@@ -4274,91 +4269,6 @@ function mergeButtons(fields) {
|
|
|
4274
4269
|
}
|
|
4275
4270
|
return others;
|
|
4276
4271
|
}
|
|
4277
|
-
function isElementVisible(el) {
|
|
4278
|
-
const style = window.getComputedStyle(el);
|
|
4279
|
-
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4280
|
-
}
|
|
4281
|
-
function arraysAreEqual(a, b) {
|
|
4282
|
-
if (a.length !== b.length) return false;
|
|
4283
|
-
const setA = new Set(a);
|
|
4284
|
-
const setB = new Set(b);
|
|
4285
|
-
if (setA.size !== setB.size) return false;
|
|
4286
|
-
for (const val of setA) {
|
|
4287
|
-
if (!setB.has(val)) return false;
|
|
4288
|
-
}
|
|
4289
|
-
return true;
|
|
4290
|
-
}
|
|
4291
|
-
function useGetRowIds(tableRef) {
|
|
4292
|
-
const [rowIds, setRowIds] = (0, import_react5.useState)([]);
|
|
4293
|
-
const lastRowIdsRef = (0, import_react5.useRef)([]);
|
|
4294
|
-
const updateVisibleRowIds = (0, import_react5.useCallback)(() => {
|
|
4295
|
-
const table = tableRef?.current;
|
|
4296
|
-
if (!table) return;
|
|
4297
|
-
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4298
|
-
const ids = [];
|
|
4299
|
-
rows.forEach((row) => {
|
|
4300
|
-
const el = row;
|
|
4301
|
-
if (isElementVisible(el)) {
|
|
4302
|
-
const id = el.getAttribute("data-row-id");
|
|
4303
|
-
if (id) ids.push(id);
|
|
4304
|
-
}
|
|
4305
|
-
});
|
|
4306
|
-
const uniqueIds = Array.from(new Set(ids));
|
|
4307
|
-
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4308
|
-
lastRowIdsRef.current = uniqueIds;
|
|
4309
|
-
setRowIds(uniqueIds);
|
|
4310
|
-
}
|
|
4311
|
-
}, [tableRef]);
|
|
4312
|
-
(0, import_react5.useEffect)(() => {
|
|
4313
|
-
const table = tableRef?.current;
|
|
4314
|
-
if (!table) return;
|
|
4315
|
-
const observer = new MutationObserver(() => {
|
|
4316
|
-
updateVisibleRowIds();
|
|
4317
|
-
});
|
|
4318
|
-
observer.observe(table, {
|
|
4319
|
-
childList: true,
|
|
4320
|
-
subtree: true,
|
|
4321
|
-
attributes: true,
|
|
4322
|
-
attributeFilter: ["style", "class"]
|
|
4323
|
-
});
|
|
4324
|
-
updateVisibleRowIds();
|
|
4325
|
-
return () => {
|
|
4326
|
-
observer.disconnect();
|
|
4327
|
-
};
|
|
4328
|
-
}, [updateVisibleRowIds, tableRef]);
|
|
4329
|
-
return { rowIds, refresh: updateVisibleRowIds };
|
|
4330
|
-
}
|
|
4331
|
-
var useSelectionState = ({
|
|
4332
|
-
typeTable,
|
|
4333
|
-
tableRef,
|
|
4334
|
-
rows
|
|
4335
|
-
}) => {
|
|
4336
|
-
const { groupByDomain } = (0, store_exports.useAppSelector)(store_exports.selectSearch);
|
|
4337
|
-
const { selectedRowKeys } = (0, store_exports.useAppSelector)(store_exports.selectList);
|
|
4338
|
-
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
4339
|
-
const selectedRowKeysRef = (0, import_react5.useRef)(recordIds);
|
|
4340
|
-
const isGroupTable = typeTable === "group";
|
|
4341
|
-
const recordsCheckedGroup = (0, import_react5.useMemo)(() => {
|
|
4342
|
-
if (!rows || !groupByDomain) return 0;
|
|
4343
|
-
const groupBy = typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0;
|
|
4344
|
-
return countSum(rows, groupBy);
|
|
4345
|
-
}, [rows, groupByDomain]);
|
|
4346
|
-
const isAllGroupChecked = (0, import_react5.useMemo)(() => {
|
|
4347
|
-
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
4348
|
-
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
4349
|
-
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
4350
|
-
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
4351
|
-
return allGroupsSelected || allRecordsSelected;
|
|
4352
|
-
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
4353
|
-
const isAllNormalChecked = (0, import_react5.useMemo)(() => {
|
|
4354
|
-
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
4355
|
-
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
4356
|
-
(id) => rows.some((record) => record.id === id)
|
|
4357
|
-
);
|
|
4358
|
-
}, [isGroupTable, selectedRowKeys, rows]);
|
|
4359
|
-
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
4360
|
-
return { checkedAll, selectedRowKeysRef };
|
|
4361
|
-
};
|
|
4362
4272
|
var getDateRange = (currentDate, unit) => {
|
|
4363
4273
|
const date = new Date(currentDate);
|
|
4364
4274
|
let dateStart, dateEnd;
|
|
@@ -4499,19 +4409,19 @@ function useStorageState(key) {
|
|
|
4499
4409
|
|
|
4500
4410
|
// src/hooks/core/use-list-data.ts
|
|
4501
4411
|
var import_hooks4 = require("@fctc/interface-logic/hooks");
|
|
4502
|
-
var
|
|
4412
|
+
var import_store3 = require("@fctc/interface-logic/store");
|
|
4503
4413
|
var import_utils = require("@fctc/interface-logic/utils");
|
|
4504
4414
|
var useListData = ({
|
|
4505
4415
|
action,
|
|
4506
4416
|
context,
|
|
4507
4417
|
viewResponse
|
|
4508
4418
|
}) => {
|
|
4509
|
-
const { groupByDomain } = (0,
|
|
4419
|
+
const { groupByDomain } = (0, import_store3.useAppSelector)(import_store3.selectSearch);
|
|
4510
4420
|
const initModel = (0, import_hooks4.useModel)();
|
|
4511
4421
|
const [type, setType] = (0, import_react6.useState)("list");
|
|
4512
4422
|
const [mode, setMode] = (0, import_react6.useState)("month");
|
|
4513
4423
|
const [currentDate, setCurrentDate] = (0, import_react6.useState)(/* @__PURE__ */ new Date());
|
|
4514
|
-
const { pageLimit, page, order } = (0,
|
|
4424
|
+
const { pageLimit, page, order } = (0, import_store3.useAppSelector)(import_store3.selectList);
|
|
4515
4425
|
const listDataProps = (0, import_react6.useMemo)(() => {
|
|
4516
4426
|
const actData = action?.result;
|
|
4517
4427
|
if (!viewResponse || !actData || !context) {
|
|
@@ -4646,10 +4556,10 @@ var import_react8 = require("react");
|
|
|
4646
4556
|
var import_react_i18next = require("react-i18next");
|
|
4647
4557
|
var import_environment4 = require("@fctc/interface-logic/environment");
|
|
4648
4558
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
4649
|
-
var
|
|
4559
|
+
var import_store4 = require("@fctc/interface-logic/store");
|
|
4650
4560
|
var useProfile = (accessToken) => {
|
|
4651
4561
|
const getProfile = (0, import_hooks6.useGetProfile)();
|
|
4652
|
-
const dispatch = (0,
|
|
4562
|
+
const dispatch = (0, import_store4.useAppDispatch)();
|
|
4653
4563
|
const { i18n: i18n2 } = (0, import_react_i18next.useTranslation)();
|
|
4654
4564
|
const fetchUserProfile = async () => {
|
|
4655
4565
|
return await getProfile.mutateAsync();
|
|
@@ -4664,7 +4574,7 @@ var useProfile = (accessToken) => {
|
|
|
4664
4574
|
const userInfo = userInfoQuery.data;
|
|
4665
4575
|
const env = (0, import_environment4.getEnv)();
|
|
4666
4576
|
env.setUid(userInfo?.sub);
|
|
4667
|
-
dispatch((0,
|
|
4577
|
+
dispatch((0, import_store4.setDataUser)(userInfo));
|
|
4668
4578
|
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
4669
4579
|
env.setLang(userLocale?.id);
|
|
4670
4580
|
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
@@ -4729,11 +4639,11 @@ var useViewV2 = ({
|
|
|
4729
4639
|
|
|
4730
4640
|
// src/hooks/core/use-auth.ts
|
|
4731
4641
|
var import_hooks8 = require("@fctc/interface-logic/hooks");
|
|
4732
|
-
var
|
|
4642
|
+
var import_store5 = require("@fctc/interface-logic/store");
|
|
4733
4643
|
var useAuth = () => {
|
|
4734
4644
|
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
4735
4645
|
const loginMutate = (0, import_hooks8.useLoginCredential)();
|
|
4736
|
-
const dispatch = (0,
|
|
4646
|
+
const dispatch = (0, import_store5.useAppDispatch)();
|
|
4737
4647
|
const signIn = async (email, password) => {
|
|
4738
4648
|
try {
|
|
4739
4649
|
loginMutate.mutate(
|
|
@@ -4754,9 +4664,9 @@ var useAuth = () => {
|
|
|
4754
4664
|
}
|
|
4755
4665
|
};
|
|
4756
4666
|
const signOut = async () => {
|
|
4757
|
-
dispatch((0,
|
|
4758
|
-
dispatch((0,
|
|
4759
|
-
dispatch((0,
|
|
4667
|
+
dispatch((0, import_store5.setMenuList)([]));
|
|
4668
|
+
dispatch((0, import_store5.setDataUser)({}));
|
|
4669
|
+
dispatch((0, import_store5.setProfile)({}));
|
|
4760
4670
|
setAccessToken(null);
|
|
4761
4671
|
};
|
|
4762
4672
|
return {
|
|
@@ -4769,6 +4679,7 @@ var useAuth = () => {
|
|
|
4769
4679
|
|
|
4770
4680
|
// src/hooks/core/use-app-provider.tsx
|
|
4771
4681
|
var import_react11 = require("react");
|
|
4682
|
+
var import_utils2 = require("@fctc/interface-logic/utils");
|
|
4772
4683
|
|
|
4773
4684
|
// src/hooks/core/use-company.ts
|
|
4774
4685
|
var import_react_query3 = require("@tanstack/react-query");
|
|
@@ -4817,10 +4728,8 @@ var useCompany = (accessToken) => {
|
|
|
4817
4728
|
context: { allowed_company_ids: [current_company_id] }
|
|
4818
4729
|
};
|
|
4819
4730
|
};
|
|
4820
|
-
var use_company_default = useCompany;
|
|
4821
4731
|
|
|
4822
4732
|
// src/hooks/core/use-app-provider.tsx
|
|
4823
|
-
var import_utils2 = require("@fctc/interface-logic/utils");
|
|
4824
4733
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
4825
4734
|
var AppProviderInitialValue = {
|
|
4826
4735
|
config: {},
|
|
@@ -4837,7 +4746,7 @@ var AppProvider = ({ children }) => {
|
|
|
4837
4746
|
const config = useConfig({});
|
|
4838
4747
|
const auth = useAuth();
|
|
4839
4748
|
const user = useUser(auth.accessToken);
|
|
4840
|
-
const company =
|
|
4749
|
+
const company = useCompany(auth.accessToken);
|
|
4841
4750
|
const menuContext = (0, import_react11.useMemo)(() => {
|
|
4842
4751
|
return combineContexts([user.context, company.context]);
|
|
4843
4752
|
}, [user.context, company.context]);
|
|
@@ -4903,8 +4812,6 @@ __export(utils_exports, {
|
|
|
4903
4812
|
languages: () => languages,
|
|
4904
4813
|
mergeButtons: () => mergeButtons,
|
|
4905
4814
|
setStorageItemAsync: () => setStorageItemAsync,
|
|
4906
|
-
useGetRowIds: () => useGetRowIds,
|
|
4907
|
-
useSelectionState: () => useSelectionState,
|
|
4908
4815
|
useStorageState: () => useStorageState
|
|
4909
4816
|
});
|
|
4910
4817
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
@@ -4946,8 +4853,74 @@ var useMenuItem = (props) => {
|
|
|
4946
4853
|
return { handleClick, path, queryActionDetail };
|
|
4947
4854
|
};
|
|
4948
4855
|
|
|
4949
|
-
// src/hooks/
|
|
4856
|
+
// src/hooks/core/use-get-rowids.ts
|
|
4950
4857
|
var import_react13 = require("react");
|
|
4858
|
+
var useGetRowIds = (tableRef) => {
|
|
4859
|
+
function isElementVisible(el) {
|
|
4860
|
+
const style = window.getComputedStyle(el);
|
|
4861
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4862
|
+
}
|
|
4863
|
+
function arraysAreEqual(a, b) {
|
|
4864
|
+
if (a.length !== b.length) return false;
|
|
4865
|
+
if (a.length === 0 && b.length === 0) return true;
|
|
4866
|
+
const setA = new Set(a);
|
|
4867
|
+
const setB = new Set(b);
|
|
4868
|
+
if (setA.size !== setB.size) return false;
|
|
4869
|
+
for (const val of setA) {
|
|
4870
|
+
if (!setB.has(val)) return false;
|
|
4871
|
+
}
|
|
4872
|
+
return true;
|
|
4873
|
+
}
|
|
4874
|
+
const [rowIds, setRowIds] = (0, import_react13.useState)([]);
|
|
4875
|
+
const lastRowIdsRef = (0, import_react13.useRef)([]);
|
|
4876
|
+
const updateVisibleRowIds = (0, import_react13.useCallback)(() => {
|
|
4877
|
+
const table = tableRef.current;
|
|
4878
|
+
if (!table) return;
|
|
4879
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4880
|
+
const ids = [];
|
|
4881
|
+
rows.forEach((row) => {
|
|
4882
|
+
const el = row;
|
|
4883
|
+
if (isElementVisible(el)) {
|
|
4884
|
+
const id = el.getAttribute("data-row-id");
|
|
4885
|
+
if (id) ids.push(id);
|
|
4886
|
+
}
|
|
4887
|
+
});
|
|
4888
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4889
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4890
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4891
|
+
setRowIds(uniqueIds);
|
|
4892
|
+
}
|
|
4893
|
+
}, [tableRef]);
|
|
4894
|
+
(0, import_react13.useEffect)(() => {
|
|
4895
|
+
const table = tableRef.current;
|
|
4896
|
+
if (!table) return;
|
|
4897
|
+
const mutationObserver = new MutationObserver(() => {
|
|
4898
|
+
updateVisibleRowIds();
|
|
4899
|
+
});
|
|
4900
|
+
mutationObserver.observe(table, {
|
|
4901
|
+
childList: true,
|
|
4902
|
+
subtree: true,
|
|
4903
|
+
attributes: true,
|
|
4904
|
+
attributeFilter: ["style", "class"]
|
|
4905
|
+
});
|
|
4906
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
4907
|
+
updateVisibleRowIds();
|
|
4908
|
+
});
|
|
4909
|
+
resizeObserver.observe(table);
|
|
4910
|
+
const handleScroll = () => updateVisibleRowIds();
|
|
4911
|
+
table.addEventListener("scroll", handleScroll, true);
|
|
4912
|
+
updateVisibleRowIds();
|
|
4913
|
+
return () => {
|
|
4914
|
+
mutationObserver.disconnect();
|
|
4915
|
+
resizeObserver.disconnect();
|
|
4916
|
+
table.removeEventListener("scroll", handleScroll, true);
|
|
4917
|
+
};
|
|
4918
|
+
}, [updateVisibleRowIds, tableRef?.current]);
|
|
4919
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4920
|
+
};
|
|
4921
|
+
|
|
4922
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4923
|
+
var import_react14 = require("react");
|
|
4951
4924
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4952
4925
|
var useClickOutside = ({
|
|
4953
4926
|
handler,
|
|
@@ -4955,8 +4928,8 @@ var useClickOutside = ({
|
|
|
4955
4928
|
nodes = [],
|
|
4956
4929
|
refs
|
|
4957
4930
|
}) => {
|
|
4958
|
-
const ref = (0,
|
|
4959
|
-
(0,
|
|
4931
|
+
const ref = (0, import_react14.useRef)(null);
|
|
4932
|
+
(0, import_react14.useEffect)(() => {
|
|
4960
4933
|
const listener = (event) => {
|
|
4961
4934
|
const { target } = event;
|
|
4962
4935
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4978,10 +4951,10 @@ var useClickOutside = ({
|
|
|
4978
4951
|
};
|
|
4979
4952
|
|
|
4980
4953
|
// src/hooks/utils/use-debounce.ts
|
|
4981
|
-
var
|
|
4954
|
+
var import_react15 = require("react");
|
|
4982
4955
|
function useDebounce(value, delay) {
|
|
4983
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4984
|
-
(0,
|
|
4956
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react15.useState)(value);
|
|
4957
|
+
(0, import_react15.useEffect)(() => {
|
|
4985
4958
|
const handler = setTimeout(() => {
|
|
4986
4959
|
setDebouncedValue(value);
|
|
4987
4960
|
}, delay);
|
|
@@ -4995,6 +4968,10 @@ function useDebounce(value, delay) {
|
|
|
4995
4968
|
// src/hooks.ts
|
|
4996
4969
|
__reExport(hooks_exports, require("@fctc/interface-logic/hooks"));
|
|
4997
4970
|
|
|
4971
|
+
// src/store.ts
|
|
4972
|
+
var store_exports = {};
|
|
4973
|
+
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
4974
|
+
|
|
4998
4975
|
// src/provider.ts
|
|
4999
4976
|
var provider_exports = {};
|
|
5000
4977
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
@@ -5015,13 +4992,13 @@ var many2oneFieldController = (props) => {
|
|
|
5015
4992
|
showDetail
|
|
5016
4993
|
} = props;
|
|
5017
4994
|
const { env } = (0, provider_exports.useEnv)();
|
|
5018
|
-
const [options, setOptions] = (0,
|
|
5019
|
-
const [inputValue, setInputValue] = (0,
|
|
4995
|
+
const [options, setOptions] = (0, import_react16.useState)([]);
|
|
4996
|
+
const [inputValue, setInputValue] = (0, import_react16.useState)("");
|
|
5020
4997
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
5021
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
5022
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
5023
|
-
const [domainModal, setDomainModal] = (0,
|
|
5024
|
-
const [domainObject, setDomainObject] = (0,
|
|
4998
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react16.useState)(false);
|
|
4999
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react16.useState)(null);
|
|
5000
|
+
const [domainModal, setDomainModal] = (0, import_react16.useState)(null);
|
|
5001
|
+
const [domainObject, setDomainObject] = (0, import_react16.useState)(null);
|
|
5025
5002
|
const actionData = sessionStorageUtils.getActionData();
|
|
5026
5003
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5027
5004
|
const initValue = methods?.getValues(name);
|
|
@@ -5052,18 +5029,18 @@ var many2oneFieldController = (props) => {
|
|
|
5052
5029
|
queryKey,
|
|
5053
5030
|
enabled: false
|
|
5054
5031
|
});
|
|
5055
|
-
const selectOptions = (0,
|
|
5032
|
+
const selectOptions = (0, import_react16.useMemo)(() => {
|
|
5056
5033
|
return dataOfSelection?.records?.map((val) => ({
|
|
5057
5034
|
value: val?.id,
|
|
5058
5035
|
label: val?.display_name || val?.name
|
|
5059
5036
|
})) || [];
|
|
5060
5037
|
}, [dataOfSelection]);
|
|
5061
|
-
(0,
|
|
5038
|
+
(0, import_react16.useEffect)(() => {
|
|
5062
5039
|
setOptions(selectOptions);
|
|
5063
5040
|
setDomainModal(domainObject);
|
|
5064
5041
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5065
5042
|
}, [selectOptions]);
|
|
5066
|
-
(0,
|
|
5043
|
+
(0, import_react16.useEffect)(() => {
|
|
5067
5044
|
setDomainObject(
|
|
5068
5045
|
(0, utils_exports.evalJSONDomain)(
|
|
5069
5046
|
domain,
|
|
@@ -5071,7 +5048,7 @@ var many2oneFieldController = (props) => {
|
|
|
5071
5048
|
)
|
|
5072
5049
|
);
|
|
5073
5050
|
}, [domain, formValues]);
|
|
5074
|
-
(0,
|
|
5051
|
+
(0, import_react16.useEffect)(() => {
|
|
5075
5052
|
if (!propValue && tempSelectedOption) {
|
|
5076
5053
|
methods.setValue(name, null);
|
|
5077
5054
|
setTempSelectedOption(null);
|
|
@@ -5082,10 +5059,10 @@ var many2oneFieldController = (props) => {
|
|
|
5082
5059
|
});
|
|
5083
5060
|
}
|
|
5084
5061
|
}, [propValue]);
|
|
5085
|
-
const fetchMoreOptions = (0,
|
|
5062
|
+
const fetchMoreOptions = (0, import_react16.useCallback)(() => {
|
|
5086
5063
|
refetch();
|
|
5087
5064
|
}, [refetch]);
|
|
5088
|
-
(0,
|
|
5065
|
+
(0, import_react16.useEffect)(() => {
|
|
5089
5066
|
if (debouncedInputValue) {
|
|
5090
5067
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5091
5068
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5100,7 +5077,7 @@ var many2oneFieldController = (props) => {
|
|
|
5100
5077
|
}, 50);
|
|
5101
5078
|
}
|
|
5102
5079
|
}, [debouncedInputValue]);
|
|
5103
|
-
const handleChooseRecord = (0,
|
|
5080
|
+
const handleChooseRecord = (0, import_react16.useCallback)(
|
|
5104
5081
|
(idRecord) => {
|
|
5105
5082
|
const newOption = options.find(
|
|
5106
5083
|
(option) => option.value === idRecord
|
|
@@ -5125,8 +5102,8 @@ var many2oneFieldController = (props) => {
|
|
|
5125
5102
|
},
|
|
5126
5103
|
[options, methods, name, onChange]
|
|
5127
5104
|
);
|
|
5128
|
-
const handleClose = (0,
|
|
5129
|
-
const handleSelectChange = (0,
|
|
5105
|
+
const handleClose = (0, import_react16.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5106
|
+
const handleSelectChange = (0, import_react16.useCallback)(
|
|
5130
5107
|
(selectedOption) => {
|
|
5131
5108
|
if (!selectedOption) {
|
|
5132
5109
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5200,7 +5177,7 @@ var many2oneButtonController = (props) => {
|
|
|
5200
5177
|
};
|
|
5201
5178
|
|
|
5202
5179
|
// src/widget/basic/many2many-field/controller.ts
|
|
5203
|
-
var
|
|
5180
|
+
var import_react17 = require("react");
|
|
5204
5181
|
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5205
5182
|
var many2manyFieldController = (props) => {
|
|
5206
5183
|
const {
|
|
@@ -5215,10 +5192,10 @@ var many2manyFieldController = (props) => {
|
|
|
5215
5192
|
actionData
|
|
5216
5193
|
} = props;
|
|
5217
5194
|
const { env } = (0, provider_exports.useEnv)();
|
|
5218
|
-
const { useGetView: useGetView2, useGetListData:
|
|
5219
|
-
const [order, setOrder] = (0,
|
|
5220
|
-
const [page, setPage] = (0,
|
|
5221
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
5195
|
+
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView } = (0, provider_exports.useService)();
|
|
5196
|
+
const [order, setOrder] = (0, import_react17.useState)();
|
|
5197
|
+
const [page, setPage] = (0, import_react17.useState)(0);
|
|
5198
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
5222
5199
|
const [debouncedPage] = useDebounce(page, 500);
|
|
5223
5200
|
const contextObject = {
|
|
5224
5201
|
...env.context,
|
|
@@ -5233,7 +5210,7 @@ var many2manyFieldController = (props) => {
|
|
|
5233
5210
|
context: contextObject
|
|
5234
5211
|
};
|
|
5235
5212
|
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5236
|
-
const baseModel = (0,
|
|
5213
|
+
const baseModel = (0, import_react17.useMemo)(
|
|
5237
5214
|
() => ({
|
|
5238
5215
|
name: String(relation),
|
|
5239
5216
|
view: viewResponse || {},
|
|
@@ -5246,13 +5223,13 @@ var many2manyFieldController = (props) => {
|
|
|
5246
5223
|
[relation, viewResponse]
|
|
5247
5224
|
);
|
|
5248
5225
|
const initModel = (0, hooks_exports.useModel)();
|
|
5249
|
-
const modelInstance = (0,
|
|
5226
|
+
const modelInstance = (0, import_react17.useMemo)(() => {
|
|
5250
5227
|
if (viewResponse) {
|
|
5251
5228
|
return initModel.initModel(baseModel);
|
|
5252
5229
|
}
|
|
5253
5230
|
return null;
|
|
5254
5231
|
}, [baseModel, viewResponse]);
|
|
5255
|
-
const specification = (0,
|
|
5232
|
+
const specification = (0, import_react17.useMemo)(() => {
|
|
5256
5233
|
if (modelInstance) {
|
|
5257
5234
|
return modelInstance.getSpecification();
|
|
5258
5235
|
}
|
|
@@ -5294,8 +5271,8 @@ var many2manyFieldController = (props) => {
|
|
|
5294
5271
|
isLoading,
|
|
5295
5272
|
isFetched,
|
|
5296
5273
|
isPlaceholderData
|
|
5297
|
-
} =
|
|
5298
|
-
(0,
|
|
5274
|
+
} = useGetListData2(data, queryKey, enabled);
|
|
5275
|
+
(0, import_react17.useEffect)(() => {
|
|
5299
5276
|
if (viewResponse) {
|
|
5300
5277
|
fetchData();
|
|
5301
5278
|
}
|
|
@@ -5348,7 +5325,7 @@ var many2manyFieldController = (props) => {
|
|
|
5348
5325
|
};
|
|
5349
5326
|
|
|
5350
5327
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5351
|
-
var
|
|
5328
|
+
var import_react18 = require("react");
|
|
5352
5329
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5353
5330
|
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5354
5331
|
var many2manyTagsController = (props) => {
|
|
@@ -5364,7 +5341,7 @@ var many2manyTagsController = (props) => {
|
|
|
5364
5341
|
const { env } = (0, provider_exports.useEnv)();
|
|
5365
5342
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5366
5343
|
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5367
|
-
const domainObject = (0,
|
|
5344
|
+
const domainObject = (0, import_react18.useMemo)(
|
|
5368
5345
|
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5369
5346
|
[domain, formValues]
|
|
5370
5347
|
);
|
|
@@ -5406,7 +5383,7 @@ var many2manyTagsController = (props) => {
|
|
|
5406
5383
|
};
|
|
5407
5384
|
|
|
5408
5385
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5409
|
-
var
|
|
5386
|
+
var import_react19 = require("react");
|
|
5410
5387
|
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5411
5388
|
var durationController = (props) => {
|
|
5412
5389
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
@@ -5415,10 +5392,10 @@ var durationController = (props) => {
|
|
|
5415
5392
|
name: "",
|
|
5416
5393
|
fold: ""
|
|
5417
5394
|
};
|
|
5418
|
-
const { useGetListData:
|
|
5395
|
+
const { useGetListData: useGetListData2, useChangeStatus } = (0, provider_exports.useService)();
|
|
5419
5396
|
const { env } = (0, provider_exports.useEnv)();
|
|
5420
|
-
const [disabled, setDisabled] = (0,
|
|
5421
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5397
|
+
const [disabled, setDisabled] = (0, import_react19.useState)(false);
|
|
5398
|
+
const [modelStatus, setModalStatus] = (0, import_react19.useState)(false);
|
|
5422
5399
|
const queryKey = [`data-status-duration`, specification];
|
|
5423
5400
|
const listDataProps = {
|
|
5424
5401
|
model: relation,
|
|
@@ -5433,7 +5410,7 @@ var durationController = (props) => {
|
|
|
5433
5410
|
},
|
|
5434
5411
|
sort: ""
|
|
5435
5412
|
};
|
|
5436
|
-
const { data: dataResponse } =
|
|
5413
|
+
const { data: dataResponse } = useGetListData2(
|
|
5437
5414
|
listDataProps,
|
|
5438
5415
|
queryKey,
|
|
5439
5416
|
enabled
|
|
@@ -5508,10 +5485,10 @@ var priorityFieldController = (props) => {
|
|
|
5508
5485
|
};
|
|
5509
5486
|
|
|
5510
5487
|
// src/widget/basic/download-file-field/controller.ts
|
|
5511
|
-
var
|
|
5488
|
+
var import_react20 = require("react");
|
|
5512
5489
|
var downloadFileController = () => {
|
|
5513
|
-
const inputId = (0,
|
|
5514
|
-
const [file, setFile] = (0,
|
|
5490
|
+
const inputId = (0, import_react20.useId)();
|
|
5491
|
+
const [file, setFile] = (0, import_react20.useState)(null);
|
|
5515
5492
|
const handleFileChange = (e) => {
|
|
5516
5493
|
setFile(e.target.files[0]);
|
|
5517
5494
|
};
|
|
@@ -6443,11 +6420,11 @@ var dateFieldController = (props) => {
|
|
|
6443
6420
|
};
|
|
6444
6421
|
|
|
6445
6422
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6446
|
-
var
|
|
6423
|
+
var import_react21 = require("react");
|
|
6447
6424
|
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6448
6425
|
var copyLinkButtonController = (props) => {
|
|
6449
6426
|
const { value, defaultValue } = props;
|
|
6450
|
-
const [isCopied, setIsCopied] = (0,
|
|
6427
|
+
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6451
6428
|
const handleCopyToClipboard = async (value2) => {
|
|
6452
6429
|
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6453
6430
|
setIsCopied(true);
|
|
@@ -6495,16 +6472,16 @@ var colorFieldController = (props) => {
|
|
|
6495
6472
|
};
|
|
6496
6473
|
|
|
6497
6474
|
// src/widget/basic/binary-field/controller.ts
|
|
6498
|
-
var
|
|
6475
|
+
var import_react22 = require("react");
|
|
6499
6476
|
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6500
6477
|
var binaryFieldController = (props) => {
|
|
6501
6478
|
const { name, methods, readonly = false, value } = props;
|
|
6502
|
-
const inputId = (0,
|
|
6503
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6504
|
-
const [initialImage, setInitialImage] = (0,
|
|
6505
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6479
|
+
const inputId = (0, import_react22.useId)();
|
|
6480
|
+
const [selectedImage, setSelectedImage] = (0, import_react22.useState)(null);
|
|
6481
|
+
const [initialImage, setInitialImage] = (0, import_react22.useState)(value || null);
|
|
6482
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react22.useState)(false);
|
|
6506
6483
|
const { setValue } = methods;
|
|
6507
|
-
const binaryRef = (0,
|
|
6484
|
+
const binaryRef = (0, import_react22.useRef)(null);
|
|
6508
6485
|
const convertUrlToBase64 = async (url) => {
|
|
6509
6486
|
try {
|
|
6510
6487
|
const response = await fetch(url);
|
|
@@ -6566,14 +6543,14 @@ var binaryFieldController = (props) => {
|
|
|
6566
6543
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6567
6544
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6568
6545
|
};
|
|
6569
|
-
(0,
|
|
6546
|
+
(0, import_react22.useEffect)(() => {
|
|
6570
6547
|
return () => {
|
|
6571
6548
|
if (selectedImage) {
|
|
6572
6549
|
URL.revokeObjectURL(selectedImage);
|
|
6573
6550
|
}
|
|
6574
6551
|
};
|
|
6575
6552
|
}, [selectedImage]);
|
|
6576
|
-
(0,
|
|
6553
|
+
(0, import_react22.useEffect)(() => {
|
|
6577
6554
|
if (binaryRef.current) {
|
|
6578
6555
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6579
6556
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6593,50 +6570,73 @@ var binaryFieldController = (props) => {
|
|
|
6593
6570
|
};
|
|
6594
6571
|
|
|
6595
6572
|
// src/widget/advance/table/table-head/controller.ts
|
|
6596
|
-
var
|
|
6573
|
+
var import_store7 = require("@fctc/interface-logic/store");
|
|
6574
|
+
var import_react23 = require("react");
|
|
6597
6575
|
var tableHeadController = (props) => {
|
|
6598
|
-
const { typeTable, rows,
|
|
6599
|
-
const appDispatch = (0,
|
|
6600
|
-
const {
|
|
6576
|
+
const { typeTable, rows, tableRef, groupByList, selectedRowKeys } = props;
|
|
6577
|
+
const appDispatch = (0, import_store7.useAppDispatch)();
|
|
6578
|
+
const { rowIds: recordIds } = useGetRowIds(tableRef);
|
|
6579
|
+
const selectedRowKeysRef = (0, import_react23.useRef)(recordIds);
|
|
6580
|
+
const isGroupTable = typeTable === "group";
|
|
6581
|
+
const recordsCheckedGroup = (0, import_react23.useMemo)(() => {
|
|
6582
|
+
if (!rows || !groupByList) return 0;
|
|
6583
|
+
const groupBy = typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0;
|
|
6584
|
+
return countSum(rows, groupBy);
|
|
6585
|
+
}, [rows, groupByList]);
|
|
6586
|
+
const isAllGroupChecked = (0, import_react23.useMemo)(() => {
|
|
6587
|
+
if (!isGroupTable || !selectedRowKeys?.length) return false;
|
|
6588
|
+
const selectedLength = selectedRowKeys.filter((id) => id !== -1).length;
|
|
6589
|
+
const allRecordsSelected = recordIds.length === selectedRowKeys.length ? recordIds.length === selectedLength : false;
|
|
6590
|
+
const allGroupsSelected = recordsCheckedGroup === selectedRowKeys.length;
|
|
6591
|
+
return allGroupsSelected || allRecordsSelected;
|
|
6592
|
+
}, [isGroupTable, selectedRowKeys, recordIds, recordsCheckedGroup]);
|
|
6593
|
+
const isAllNormalChecked = (0, import_react23.useMemo)(() => {
|
|
6594
|
+
if (isGroupTable || !selectedRowKeys?.length || !rows?.length) return false;
|
|
6595
|
+
return selectedRowKeys.length === rows.length && selectedRowKeys.every(
|
|
6596
|
+
(id) => rows.some((record) => record.id === id)
|
|
6597
|
+
);
|
|
6598
|
+
}, [isGroupTable, selectedRowKeys, rows]);
|
|
6599
|
+
const checkedAll = isAllGroupChecked || isAllNormalChecked;
|
|
6601
6600
|
const handleCheckBoxAll = (event) => {
|
|
6602
6601
|
if (event?.target?.checked && typeTable === "list") {
|
|
6603
6602
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6604
|
-
appDispatch((0,
|
|
6603
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(allRowKeys));
|
|
6605
6604
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6606
6605
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6607
6606
|
const ids = Array.from(rowsIDs)?.map(
|
|
6608
6607
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6609
6608
|
);
|
|
6610
6609
|
if (ids?.length > 0) {
|
|
6611
|
-
appDispatch((0,
|
|
6610
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(ids));
|
|
6612
6611
|
} else {
|
|
6613
6612
|
const sum = countSum(
|
|
6614
6613
|
rows,
|
|
6615
|
-
typeof
|
|
6614
|
+
typeof groupByList === "object" ? groupByList?.contexts?.[0]?.group_by : void 0
|
|
6616
6615
|
);
|
|
6617
6616
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6618
|
-
appDispatch((0,
|
|
6617
|
+
appDispatch((0, import_store7.setSelectedRowKeys)(keys));
|
|
6619
6618
|
}
|
|
6620
6619
|
if (selectedRowKeysRef) {
|
|
6621
6620
|
selectedRowKeysRef.current = [];
|
|
6622
6621
|
}
|
|
6623
6622
|
} else {
|
|
6624
|
-
appDispatch((0,
|
|
6623
|
+
appDispatch((0, import_store7.setSelectedRowKeys)([]));
|
|
6625
6624
|
}
|
|
6626
6625
|
};
|
|
6627
6626
|
return {
|
|
6628
|
-
handleCheckBoxAll
|
|
6627
|
+
handleCheckBoxAll,
|
|
6628
|
+
checkedAll,
|
|
6629
|
+
selectedRowKeysRef
|
|
6629
6630
|
};
|
|
6630
6631
|
};
|
|
6631
6632
|
|
|
6632
6633
|
// src/widget/advance/table/table-view/controller.ts
|
|
6633
|
-
var
|
|
6634
|
-
var import_store9 = require("@fctc/interface-logic/store");
|
|
6634
|
+
var import_react24 = require("react");
|
|
6635
6635
|
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6636
6636
|
var tableController = ({ data }) => {
|
|
6637
|
-
const [rows, setRows] = (0,
|
|
6638
|
-
const [columns, setColumns] = (0,
|
|
6639
|
-
const dataModelFields = data
|
|
6637
|
+
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6638
|
+
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
6639
|
+
const dataModelFields = data?.fields?.map((field) => {
|
|
6640
6640
|
return {
|
|
6641
6641
|
...data.dataModel?.[field?.name],
|
|
6642
6642
|
...field,
|
|
@@ -6663,8 +6663,8 @@ var tableController = ({ data }) => {
|
|
|
6663
6663
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6664
6664
|
});
|
|
6665
6665
|
};
|
|
6666
|
-
(0,
|
|
6667
|
-
setRows(transformData(data.records
|
|
6666
|
+
(0, import_react24.useEffect)(() => {
|
|
6667
|
+
setRows(transformData(data.records));
|
|
6668
6668
|
}, [data.records]);
|
|
6669
6669
|
const handleGetColumns = () => {
|
|
6670
6670
|
let cols = [];
|
|
@@ -6684,10 +6684,11 @@ var tableController = ({ data }) => {
|
|
|
6684
6684
|
}
|
|
6685
6685
|
return cols;
|
|
6686
6686
|
};
|
|
6687
|
-
(0,
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6687
|
+
(0, import_react24.useEffect)(() => {
|
|
6688
|
+
if (!columns) {
|
|
6689
|
+
setColumns(handleGetColumns());
|
|
6690
|
+
}
|
|
6691
|
+
}, [data]);
|
|
6691
6692
|
const onToggleColumnOptional = (item) => {
|
|
6692
6693
|
const tempColumn = [...columns]?.map((val) => {
|
|
6693
6694
|
if (item?.name === val?.name) {
|
|
@@ -6700,6 +6701,14 @@ var tableController = ({ data }) => {
|
|
|
6700
6701
|
});
|
|
6701
6702
|
setColumns(tempColumn);
|
|
6702
6703
|
};
|
|
6704
|
+
(0, import_react24.useEffect)(() => {
|
|
6705
|
+
setRows(null);
|
|
6706
|
+
setColumns(null);
|
|
6707
|
+
return () => {
|
|
6708
|
+
setRows(null);
|
|
6709
|
+
setColumns(null);
|
|
6710
|
+
};
|
|
6711
|
+
}, [data?.fields]);
|
|
6703
6712
|
return {
|
|
6704
6713
|
rows,
|
|
6705
6714
|
columns,
|
|
@@ -6709,47 +6718,32 @@ var tableController = ({ data }) => {
|
|
|
6709
6718
|
};
|
|
6710
6719
|
|
|
6711
6720
|
// src/widget/advance/table/table-group/controller.ts
|
|
6712
|
-
var
|
|
6713
|
-
var
|
|
6714
|
-
var import_store10 = require("@fctc/interface-logic/store");
|
|
6715
|
-
|
|
6716
|
-
// src/environment.ts
|
|
6717
|
-
var environment_exports = {};
|
|
6718
|
-
__reExport(environment_exports, require("@fctc/interface-logic/environment"));
|
|
6719
|
-
|
|
6720
|
-
// src/widget/advance/table/table-group/controller.ts
|
|
6721
|
+
var import_react25 = require("react");
|
|
6722
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6721
6723
|
var tableGroupController = (props) => {
|
|
6722
|
-
const env = (0,
|
|
6724
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
6725
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
6723
6726
|
const {
|
|
6724
|
-
rows,
|
|
6725
6727
|
columns,
|
|
6726
|
-
indexRow,
|
|
6727
6728
|
row,
|
|
6728
6729
|
model,
|
|
6729
6730
|
viewData,
|
|
6730
|
-
renderField,
|
|
6731
6731
|
level,
|
|
6732
6732
|
specification,
|
|
6733
|
-
domain,
|
|
6734
6733
|
context,
|
|
6735
6734
|
checkedAll,
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
setIsAutoSelect,
|
|
6739
|
-
selectedRowKeysRef
|
|
6735
|
+
groupByList,
|
|
6736
|
+
setSelectedRowKeys: setSelectedRowKeys3
|
|
6740
6737
|
} = props;
|
|
6741
|
-
const [pageGroup, setPageGroup] = (0,
|
|
6742
|
-
const {
|
|
6743
|
-
const
|
|
6744
|
-
const
|
|
6745
|
-
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
6746
|
-
const initVal = toDataJS(row, viewData, model);
|
|
6747
|
-
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
6748
|
-
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
6738
|
+
const [pageGroup, setPageGroup] = (0, import_react25.useState)(0);
|
|
6739
|
+
const { selectedRowKeys } = (0, import_store8.useAppSelector)(import_store8.selectList);
|
|
6740
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react25.useState)(false);
|
|
6741
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react25.useState)({
|
|
6749
6742
|
fromStart: 1,
|
|
6750
6743
|
fromEnd: 1
|
|
6751
6744
|
});
|
|
6752
|
-
const
|
|
6745
|
+
const domain = row?.__domain;
|
|
6746
|
+
const processedData = (0, import_react25.useMemo)(() => {
|
|
6753
6747
|
const calculateColSpanEmpty = () => {
|
|
6754
6748
|
const startIndex = columns.findIndex(
|
|
6755
6749
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6764,7 +6758,7 @@ var tableGroupController = (props) => {
|
|
|
6764
6758
|
};
|
|
6765
6759
|
return calculateColSpanEmpty();
|
|
6766
6760
|
}, [columns, row]);
|
|
6767
|
-
const shouldFetchData = (0,
|
|
6761
|
+
const shouldFetchData = (0, import_react25.useMemo)(() => {
|
|
6768
6762
|
return !!isShowGroup;
|
|
6769
6763
|
}, [isShowGroup]);
|
|
6770
6764
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6774,22 +6768,22 @@ var tableGroupController = (props) => {
|
|
|
6774
6768
|
domain,
|
|
6775
6769
|
context,
|
|
6776
6770
|
offset: pageGroup * 10,
|
|
6777
|
-
fields:
|
|
6778
|
-
groupby: [
|
|
6771
|
+
fields: groupByList?.fields,
|
|
6772
|
+
groupby: [groupByList?.contexts[level]?.group_by]
|
|
6779
6773
|
};
|
|
6780
6774
|
const queryKey = [
|
|
6781
|
-
`data-${model}
|
|
6775
|
+
`data-${model}-level_${level}-row-${row?.id}`,
|
|
6782
6776
|
specification,
|
|
6783
6777
|
domain,
|
|
6784
6778
|
pageGroup
|
|
6785
6779
|
];
|
|
6786
6780
|
const {
|
|
6787
|
-
data:
|
|
6788
|
-
isFetched:
|
|
6789
|
-
isPlaceholderData,
|
|
6781
|
+
data: dataGroup,
|
|
6782
|
+
isFetched: isDataGroupFetched,
|
|
6790
6783
|
isLoading,
|
|
6791
|
-
isFetching
|
|
6792
|
-
|
|
6784
|
+
isFetching,
|
|
6785
|
+
isPlaceholderData: isDataPlaceHolder
|
|
6786
|
+
} = useGetListData2(listDataProps, queryKey, enabled);
|
|
6793
6787
|
const {
|
|
6794
6788
|
columns: columnsGroup,
|
|
6795
6789
|
rows: rowsGroup,
|
|
@@ -6797,27 +6791,21 @@ var tableGroupController = (props) => {
|
|
|
6797
6791
|
} = tableController({
|
|
6798
6792
|
data: {
|
|
6799
6793
|
fields: viewData?.views?.list?.fields,
|
|
6800
|
-
records:
|
|
6794
|
+
records: dataGroup?.records ?? dataGroup?.groups,
|
|
6801
6795
|
dataModel: viewData?.models?.[model],
|
|
6802
6796
|
context: env.context,
|
|
6803
|
-
typeTable:
|
|
6797
|
+
typeTable: dataGroup?.groups ? "group" : "list"
|
|
6804
6798
|
}
|
|
6805
6799
|
});
|
|
6806
|
-
const
|
|
6807
|
-
(0, import_react23.useEffect)(() => {
|
|
6808
|
-
if (isShowGroup && selectedTags?.length > 0) {
|
|
6809
|
-
setIsShowGroup(false);
|
|
6810
|
-
}
|
|
6811
|
-
}, [selectedTags]);
|
|
6812
|
-
const group_by_field_name = groupByDomain?.contexts[level - 1]?.group_by;
|
|
6800
|
+
const group_by_field_name = groupByList?.contexts[level - 1]?.group_by;
|
|
6813
6801
|
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(
|
|
6814
6802
|
(selectItem) => selectItem?.[0] === row[group_by_field_name]
|
|
6815
6803
|
)?.[1] : row[group_by_field_name];
|
|
6816
6804
|
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`]})`;
|
|
6817
6805
|
const allIdsNull = selectedRowKeys?.every((item) => item === void 0);
|
|
6818
|
-
const
|
|
6806
|
+
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6807
|
+
const onExpandChildGroup = () => {
|
|
6819
6808
|
if (isLoading || isFetching) return;
|
|
6820
|
-
const toggleShowGroup = () => setIsShowGroup((prev) => !prev);
|
|
6821
6809
|
if (allIdsNull || typeTableGroup === "group") {
|
|
6822
6810
|
toggleShowGroup();
|
|
6823
6811
|
return;
|
|
@@ -6827,53 +6815,39 @@ var tableGroupController = (props) => {
|
|
|
6827
6815
|
const filteredIds = selectedRowKeys.filter(
|
|
6828
6816
|
(id) => !ids.includes(id)
|
|
6829
6817
|
);
|
|
6830
|
-
|
|
6831
|
-
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull
|
|
6818
|
+
setSelectedRowKeys3(filteredIds);
|
|
6819
|
+
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull) {
|
|
6832
6820
|
const clonedKeys = [...selectedRowKeys];
|
|
6833
|
-
|
|
6834
|
-
setTimeout(() =>
|
|
6821
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
6822
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
6835
6823
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6824
|
+
console.log("abc");
|
|
6836
6825
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6837
|
-
|
|
6826
|
+
setSelectedRowKeys3(filteredKeys);
|
|
6838
6827
|
}
|
|
6839
6828
|
toggleShowGroup();
|
|
6840
6829
|
};
|
|
6841
|
-
(0,
|
|
6842
|
-
if (!
|
|
6830
|
+
(0, import_react25.useEffect)(() => {
|
|
6831
|
+
if (!isDataGroupFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6843
6832
|
return;
|
|
6844
6833
|
}
|
|
6845
6834
|
const clonedKeys = [...selectedRowKeys];
|
|
6846
|
-
(
|
|
6847
|
-
setTimeout(() => (
|
|
6848
|
-
}, [
|
|
6835
|
+
setSelectedRowKeys3([...clonedKeys, -1]);
|
|
6836
|
+
setTimeout(() => setSelectedRowKeys3(clonedKeys), 500);
|
|
6837
|
+
}, [isDataGroupFetched]);
|
|
6849
6838
|
return {
|
|
6850
|
-
|
|
6839
|
+
onExpandChildGroup,
|
|
6851
6840
|
colEmptyGroup,
|
|
6852
|
-
leftPadding,
|
|
6853
6841
|
isShowGroup,
|
|
6854
|
-
|
|
6842
|
+
isDataGroupFetched,
|
|
6843
|
+
isDataPlaceHolder,
|
|
6855
6844
|
nameGroupWithCount,
|
|
6856
|
-
columns,
|
|
6857
|
-
row,
|
|
6858
|
-
isPlaceholderData,
|
|
6859
6845
|
columnsGroup,
|
|
6860
|
-
indexRow,
|
|
6861
6846
|
rowsGroup,
|
|
6862
|
-
|
|
6863
|
-
viewData,
|
|
6864
|
-
renderField,
|
|
6865
|
-
level,
|
|
6866
|
-
specification,
|
|
6867
|
-
context,
|
|
6868
|
-
checkedAll,
|
|
6869
|
-
isDisplayCheckbox,
|
|
6870
|
-
isAutoSelect,
|
|
6871
|
-
setIsAutoSelect,
|
|
6872
|
-
selectedRowKeysRef,
|
|
6873
|
-
initVal,
|
|
6874
|
-
dataResponse,
|
|
6847
|
+
dataGroup,
|
|
6875
6848
|
pageGroup,
|
|
6876
|
-
setPageGroup
|
|
6849
|
+
setPageGroup,
|
|
6850
|
+
typeTableGroup
|
|
6877
6851
|
};
|
|
6878
6852
|
};
|
|
6879
6853
|
|
|
@@ -6881,7 +6855,7 @@ var tableGroupController = (props) => {
|
|
|
6881
6855
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
6882
6856
|
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6883
6857
|
var import_moment2 = __toESM(require_moment());
|
|
6884
|
-
var
|
|
6858
|
+
var import_react26 = require("react");
|
|
6885
6859
|
var searchController = ({
|
|
6886
6860
|
viewData,
|
|
6887
6861
|
model,
|
|
@@ -6890,12 +6864,12 @@ var searchController = ({
|
|
|
6890
6864
|
fieldsList
|
|
6891
6865
|
}) => {
|
|
6892
6866
|
const { env } = (0, provider_exports.useEnv)();
|
|
6893
|
-
const [filterBy, setFilterBy] = (0,
|
|
6894
|
-
const [searchBy, setSearchBy] = (0,
|
|
6895
|
-
const [groupBy, setGroupBy] = (0,
|
|
6896
|
-
const [selectedTags, setSelectedTags] = (0,
|
|
6897
|
-
const [searchString, setSearchString] = (0,
|
|
6898
|
-
const [searchMap, setSearchMap] = (0,
|
|
6867
|
+
const [filterBy, setFilterBy] = (0, import_react26.useState)(null);
|
|
6868
|
+
const [searchBy, setSearchBy] = (0, import_react26.useState)(null);
|
|
6869
|
+
const [groupBy, setGroupBy] = (0, import_react26.useState)(null);
|
|
6870
|
+
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
6871
|
+
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
6872
|
+
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
6899
6873
|
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
6900
6874
|
const contextSearch = { ...env.context, ...actionContext };
|
|
6901
6875
|
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
@@ -6942,7 +6916,7 @@ var searchController = ({
|
|
|
6942
6916
|
}
|
|
6943
6917
|
}
|
|
6944
6918
|
};
|
|
6945
|
-
(0,
|
|
6919
|
+
(0, import_react26.useEffect)(() => {
|
|
6946
6920
|
fetchData();
|
|
6947
6921
|
}, [model, viewData]);
|
|
6948
6922
|
const onChangeSearchInput = (search_string) => {
|
|
@@ -7024,7 +6998,7 @@ var searchController = ({
|
|
|
7024
6998
|
return [...domain2];
|
|
7025
6999
|
}
|
|
7026
7000
|
};
|
|
7027
|
-
const setTagSearch = (0,
|
|
7001
|
+
const setTagSearch = (0, import_react26.useCallback)(
|
|
7028
7002
|
(updatedMap) => {
|
|
7029
7003
|
if (!updatedMap) return;
|
|
7030
7004
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7087,7 +7061,7 @@ var searchController = ({
|
|
|
7087
7061
|
},
|
|
7088
7062
|
[searchMap]
|
|
7089
7063
|
);
|
|
7090
|
-
(0,
|
|
7064
|
+
(0, import_react26.useEffect)(() => {
|
|
7091
7065
|
setTagSearch(searchMap);
|
|
7092
7066
|
}, [searchMap]);
|
|
7093
7067
|
const handleAddTagSearch = (tag) => {
|