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