@fctc/widget-logic 1.10.6 → 2.0.2
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 +12 -1
- package/dist/hooks.d.ts +12 -1
- package/dist/hooks.js +179 -6
- package/dist/hooks.mjs +179 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +315 -247
- package/dist/index.mjs +230 -158
- package/dist/types.d.mts +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/widget.d.mts +17 -45
- package/dist/widget.d.ts +17 -45
- package/dist/widget.js +305 -239
- package/dist/widget.mjs +224 -154
- package/package.json +96 -96
package/dist/widget.js
CHANGED
|
@@ -4111,7 +4111,7 @@ var statusDropdownController = (props) => {
|
|
|
4111
4111
|
};
|
|
4112
4112
|
|
|
4113
4113
|
// src/widget/basic/many2one-field/controller.ts
|
|
4114
|
-
var
|
|
4114
|
+
var import_react15 = require("react");
|
|
4115
4115
|
|
|
4116
4116
|
// src/hooks.ts
|
|
4117
4117
|
var hooks_exports = {};
|
|
@@ -4126,6 +4126,7 @@ __export(hooks_exports, {
|
|
|
4126
4126
|
useDetail: () => useDetail,
|
|
4127
4127
|
useListData: () => useListData,
|
|
4128
4128
|
useMenu: () => useMenu,
|
|
4129
|
+
useMenuItem: () => useMenuItem,
|
|
4129
4130
|
useProfile: () => useProfile,
|
|
4130
4131
|
useUser: () => useUser,
|
|
4131
4132
|
useViewV2: () => useViewV2
|
|
@@ -4885,8 +4886,69 @@ var useAppProvider = () => {
|
|
|
4885
4886
|
return context;
|
|
4886
4887
|
};
|
|
4887
4888
|
|
|
4888
|
-
// src/hooks/
|
|
4889
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4890
|
+
var import_environment6 = require("@fctc/interface-logic/environment");
|
|
4891
|
+
var import_hooks10 = require("@fctc/interface-logic/hooks");
|
|
4889
4892
|
var import_react12 = require("react");
|
|
4893
|
+
|
|
4894
|
+
// src/utils.ts
|
|
4895
|
+
var utils_exports = {};
|
|
4896
|
+
__export(utils_exports, {
|
|
4897
|
+
API_APP_URL: () => API_APP_URL,
|
|
4898
|
+
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
4899
|
+
STORAGES: () => STORAGES,
|
|
4900
|
+
combineContexts: () => combineContexts,
|
|
4901
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
4902
|
+
countSum: () => countSum,
|
|
4903
|
+
getDateRange: () => getDateRange,
|
|
4904
|
+
languages: () => languages,
|
|
4905
|
+
mergeButtons: () => mergeButtons,
|
|
4906
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
4907
|
+
useGetRowIds: () => useGetRowIds,
|
|
4908
|
+
useSelectionState: () => useSelectionState,
|
|
4909
|
+
useStorageState: () => useStorageState
|
|
4910
|
+
});
|
|
4911
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4912
|
+
|
|
4913
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4914
|
+
var useMenuItem = (props) => {
|
|
4915
|
+
const { menu, activeMenuId } = props;
|
|
4916
|
+
const model = menu?.action?.res_model;
|
|
4917
|
+
const aid = menu?.action?.id?.id;
|
|
4918
|
+
const id = menu?.id;
|
|
4919
|
+
const context = (0, import_environment6.getEnv)().context;
|
|
4920
|
+
const queryActionDetail = (0, import_hooks10.useGetActionDetail)({
|
|
4921
|
+
aid,
|
|
4922
|
+
id,
|
|
4923
|
+
model,
|
|
4924
|
+
context,
|
|
4925
|
+
enabled: true,
|
|
4926
|
+
queryKey: [`action-${aid}`]
|
|
4927
|
+
}).data;
|
|
4928
|
+
const [path, setPath] = (0, import_react12.useState)("");
|
|
4929
|
+
const handleClick = () => {
|
|
4930
|
+
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4931
|
+
return;
|
|
4932
|
+
}
|
|
4933
|
+
const hasListView = queryActionDetail.views.some(
|
|
4934
|
+
([id2, type]) => type === "list"
|
|
4935
|
+
);
|
|
4936
|
+
const viewType = hasListView ? "list" : "form";
|
|
4937
|
+
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
4938
|
+
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
4939
|
+
const path2 = (0, utils_exports.formatUrlPath)({
|
|
4940
|
+
viewType,
|
|
4941
|
+
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
4942
|
+
aid: menu?.action?.id?.id,
|
|
4943
|
+
model: queryActionDetail.res_model
|
|
4944
|
+
});
|
|
4945
|
+
setPath(path2);
|
|
4946
|
+
};
|
|
4947
|
+
return { handleClick, path, queryActionDetail };
|
|
4948
|
+
};
|
|
4949
|
+
|
|
4950
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4951
|
+
var import_react13 = require("react");
|
|
4890
4952
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4891
4953
|
var useClickOutside = ({
|
|
4892
4954
|
handler,
|
|
@@ -4894,8 +4956,8 @@ var useClickOutside = ({
|
|
|
4894
4956
|
nodes = [],
|
|
4895
4957
|
refs
|
|
4896
4958
|
}) => {
|
|
4897
|
-
const ref = (0,
|
|
4898
|
-
(0,
|
|
4959
|
+
const ref = (0, import_react13.useRef)(null);
|
|
4960
|
+
(0, import_react13.useEffect)(() => {
|
|
4899
4961
|
const listener = (event) => {
|
|
4900
4962
|
const { target } = event;
|
|
4901
4963
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4917,10 +4979,10 @@ var useClickOutside = ({
|
|
|
4917
4979
|
};
|
|
4918
4980
|
|
|
4919
4981
|
// src/hooks/utils/use-debounce.ts
|
|
4920
|
-
var
|
|
4982
|
+
var import_react14 = require("react");
|
|
4921
4983
|
function useDebounce(value, delay) {
|
|
4922
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4923
|
-
(0,
|
|
4984
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
4985
|
+
(0, import_react14.useEffect)(() => {
|
|
4924
4986
|
const handler = setTimeout(() => {
|
|
4925
4987
|
setDebouncedValue(value);
|
|
4926
4988
|
}, delay);
|
|
@@ -4934,25 +4996,6 @@ function useDebounce(value, delay) {
|
|
|
4934
4996
|
// src/hooks.ts
|
|
4935
4997
|
__reExport(hooks_exports, require("@fctc/interface-logic/hooks"));
|
|
4936
4998
|
|
|
4937
|
-
// src/utils.ts
|
|
4938
|
-
var utils_exports = {};
|
|
4939
|
-
__export(utils_exports, {
|
|
4940
|
-
API_APP_URL: () => API_APP_URL,
|
|
4941
|
-
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
4942
|
-
STORAGES: () => STORAGES,
|
|
4943
|
-
combineContexts: () => combineContexts,
|
|
4944
|
-
convertFieldsToArray: () => convertFieldsToArray,
|
|
4945
|
-
countSum: () => countSum,
|
|
4946
|
-
getDateRange: () => getDateRange,
|
|
4947
|
-
languages: () => languages,
|
|
4948
|
-
mergeButtons: () => mergeButtons,
|
|
4949
|
-
setStorageItemAsync: () => setStorageItemAsync,
|
|
4950
|
-
useGetRowIds: () => useGetRowIds,
|
|
4951
|
-
useSelectionState: () => useSelectionState,
|
|
4952
|
-
useStorageState: () => useStorageState
|
|
4953
|
-
});
|
|
4954
|
-
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4955
|
-
|
|
4956
4999
|
// src/provider.ts
|
|
4957
5000
|
var provider_exports = {};
|
|
4958
5001
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
@@ -4972,22 +5015,22 @@ var many2oneFieldController = (props) => {
|
|
|
4972
5015
|
options: fieldOptions,
|
|
4973
5016
|
showDetail
|
|
4974
5017
|
} = props;
|
|
4975
|
-
const
|
|
4976
|
-
const [
|
|
4977
|
-
const [inputValue, setInputValue] = (0, import_react14.useState)("");
|
|
5018
|
+
const [options, setOptions] = (0, import_react15.useState)([]);
|
|
5019
|
+
const [inputValue, setInputValue] = (0, import_react15.useState)("");
|
|
4978
5020
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
4979
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
4980
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
4981
|
-
const [domainModal, setDomainModal] = (0,
|
|
4982
|
-
const [domainObject, setDomainObject] = (0,
|
|
5021
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react15.useState)(false);
|
|
5022
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react15.useState)(null);
|
|
5023
|
+
const [domainModal, setDomainModal] = (0, import_react15.useState)(null);
|
|
5024
|
+
const [domainObject, setDomainObject] = (0, import_react15.useState)(null);
|
|
4983
5025
|
const actionData = sessionStorageUtils.getActionData();
|
|
4984
5026
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5027
|
+
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
4985
5028
|
const initValue = methods?.getValues(name);
|
|
4986
5029
|
const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
|
|
4987
5030
|
const contextObject = {
|
|
4988
5031
|
...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
|
|
4989
5032
|
...fieldContext,
|
|
4990
|
-
...
|
|
5033
|
+
...context
|
|
4991
5034
|
};
|
|
4992
5035
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
4993
5036
|
const data = {
|
|
@@ -5010,18 +5053,18 @@ var many2oneFieldController = (props) => {
|
|
|
5010
5053
|
queryKey,
|
|
5011
5054
|
enabled: false
|
|
5012
5055
|
});
|
|
5013
|
-
const selectOptions = (0,
|
|
5056
|
+
const selectOptions = (0, import_react15.useMemo)(() => {
|
|
5014
5057
|
return dataOfSelection?.records?.map((val) => ({
|
|
5015
5058
|
value: val?.id,
|
|
5016
5059
|
label: val?.display_name || val?.name
|
|
5017
5060
|
})) || [];
|
|
5018
5061
|
}, [dataOfSelection]);
|
|
5019
|
-
(0,
|
|
5062
|
+
(0, import_react15.useEffect)(() => {
|
|
5020
5063
|
setOptions(selectOptions);
|
|
5021
5064
|
setDomainModal(domainObject);
|
|
5022
5065
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5023
5066
|
}, [selectOptions]);
|
|
5024
|
-
(0,
|
|
5067
|
+
(0, import_react15.useEffect)(() => {
|
|
5025
5068
|
setDomainObject(
|
|
5026
5069
|
(0, utils_exports.evalJSONDomain)(
|
|
5027
5070
|
domain,
|
|
@@ -5029,7 +5072,7 @@ var many2oneFieldController = (props) => {
|
|
|
5029
5072
|
)
|
|
5030
5073
|
);
|
|
5031
5074
|
}, [domain, formValues]);
|
|
5032
|
-
(0,
|
|
5075
|
+
(0, import_react15.useEffect)(() => {
|
|
5033
5076
|
if (!propValue && tempSelectedOption) {
|
|
5034
5077
|
methods.setValue(name, null);
|
|
5035
5078
|
setTempSelectedOption(null);
|
|
@@ -5040,10 +5083,10 @@ var many2oneFieldController = (props) => {
|
|
|
5040
5083
|
});
|
|
5041
5084
|
}
|
|
5042
5085
|
}, [propValue]);
|
|
5043
|
-
const fetchMoreOptions = (0,
|
|
5086
|
+
const fetchMoreOptions = (0, import_react15.useCallback)(() => {
|
|
5044
5087
|
refetch();
|
|
5045
5088
|
}, [refetch]);
|
|
5046
|
-
(0,
|
|
5089
|
+
(0, import_react15.useEffect)(() => {
|
|
5047
5090
|
if (debouncedInputValue) {
|
|
5048
5091
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5049
5092
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5058,7 +5101,7 @@ var many2oneFieldController = (props) => {
|
|
|
5058
5101
|
}, 50);
|
|
5059
5102
|
}
|
|
5060
5103
|
}, [debouncedInputValue]);
|
|
5061
|
-
const handleChooseRecord = (0,
|
|
5104
|
+
const handleChooseRecord = (0, import_react15.useCallback)(
|
|
5062
5105
|
(idRecord) => {
|
|
5063
5106
|
const newOption = options.find(
|
|
5064
5107
|
(option) => option.value === idRecord
|
|
@@ -5083,8 +5126,8 @@ var many2oneFieldController = (props) => {
|
|
|
5083
5126
|
},
|
|
5084
5127
|
[options, methods, name, onChange]
|
|
5085
5128
|
);
|
|
5086
|
-
const handleClose = (0,
|
|
5087
|
-
const handleSelectChange = (0,
|
|
5129
|
+
const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5130
|
+
const handleSelectChange = (0, import_react15.useCallback)(
|
|
5088
5131
|
(selectedOption) => {
|
|
5089
5132
|
if (!selectedOption) {
|
|
5090
5133
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5131,20 +5174,20 @@ var many2oneFieldController = (props) => {
|
|
|
5131
5174
|
};
|
|
5132
5175
|
|
|
5133
5176
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5134
|
-
var
|
|
5135
|
-
var
|
|
5136
|
-
var
|
|
5177
|
+
var import_environment7 = require("@fctc/interface-logic/environment");
|
|
5178
|
+
var import_hooks13 = require("@fctc/interface-logic/hooks");
|
|
5179
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5137
5180
|
var many2oneButtonController = (props) => {
|
|
5138
5181
|
const { domain, methods, relation } = props;
|
|
5139
5182
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5140
|
-
const env = (0,
|
|
5141
|
-
const domainObject = (0,
|
|
5183
|
+
const env = (0, import_environment7.getEnv)();
|
|
5184
|
+
const domainObject = (0, import_utils6.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5142
5185
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5143
|
-
const { data: dataOfSelection } = (0,
|
|
5186
|
+
const { data: dataOfSelection } = (0, import_hooks13.useGetSelection)({
|
|
5144
5187
|
data: {
|
|
5145
5188
|
model: relation ?? "",
|
|
5146
5189
|
domain: domainObject,
|
|
5147
|
-
context: { ...env.context, ...(0,
|
|
5190
|
+
context: { ...env.context, ...(0, import_utils6.evalJSONContext)(actionData?.context) }
|
|
5148
5191
|
},
|
|
5149
5192
|
queryKey: [`data_${relation}`, domainObject]
|
|
5150
5193
|
});
|
|
@@ -5158,78 +5201,91 @@ var many2oneButtonController = (props) => {
|
|
|
5158
5201
|
};
|
|
5159
5202
|
|
|
5160
5203
|
// src/widget/basic/many2many-field/controller.ts
|
|
5161
|
-
var
|
|
5162
|
-
var
|
|
5204
|
+
var import_react16 = require("react");
|
|
5205
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
5206
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5163
5207
|
var many2manyFieldController = (props) => {
|
|
5164
5208
|
const {
|
|
5165
5209
|
relation,
|
|
5166
5210
|
domain,
|
|
5167
5211
|
context,
|
|
5168
|
-
options,
|
|
5169
5212
|
tab,
|
|
5213
|
+
model,
|
|
5214
|
+
aid,
|
|
5170
5215
|
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5216
|
+
fields,
|
|
5217
|
+
setFields,
|
|
5171
5218
|
groupByDomain,
|
|
5172
|
-
|
|
5173
|
-
|
|
5219
|
+
page,
|
|
5220
|
+
options,
|
|
5221
|
+
sessionStorageUtils
|
|
5174
5222
|
} = props;
|
|
5223
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
5224
|
+
const actionData = sessionStorageUtils.getActionData();
|
|
5225
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5226
|
+
const [order, setOrder] = (0, import_react16.useState)();
|
|
5227
|
+
const [isLoadedData, setIsLoadedData] = (0, import_react16.useState)(false);
|
|
5228
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(domain);
|
|
5175
5229
|
const { env } = (0, provider_exports.useEnv)();
|
|
5176
5230
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5177
|
-
const [order, setOrder] = (0, import_react15.useState)();
|
|
5178
|
-
const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
|
|
5179
|
-
const [page, setPage] = (0, import_react15.useState)(0);
|
|
5180
|
-
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(null);
|
|
5181
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
5182
|
-
const contextObject = {
|
|
5183
|
-
...env.context,
|
|
5184
|
-
...context || {}
|
|
5185
|
-
};
|
|
5186
5231
|
const viewParams = {
|
|
5187
5232
|
model: relation,
|
|
5188
5233
|
views: [
|
|
5189
5234
|
[false, "list"],
|
|
5190
5235
|
[false, "search"]
|
|
5191
5236
|
],
|
|
5192
|
-
context
|
|
5237
|
+
context
|
|
5193
5238
|
};
|
|
5194
|
-
const { data: viewResponse } = useGetView2(viewParams,
|
|
5195
|
-
const baseModel = (0,
|
|
5239
|
+
const { data: viewResponse } = useGetView2(viewParams, actionData);
|
|
5240
|
+
const baseModel = (0, import_react16.useMemo)(
|
|
5196
5241
|
() => ({
|
|
5197
5242
|
name: String(relation),
|
|
5198
5243
|
view: viewResponse || {},
|
|
5199
|
-
actContext:
|
|
5244
|
+
actContext: context,
|
|
5200
5245
|
fields: [
|
|
5201
5246
|
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5202
5247
|
...tab?.fields ? tab.fields : []
|
|
5203
5248
|
]
|
|
5204
5249
|
}),
|
|
5205
|
-
[
|
|
5250
|
+
[model, viewResponse]
|
|
5206
5251
|
);
|
|
5207
5252
|
const initModel = (0, hooks_exports.useModel)();
|
|
5208
|
-
const modelInstance = (0,
|
|
5253
|
+
const modelInstance = (0, import_react16.useMemo)(() => {
|
|
5209
5254
|
if (viewResponse) {
|
|
5210
5255
|
return initModel.initModel(baseModel);
|
|
5211
5256
|
}
|
|
5212
5257
|
return null;
|
|
5213
5258
|
}, [baseModel, viewResponse]);
|
|
5214
|
-
const specification = (0,
|
|
5259
|
+
const specification = (0, import_react16.useMemo)(() => {
|
|
5215
5260
|
if (modelInstance) {
|
|
5216
5261
|
return modelInstance.getSpecification();
|
|
5217
5262
|
}
|
|
5218
5263
|
return null;
|
|
5219
5264
|
}, [modelInstance]);
|
|
5220
5265
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5221
|
-
const optionsObject = tab?.options ? (0,
|
|
5266
|
+
const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
|
|
5222
5267
|
const fetchData = async () => {
|
|
5223
5268
|
try {
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5269
|
+
setDomainMany2Many(domain);
|
|
5270
|
+
appDispatch((0, import_store8.setFirstDomain)(domain));
|
|
5271
|
+
appDispatch((0, import_store8.setViewDataStore)(viewResponse));
|
|
5272
|
+
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
5273
|
+
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
5274
|
+
...field
|
|
5275
|
+
}));
|
|
5276
|
+
if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
|
|
5277
|
+
setFields({
|
|
5278
|
+
...fields,
|
|
5279
|
+
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
5280
|
+
});
|
|
5281
|
+
}
|
|
5282
|
+
appDispatch((0, import_store8.setPage)(0));
|
|
5227
5283
|
} catch (err) {
|
|
5228
5284
|
console.log(err);
|
|
5229
5285
|
}
|
|
5230
5286
|
};
|
|
5231
5287
|
const queryKey = [
|
|
5232
|
-
`view-${relation}`,
|
|
5288
|
+
`view-${relation}-${aid}`,
|
|
5233
5289
|
specification,
|
|
5234
5290
|
domainMany2Many,
|
|
5235
5291
|
debouncedPage,
|
|
@@ -5242,82 +5298,93 @@ var many2manyFieldController = (props) => {
|
|
|
5242
5298
|
domain: domainMany2Many,
|
|
5243
5299
|
offset: debouncedPage * 10,
|
|
5244
5300
|
limit: 10,
|
|
5245
|
-
context
|
|
5301
|
+
context,
|
|
5246
5302
|
fields: groupByDomain?.fields,
|
|
5247
5303
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5248
|
-
sort: order ? order : default_order ? (0,
|
|
5304
|
+
sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
|
|
5249
5305
|
};
|
|
5250
|
-
const enabled =
|
|
5306
|
+
const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5251
5307
|
const {
|
|
5252
5308
|
data: dataResponse,
|
|
5253
|
-
isLoading,
|
|
5254
|
-
isFetched,
|
|
5309
|
+
isLoading: isDataLoading,
|
|
5310
|
+
isFetched: isDataResponseFetched,
|
|
5255
5311
|
isPlaceholderData
|
|
5256
5312
|
} = useGetListData3(data, queryKey, enabled);
|
|
5257
|
-
(0,
|
|
5313
|
+
(0, import_react16.useEffect)(() => {
|
|
5258
5314
|
if (viewResponse) {
|
|
5259
5315
|
fetchData();
|
|
5260
5316
|
}
|
|
5261
5317
|
return () => {
|
|
5262
|
-
|
|
5318
|
+
appDispatch((0, import_store8.setGroupByDomain)(null));
|
|
5319
|
+
setFields((prevFields) => ({
|
|
5320
|
+
...prevFields,
|
|
5321
|
+
[`${aid}_${relation}_popupmany2many`]: null
|
|
5322
|
+
}));
|
|
5323
|
+
appDispatch((0, import_store8.setPage)(0));
|
|
5263
5324
|
setSelectedRowKeys4([]);
|
|
5264
5325
|
setDomainMany2Many(null);
|
|
5265
5326
|
setIsLoadedData(false);
|
|
5266
5327
|
};
|
|
5267
5328
|
}, [viewResponse]);
|
|
5268
|
-
const { rows, columns, typeTable
|
|
5329
|
+
const { rows, columns, typeTable } = tableController({
|
|
5269
5330
|
data: {
|
|
5270
|
-
fields: viewResponse?.views?.list?.fields,
|
|
5331
|
+
fields: fields?.[`${aid}_${relation}_popupmany2many`] || viewResponse?.views?.list?.fields,
|
|
5271
5332
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5272
5333
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5273
|
-
context:
|
|
5334
|
+
context: { ...env.context, ...context },
|
|
5274
5335
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5275
5336
|
}
|
|
5276
5337
|
});
|
|
5277
|
-
const
|
|
5278
|
-
|
|
5279
|
-
model: relation
|
|
5280
|
-
context
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5338
|
+
const dataFormView = {
|
|
5339
|
+
id: null,
|
|
5340
|
+
model: relation,
|
|
5341
|
+
context
|
|
5342
|
+
};
|
|
5343
|
+
const {
|
|
5344
|
+
refetch,
|
|
5345
|
+
data: dataFormViewResponse,
|
|
5346
|
+
isSuccess
|
|
5347
|
+
} = useGetFormView({
|
|
5348
|
+
data: dataFormView,
|
|
5349
|
+
queryKey: [`form-view-action-${relation}`],
|
|
5350
|
+
enabled: false
|
|
5287
5351
|
});
|
|
5288
|
-
(0,
|
|
5352
|
+
(0, import_react16.useEffect)(() => {
|
|
5353
|
+
if (isSuccess && dataFormViewResponse) {
|
|
5354
|
+
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5355
|
+
window.location.href = `/form/menu?model=${relation}`;
|
|
5356
|
+
}
|
|
5357
|
+
}, [isSuccess]);
|
|
5358
|
+
(0, import_react16.useEffect)(() => {
|
|
5289
5359
|
if (domainMany2Many && !isLoadedData) {
|
|
5290
5360
|
setIsLoadedData(true);
|
|
5291
5361
|
}
|
|
5292
5362
|
}, [domainMany2Many]);
|
|
5293
5363
|
const handleCreateNewOnPage = async () => {
|
|
5364
|
+
try {
|
|
5365
|
+
refetch();
|
|
5366
|
+
} catch (error) {
|
|
5367
|
+
console.log(error);
|
|
5368
|
+
}
|
|
5294
5369
|
};
|
|
5295
5370
|
return {
|
|
5296
5371
|
handleCreateNewOnPage,
|
|
5297
5372
|
optionsObject,
|
|
5298
|
-
totalRows: dataResponse?.length ?? 0,
|
|
5299
5373
|
rows,
|
|
5300
5374
|
columns,
|
|
5301
|
-
onToggleColumnOptional,
|
|
5302
5375
|
typeTable,
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
isPlaceholderData
|
|
5306
|
-
setPage,
|
|
5307
|
-
page,
|
|
5308
|
-
viewData: viewResponse,
|
|
5309
|
-
domain: domainMany2Many,
|
|
5310
|
-
setDomain: setDomainMany2Many,
|
|
5311
|
-
searchController: searchControllers
|
|
5376
|
+
isDataLoading,
|
|
5377
|
+
isDataResponseFetched,
|
|
5378
|
+
isPlaceholderData
|
|
5312
5379
|
};
|
|
5313
5380
|
};
|
|
5314
5381
|
|
|
5315
5382
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5316
|
-
var
|
|
5383
|
+
var import_react17 = require("react");
|
|
5317
5384
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5318
|
-
var
|
|
5319
|
-
var
|
|
5320
|
-
var
|
|
5385
|
+
var import_environment8 = require("@fctc/interface-logic/environment");
|
|
5386
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
5387
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5321
5388
|
var many2manyTagsController = (props) => {
|
|
5322
5389
|
const {
|
|
5323
5390
|
relation,
|
|
@@ -5328,10 +5395,10 @@ var many2manyTagsController = (props) => {
|
|
|
5328
5395
|
placeholderNoOption
|
|
5329
5396
|
} = props;
|
|
5330
5397
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5331
|
-
const env = (0,
|
|
5332
|
-
const addtionalFields = optionsFields ? (0,
|
|
5333
|
-
const domainObject = (0,
|
|
5334
|
-
() => (0,
|
|
5398
|
+
const env = (0, import_environment8.getEnv)();
|
|
5399
|
+
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5400
|
+
const domainObject = (0, import_react17.useMemo)(
|
|
5401
|
+
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5335
5402
|
[domain, formValues]
|
|
5336
5403
|
);
|
|
5337
5404
|
const data = {
|
|
@@ -5347,7 +5414,7 @@ var many2manyTagsController = (props) => {
|
|
|
5347
5414
|
enabled: true,
|
|
5348
5415
|
context: env.context
|
|
5349
5416
|
};
|
|
5350
|
-
const { data: dataOfSelection } = (0,
|
|
5417
|
+
const { data: dataOfSelection } = (0, import_hooks15.useGetSelection)({
|
|
5351
5418
|
data,
|
|
5352
5419
|
queryKey: [`data_${relation}`, domainObject]
|
|
5353
5420
|
});
|
|
@@ -5373,8 +5440,8 @@ var many2manyTagsController = (props) => {
|
|
|
5373
5440
|
};
|
|
5374
5441
|
|
|
5375
5442
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5376
|
-
var
|
|
5377
|
-
var
|
|
5443
|
+
var import_react18 = require("react");
|
|
5444
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5378
5445
|
var durationController = (props) => {
|
|
5379
5446
|
const { relation, domain, formValues, name, id, model, onRefetch } = props;
|
|
5380
5447
|
const specification = {
|
|
@@ -5384,13 +5451,13 @@ var durationController = (props) => {
|
|
|
5384
5451
|
};
|
|
5385
5452
|
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5386
5453
|
const { env } = (0, provider_exports.useEnv)();
|
|
5387
|
-
const [disabled, setDisabled] = (0,
|
|
5388
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5454
|
+
const [disabled, setDisabled] = (0, import_react18.useState)(false);
|
|
5455
|
+
const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
|
|
5389
5456
|
const queryKey = [`data-status-duration`, specification];
|
|
5390
5457
|
const listDataProps = {
|
|
5391
5458
|
model: relation,
|
|
5392
5459
|
specification,
|
|
5393
|
-
domain: (0,
|
|
5460
|
+
domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5394
5461
|
limit: 10,
|
|
5395
5462
|
offset: 0,
|
|
5396
5463
|
fields: "",
|
|
@@ -5436,8 +5503,8 @@ var durationController = (props) => {
|
|
|
5436
5503
|
};
|
|
5437
5504
|
|
|
5438
5505
|
// src/widget/basic/priority-field/controller.ts
|
|
5439
|
-
var
|
|
5440
|
-
var
|
|
5506
|
+
var import_hooks16 = require("@fctc/interface-logic/hooks");
|
|
5507
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5441
5508
|
var priorityFieldController = (props) => {
|
|
5442
5509
|
const {
|
|
5443
5510
|
value,
|
|
@@ -5452,11 +5519,11 @@ var priorityFieldController = (props) => {
|
|
|
5452
5519
|
viewData,
|
|
5453
5520
|
context
|
|
5454
5521
|
} = props;
|
|
5455
|
-
const _context = { ...(0,
|
|
5522
|
+
const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
|
|
5456
5523
|
const contextObject = { ...context, ..._context };
|
|
5457
5524
|
const defaultPriority = parseInt(value) + 1;
|
|
5458
5525
|
const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
|
|
5459
|
-
const { mutateAsync: fetchSave } = (0,
|
|
5526
|
+
const { mutateAsync: fetchSave } = (0, import_hooks16.useSave)();
|
|
5460
5527
|
const savePriorities = async ({
|
|
5461
5528
|
value: value2,
|
|
5462
5529
|
resetPriority
|
|
@@ -5491,10 +5558,10 @@ var priorityFieldController = (props) => {
|
|
|
5491
5558
|
};
|
|
5492
5559
|
|
|
5493
5560
|
// src/widget/basic/download-file-field/controller.ts
|
|
5494
|
-
var
|
|
5561
|
+
var import_react19 = require("react");
|
|
5495
5562
|
var downloadFileController = () => {
|
|
5496
|
-
const inputId = (0,
|
|
5497
|
-
const [file, setFile] = (0,
|
|
5563
|
+
const inputId = (0, import_react19.useId)();
|
|
5564
|
+
const [file, setFile] = (0, import_react19.useState)(null);
|
|
5498
5565
|
const handleFileChange = (e) => {
|
|
5499
5566
|
setFile(e.target.files[0]);
|
|
5500
5567
|
};
|
|
@@ -6426,13 +6493,13 @@ var dateFieldController = (props) => {
|
|
|
6426
6493
|
};
|
|
6427
6494
|
|
|
6428
6495
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6429
|
-
var
|
|
6430
|
-
var
|
|
6496
|
+
var import_react20 = require("react");
|
|
6497
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6431
6498
|
var copyLinkButtonController = (props) => {
|
|
6432
6499
|
const { value, defaultValue } = props;
|
|
6433
|
-
const [isCopied, setIsCopied] = (0,
|
|
6500
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
6434
6501
|
const handleCopyToClipboard = async (value2) => {
|
|
6435
|
-
await (0,
|
|
6502
|
+
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6436
6503
|
setIsCopied(true);
|
|
6437
6504
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6438
6505
|
};
|
|
@@ -6445,12 +6512,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6445
6512
|
};
|
|
6446
6513
|
|
|
6447
6514
|
// src/widget/basic/color-field/color-controller.ts
|
|
6448
|
-
var
|
|
6515
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
6449
6516
|
var colorFieldController = (props) => {
|
|
6450
6517
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6451
6518
|
const { env } = (0, provider_exports.useEnv)();
|
|
6452
6519
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6453
|
-
const _context = { ...(0,
|
|
6520
|
+
const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
|
|
6454
6521
|
const contextObject = { ...env.context, ..._context };
|
|
6455
6522
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6456
6523
|
const { mutate: onSave } = useSave3();
|
|
@@ -6478,16 +6545,16 @@ var colorFieldController = (props) => {
|
|
|
6478
6545
|
};
|
|
6479
6546
|
|
|
6480
6547
|
// src/widget/basic/binary-field/controller.ts
|
|
6481
|
-
var
|
|
6482
|
-
var
|
|
6548
|
+
var import_react21 = require("react");
|
|
6549
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6483
6550
|
var binaryFieldController = (props) => {
|
|
6484
6551
|
const { name, methods, readonly = false, value } = props;
|
|
6485
|
-
const inputId = (0,
|
|
6486
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6487
|
-
const [initialImage, setInitialImage] = (0,
|
|
6488
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6552
|
+
const inputId = (0, import_react21.useId)();
|
|
6553
|
+
const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
|
|
6554
|
+
const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
|
|
6555
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
|
|
6489
6556
|
const { setValue } = methods;
|
|
6490
|
-
const binaryRef = (0,
|
|
6557
|
+
const binaryRef = (0, import_react21.useRef)(null);
|
|
6491
6558
|
const convertUrlToBase64 = async (url) => {
|
|
6492
6559
|
try {
|
|
6493
6560
|
const response = await fetch(url);
|
|
@@ -6536,11 +6603,11 @@ var binaryFieldController = (props) => {
|
|
|
6536
6603
|
};
|
|
6537
6604
|
const checkIsImageLink = (url) => {
|
|
6538
6605
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6539
|
-
return imageExtensions.test(url) || (0,
|
|
6606
|
+
return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
|
|
6540
6607
|
};
|
|
6541
6608
|
const getImageBase64WithMimeType = (base64) => {
|
|
6542
6609
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6543
|
-
if ((0,
|
|
6610
|
+
if ((0, import_utils13.isBase64Image)(base64)) return base64;
|
|
6544
6611
|
let mimeType = null;
|
|
6545
6612
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6546
6613
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6549,14 +6616,14 @@ var binaryFieldController = (props) => {
|
|
|
6549
6616
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6550
6617
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6551
6618
|
};
|
|
6552
|
-
(0,
|
|
6619
|
+
(0, import_react21.useEffect)(() => {
|
|
6553
6620
|
return () => {
|
|
6554
6621
|
if (selectedImage) {
|
|
6555
6622
|
URL.revokeObjectURL(selectedImage);
|
|
6556
6623
|
}
|
|
6557
6624
|
};
|
|
6558
6625
|
}, [selectedImage]);
|
|
6559
|
-
(0,
|
|
6626
|
+
(0, import_react21.useEffect)(() => {
|
|
6560
6627
|
if (binaryRef.current) {
|
|
6561
6628
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6562
6629
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6576,8 +6643,8 @@ var binaryFieldController = (props) => {
|
|
|
6576
6643
|
};
|
|
6577
6644
|
|
|
6578
6645
|
// src/widget/advance/table/table-body/controller.ts
|
|
6579
|
-
var
|
|
6580
|
-
var
|
|
6646
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6647
|
+
var import_react22 = require("react");
|
|
6581
6648
|
var tableBodyController = (props) => {
|
|
6582
6649
|
const {
|
|
6583
6650
|
checkedAll,
|
|
@@ -6589,8 +6656,8 @@ var tableBodyController = (props) => {
|
|
|
6589
6656
|
selectedRowKeysRef,
|
|
6590
6657
|
onClickRow
|
|
6591
6658
|
} = props;
|
|
6592
|
-
const appDispatch = (0,
|
|
6593
|
-
const checked = (0,
|
|
6659
|
+
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6660
|
+
const checked = (0, import_react22.useMemo)(() => {
|
|
6594
6661
|
if (!row?.id) return false;
|
|
6595
6662
|
if (selectedRowKeys?.includes(row.id)) {
|
|
6596
6663
|
return true;
|
|
@@ -6606,12 +6673,12 @@ var tableBodyController = (props) => {
|
|
|
6606
6673
|
}
|
|
6607
6674
|
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6608
6675
|
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6609
|
-
appDispatch((0,
|
|
6676
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6610
6677
|
};
|
|
6611
6678
|
const handleClickRow = (col, row2) => {
|
|
6612
6679
|
onClickRow(col, row2);
|
|
6613
6680
|
};
|
|
6614
|
-
(0,
|
|
6681
|
+
(0, import_react22.useEffect)(() => {
|
|
6615
6682
|
if (!row?.id) return;
|
|
6616
6683
|
if (isAutoSelect) {
|
|
6617
6684
|
if (checkboxRef?.current === "uncheck") {
|
|
@@ -6619,17 +6686,17 @@ var tableBodyController = (props) => {
|
|
|
6619
6686
|
(id) => id !== row.id
|
|
6620
6687
|
);
|
|
6621
6688
|
selectedRowKeysRef.current = filtered;
|
|
6622
|
-
appDispatch((0,
|
|
6689
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(filtered));
|
|
6623
6690
|
} else {
|
|
6624
6691
|
const unique = Array.from(
|
|
6625
6692
|
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6626
6693
|
);
|
|
6627
6694
|
selectedRowKeysRef.current = unique;
|
|
6628
|
-
appDispatch((0,
|
|
6695
|
+
appDispatch((0, import_store9.setSelectedRowKeys)(unique));
|
|
6629
6696
|
}
|
|
6630
6697
|
}
|
|
6631
6698
|
}, [isAutoSelect]);
|
|
6632
|
-
(0,
|
|
6699
|
+
(0, import_react22.useEffect)(() => {
|
|
6633
6700
|
if (!checkedAll) {
|
|
6634
6701
|
checkboxRef.current = "enabled";
|
|
6635
6702
|
false;
|
|
@@ -6643,35 +6710,35 @@ var tableBodyController = (props) => {
|
|
|
6643
6710
|
};
|
|
6644
6711
|
|
|
6645
6712
|
// src/widget/advance/table/table-head/controller.ts
|
|
6646
|
-
var
|
|
6713
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6647
6714
|
var tableHeadController = (props) => {
|
|
6648
6715
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6649
|
-
const appDispatch = (0,
|
|
6650
|
-
const { groupByDomain } = (0,
|
|
6716
|
+
const appDispatch = (0, import_store10.useAppDispatch)();
|
|
6717
|
+
const { groupByDomain } = (0, import_store10.useAppSelector)(import_store10.selectSearch);
|
|
6651
6718
|
const handleCheckBoxAll = (event) => {
|
|
6652
6719
|
if (event?.target?.checked && typeTable === "list") {
|
|
6653
6720
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6654
|
-
appDispatch((0,
|
|
6721
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(allRowKeys));
|
|
6655
6722
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6656
6723
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6657
6724
|
const ids = Array.from(rowsIDs)?.map(
|
|
6658
6725
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6659
6726
|
);
|
|
6660
6727
|
if (ids?.length > 0) {
|
|
6661
|
-
appDispatch((0,
|
|
6728
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(ids));
|
|
6662
6729
|
} else {
|
|
6663
6730
|
const sum = countSum(
|
|
6664
6731
|
rows,
|
|
6665
6732
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6666
6733
|
);
|
|
6667
6734
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6668
|
-
appDispatch((0,
|
|
6735
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(keys));
|
|
6669
6736
|
}
|
|
6670
6737
|
if (selectedRowKeysRef) {
|
|
6671
6738
|
selectedRowKeysRef.current = [];
|
|
6672
6739
|
}
|
|
6673
6740
|
} else {
|
|
6674
|
-
appDispatch((0,
|
|
6741
|
+
appDispatch((0, import_store10.setSelectedRowKeys)([]));
|
|
6675
6742
|
}
|
|
6676
6743
|
};
|
|
6677
6744
|
return {
|
|
@@ -6680,12 +6747,12 @@ var tableHeadController = (props) => {
|
|
|
6680
6747
|
};
|
|
6681
6748
|
|
|
6682
6749
|
// src/widget/advance/table/table-view/controller.ts
|
|
6683
|
-
var
|
|
6684
|
-
var
|
|
6685
|
-
var
|
|
6750
|
+
var import_react23 = require("react");
|
|
6751
|
+
var import_store11 = require("@fctc/interface-logic/store");
|
|
6752
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6686
6753
|
var tableController = ({ data }) => {
|
|
6687
|
-
const [rows, setRows] = (0,
|
|
6688
|
-
const [columns, setColumns] = (0,
|
|
6754
|
+
const [rows, setRows] = (0, import_react23.useState)(data.records || []);
|
|
6755
|
+
const [columns, setColumns] = (0, import_react23.useState)([]);
|
|
6689
6756
|
const dataModelFields = data.fields?.map((field) => {
|
|
6690
6757
|
return {
|
|
6691
6758
|
...data.dataModel?.[field?.name],
|
|
@@ -6713,14 +6780,14 @@ var tableController = ({ data }) => {
|
|
|
6713
6780
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6714
6781
|
});
|
|
6715
6782
|
};
|
|
6716
|
-
(0,
|
|
6783
|
+
(0, import_react23.useEffect)(() => {
|
|
6717
6784
|
setRows(transformData(data.records || null));
|
|
6718
6785
|
}, [data.records]);
|
|
6719
6786
|
const handleGetColumns = () => {
|
|
6720
6787
|
let cols = [];
|
|
6721
6788
|
try {
|
|
6722
6789
|
cols = mergeFields?.filter((item) => {
|
|
6723
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6790
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils14.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils14.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
6724
6791
|
})?.map((field) => {
|
|
6725
6792
|
return {
|
|
6726
6793
|
name: field?.name,
|
|
@@ -6734,7 +6801,7 @@ var tableController = ({ data }) => {
|
|
|
6734
6801
|
}
|
|
6735
6802
|
return cols;
|
|
6736
6803
|
};
|
|
6737
|
-
(0,
|
|
6804
|
+
(0, import_react23.useEffect)(() => {
|
|
6738
6805
|
const columns2 = handleGetColumns();
|
|
6739
6806
|
setColumns(columns2);
|
|
6740
6807
|
}, [data.records]);
|
|
@@ -6759,9 +6826,9 @@ var tableController = ({ data }) => {
|
|
|
6759
6826
|
};
|
|
6760
6827
|
|
|
6761
6828
|
// src/widget/advance/table/table-group/controller.ts
|
|
6762
|
-
var
|
|
6763
|
-
var
|
|
6764
|
-
var
|
|
6829
|
+
var import_react24 = require("react");
|
|
6830
|
+
var import_hooks17 = require("@fctc/interface-logic/hooks");
|
|
6831
|
+
var import_store12 = require("@fctc/interface-logic/store");
|
|
6765
6832
|
|
|
6766
6833
|
// src/environment.ts
|
|
6767
6834
|
var environment_exports = {};
|
|
@@ -6788,18 +6855,18 @@ var tableGroupController = (props) => {
|
|
|
6788
6855
|
setIsAutoSelect,
|
|
6789
6856
|
selectedRowKeysRef
|
|
6790
6857
|
} = props;
|
|
6791
|
-
const [pageGroup, setPageGroup] = (0,
|
|
6792
|
-
const { groupByDomain, selectedTags } = (0,
|
|
6793
|
-
const { selectedRowKeys } = (0,
|
|
6794
|
-
const appDispatch = (0,
|
|
6795
|
-
const { toDataJS } = (0,
|
|
6858
|
+
const [pageGroup, setPageGroup] = (0, import_react24.useState)(0);
|
|
6859
|
+
const { groupByDomain, selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
|
|
6860
|
+
const { selectedRowKeys } = (0, import_store12.useAppSelector)(import_store12.selectList);
|
|
6861
|
+
const appDispatch = (0, import_store12.useAppDispatch)();
|
|
6862
|
+
const { toDataJS } = (0, import_hooks17.useOdooDataTransform)();
|
|
6796
6863
|
const initVal = toDataJS(row, viewData, model);
|
|
6797
|
-
const [isShowGroup, setIsShowGroup] = (0,
|
|
6798
|
-
const [colEmptyGroup, setColEmptyGroup] = (0,
|
|
6864
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react24.useState)(false);
|
|
6865
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react24.useState)({
|
|
6799
6866
|
fromStart: 1,
|
|
6800
6867
|
fromEnd: 1
|
|
6801
6868
|
});
|
|
6802
|
-
const processedData = (0,
|
|
6869
|
+
const processedData = (0, import_react24.useMemo)(() => {
|
|
6803
6870
|
const calculateColSpanEmpty = () => {
|
|
6804
6871
|
const startIndex = columns.findIndex(
|
|
6805
6872
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6814,7 +6881,7 @@ var tableGroupController = (props) => {
|
|
|
6814
6881
|
};
|
|
6815
6882
|
return calculateColSpanEmpty();
|
|
6816
6883
|
}, [columns, row]);
|
|
6817
|
-
const shouldFetchData = (0,
|
|
6884
|
+
const shouldFetchData = (0, import_react24.useMemo)(() => {
|
|
6818
6885
|
return !!isShowGroup;
|
|
6819
6886
|
}, [isShowGroup]);
|
|
6820
6887
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6839,7 +6906,7 @@ var tableGroupController = (props) => {
|
|
|
6839
6906
|
isPlaceholderData,
|
|
6840
6907
|
isLoading,
|
|
6841
6908
|
isFetching
|
|
6842
|
-
} = (0,
|
|
6909
|
+
} = (0, import_hooks17.useGetListData)(listDataProps, queryKey, enabled);
|
|
6843
6910
|
const {
|
|
6844
6911
|
columns: columnsGroup,
|
|
6845
6912
|
rows: rowsGroup,
|
|
@@ -6854,7 +6921,7 @@ var tableGroupController = (props) => {
|
|
|
6854
6921
|
}
|
|
6855
6922
|
});
|
|
6856
6923
|
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6857
|
-
(0,
|
|
6924
|
+
(0, import_react24.useEffect)(() => {
|
|
6858
6925
|
if (isShowGroup && selectedTags?.length > 0) {
|
|
6859
6926
|
setIsShowGroup(false);
|
|
6860
6927
|
}
|
|
@@ -6877,24 +6944,24 @@ var tableGroupController = (props) => {
|
|
|
6877
6944
|
const filteredIds = selectedRowKeys.filter(
|
|
6878
6945
|
(id) => !ids.includes(id)
|
|
6879
6946
|
);
|
|
6880
|
-
appDispatch((0,
|
|
6947
|
+
appDispatch((0, import_store12.setSelectedRowKeys)(filteredIds));
|
|
6881
6948
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6882
6949
|
const clonedKeys = [...selectedRowKeys];
|
|
6883
|
-
appDispatch((0,
|
|
6884
|
-
setTimeout(() => appDispatch((0,
|
|
6950
|
+
appDispatch((0, import_store12.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
6951
|
+
setTimeout(() => appDispatch((0, import_store12.setSelectedRowKeys)(clonedKeys)), 500);
|
|
6885
6952
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6886
6953
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6887
|
-
appDispatch((0,
|
|
6954
|
+
appDispatch((0, import_store12.setSelectedRowKeys)(filteredKeys));
|
|
6888
6955
|
}
|
|
6889
6956
|
toggleShowGroup();
|
|
6890
6957
|
};
|
|
6891
|
-
(0,
|
|
6958
|
+
(0, import_react24.useEffect)(() => {
|
|
6892
6959
|
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6893
6960
|
return;
|
|
6894
6961
|
}
|
|
6895
6962
|
const clonedKeys = [...selectedRowKeys];
|
|
6896
|
-
(0,
|
|
6897
|
-
setTimeout(() => (0,
|
|
6963
|
+
(0, import_store12.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
6964
|
+
setTimeout(() => (0, import_store12.setSelectedRowKeys)(clonedKeys), 500);
|
|
6898
6965
|
}, [isQueryFetched]);
|
|
6899
6966
|
return {
|
|
6900
6967
|
handleExpandChildGroup,
|
|
@@ -6929,26 +6996,25 @@ var tableGroupController = (props) => {
|
|
|
6929
6996
|
|
|
6930
6997
|
// src/widget/advance/search/controller.ts
|
|
6931
6998
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
6932
|
-
var
|
|
6999
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6933
7000
|
var import_moment2 = __toESM(require_moment());
|
|
6934
|
-
var
|
|
7001
|
+
var import_react25 = require("react");
|
|
6935
7002
|
var searchController = ({
|
|
6936
7003
|
viewData,
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
7004
|
+
actionData,
|
|
7005
|
+
fieldsList,
|
|
7006
|
+
contextSearch,
|
|
7007
|
+
setSearchMap,
|
|
7008
|
+
searchMap
|
|
6941
7009
|
}) => {
|
|
6942
|
-
const
|
|
6943
|
-
const [
|
|
6944
|
-
const [
|
|
6945
|
-
const [
|
|
6946
|
-
const [
|
|
6947
|
-
const [
|
|
6948
|
-
const
|
|
6949
|
-
const
|
|
6950
|
-
const contextSearch = { ...env.context, ...actionContext };
|
|
6951
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils14.evalJSONDomain)(domain, contextSearch) : [];
|
|
7010
|
+
const [filterBy, setFilterBy] = (0, import_react25.useState)(null);
|
|
7011
|
+
const [searchBy, setSearchBy] = (0, import_react25.useState)(null);
|
|
7012
|
+
const [groupBy, setGroupBy] = (0, import_react25.useState)(null);
|
|
7013
|
+
const [selectedTags, setSelectedTags] = (0, import_react25.useState)(null);
|
|
7014
|
+
const [searchString, setSearchString] = (0, import_react25.useState)("");
|
|
7015
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils15.evalJSONDomain)(actionData?.domain, contextSearch) : [];
|
|
7016
|
+
const aid = actionData?.id;
|
|
7017
|
+
const model = actionData?.res_model;
|
|
6952
7018
|
const clearSearch = () => {
|
|
6953
7019
|
setFilterBy([]);
|
|
6954
7020
|
setGroupBy([]);
|
|
@@ -6963,7 +7029,7 @@ var searchController = ({
|
|
|
6963
7029
|
const dataModel = viewData?.models?.[model];
|
|
6964
7030
|
const searchViews = viewData?.views?.search;
|
|
6965
7031
|
const searchByItems = searchViews?.search_by?.filter(
|
|
6966
|
-
(item) => !
|
|
7032
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
6967
7033
|
)?.map(
|
|
6968
7034
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
6969
7035
|
dataIndex: index,
|
|
@@ -6976,10 +7042,10 @@ var searchController = ({
|
|
|
6976
7042
|
})
|
|
6977
7043
|
);
|
|
6978
7044
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
6979
|
-
return !
|
|
7045
|
+
return !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
6980
7046
|
})?.map((item) => ({ ...item, active: false }));
|
|
6981
7047
|
const groupByItems = searchViews?.group_by.filter(
|
|
6982
|
-
(item) => !
|
|
7048
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
6983
7049
|
).map((item) => ({
|
|
6984
7050
|
...item,
|
|
6985
7051
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -6992,9 +7058,10 @@ var searchController = ({
|
|
|
6992
7058
|
}
|
|
6993
7059
|
}
|
|
6994
7060
|
};
|
|
6995
|
-
(0,
|
|
7061
|
+
(0, import_react25.useEffect)(() => {
|
|
7062
|
+
clearSearch();
|
|
6996
7063
|
fetchData();
|
|
6997
|
-
}, [model, viewData]);
|
|
7064
|
+
}, [aid, model, viewData]);
|
|
6998
7065
|
const onChangeSearchInput = (search_string) => {
|
|
6999
7066
|
setSearchString(search_string);
|
|
7000
7067
|
};
|
|
@@ -7031,50 +7098,50 @@ var searchController = ({
|
|
|
7031
7098
|
};
|
|
7032
7099
|
const formatDomain = () => {
|
|
7033
7100
|
if (domainAction) {
|
|
7034
|
-
const
|
|
7101
|
+
const domain = [];
|
|
7035
7102
|
if (domainAction?.length > 0) {
|
|
7036
7103
|
if (Object.keys(searchMap).length > 0) {
|
|
7037
|
-
|
|
7104
|
+
domain.push("&");
|
|
7038
7105
|
}
|
|
7039
7106
|
domainAction.forEach((domainItem) => {
|
|
7040
|
-
|
|
7107
|
+
domain.push(domainItem);
|
|
7041
7108
|
});
|
|
7042
7109
|
}
|
|
7043
7110
|
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
7044
7111
|
if (!key?.includes(import_constants5.SearchType.GROUP)) {
|
|
7045
7112
|
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
7046
|
-
|
|
7113
|
+
domain.push("&");
|
|
7047
7114
|
}
|
|
7048
7115
|
const valuesOfKey = searchMap[key];
|
|
7049
7116
|
valuesOfKey.forEach((value, index) => {
|
|
7050
7117
|
if (index < valuesOfKey.length - 1) {
|
|
7051
|
-
|
|
7118
|
+
domain.push("|");
|
|
7052
7119
|
}
|
|
7053
7120
|
if (value.domain) {
|
|
7054
|
-
|
|
7121
|
+
domain.push(...value.domain);
|
|
7055
7122
|
return;
|
|
7056
7123
|
}
|
|
7057
7124
|
let valueDomainItem = value?.value;
|
|
7058
7125
|
if (value?.modelType === "date") {
|
|
7059
|
-
valueDomainItem = (0,
|
|
7126
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value);
|
|
7060
7127
|
} else if (value?.modelType === "datetime") {
|
|
7061
7128
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7062
|
-
const parsedDate = (0,
|
|
7129
|
+
const parsedDate = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7063
7130
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7064
7131
|
valueDomainItem = hasTime ? (0, import_moment2.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment2.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
7065
7132
|
} else {
|
|
7066
|
-
valueDomainItem = (0,
|
|
7133
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7067
7134
|
}
|
|
7068
7135
|
}
|
|
7069
7136
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
7070
|
-
|
|
7137
|
+
domain.push([value.name, operator, valueDomainItem]);
|
|
7071
7138
|
});
|
|
7072
7139
|
}
|
|
7073
7140
|
});
|
|
7074
|
-
return [...
|
|
7141
|
+
return [...domain];
|
|
7075
7142
|
}
|
|
7076
7143
|
};
|
|
7077
|
-
const setTagSearch = (0,
|
|
7144
|
+
const setTagSearch = (0, import_react25.useCallback)(
|
|
7078
7145
|
(updatedMap) => {
|
|
7079
7146
|
if (!updatedMap) return;
|
|
7080
7147
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7102,16 +7169,16 @@ var searchController = ({
|
|
|
7102
7169
|
const contexts = [];
|
|
7103
7170
|
let groupValues = [];
|
|
7104
7171
|
objValues?.forEach((objValue) => {
|
|
7105
|
-
const { context
|
|
7172
|
+
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7106
7173
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
7107
7174
|
contexts.push(
|
|
7108
|
-
...Array.isArray(
|
|
7175
|
+
...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({ group_by: item })) : [context]
|
|
7109
7176
|
);
|
|
7110
7177
|
groupValues[indexAppend] = {
|
|
7111
7178
|
contexts: [
|
|
7112
|
-
...Array.isArray(
|
|
7179
|
+
...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({
|
|
7113
7180
|
group_by: item
|
|
7114
|
-
})) : [
|
|
7181
|
+
})) : [context]
|
|
7115
7182
|
],
|
|
7116
7183
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
7117
7184
|
};
|
|
@@ -7137,40 +7204,40 @@ var searchController = ({
|
|
|
7137
7204
|
},
|
|
7138
7205
|
[searchMap]
|
|
7139
7206
|
);
|
|
7140
|
-
(0,
|
|
7207
|
+
(0, import_react25.useEffect)(() => {
|
|
7141
7208
|
setSelectedTags(null);
|
|
7142
7209
|
setTagSearch(searchMap);
|
|
7143
7210
|
}, [searchMap]);
|
|
7144
7211
|
const handleAddTagSearch = (tag) => {
|
|
7145
7212
|
const {
|
|
7146
|
-
domain
|
|
7213
|
+
domain,
|
|
7147
7214
|
groupIndex,
|
|
7148
7215
|
value,
|
|
7149
7216
|
type,
|
|
7150
7217
|
title,
|
|
7151
|
-
context
|
|
7218
|
+
context,
|
|
7152
7219
|
active,
|
|
7153
7220
|
dataIndex
|
|
7154
7221
|
} = tag;
|
|
7155
|
-
const domainFormat = new
|
|
7222
|
+
const domainFormat = new import_utils15.domainHelper.Domain(domain);
|
|
7156
7223
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7157
7224
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7158
7225
|
...tag,
|
|
7159
|
-
domain:
|
|
7226
|
+
domain: domain ? domainFormat.toList(context) : null
|
|
7160
7227
|
});
|
|
7161
7228
|
} else if (type === import_constants5.SearchType.SEARCH) {
|
|
7162
7229
|
addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
7163
7230
|
...tag,
|
|
7164
|
-
domain:
|
|
7165
|
-
...
|
|
7231
|
+
domain: domain ? domainFormat.toList({
|
|
7232
|
+
...context,
|
|
7166
7233
|
self: value
|
|
7167
7234
|
}) : null
|
|
7168
7235
|
});
|
|
7169
7236
|
} else if (type === import_constants5.SearchType.GROUP) {
|
|
7170
7237
|
addSearchItems(`${import_constants5.SearchType.GROUP}`, {
|
|
7171
7238
|
...tag,
|
|
7172
|
-
domain:
|
|
7173
|
-
context
|
|
7239
|
+
domain: domain ? domainFormat.toList({
|
|
7240
|
+
context,
|
|
7174
7241
|
self: value
|
|
7175
7242
|
}) : null
|
|
7176
7243
|
});
|
|
@@ -7190,8 +7257,7 @@ var searchController = ({
|
|
|
7190
7257
|
removeSearchItems,
|
|
7191
7258
|
onSearchString: onChangeSearchInput,
|
|
7192
7259
|
handleAddTagSearch,
|
|
7193
|
-
domain: formatDomain()
|
|
7194
|
-
context: contextSearch
|
|
7260
|
+
domain: formatDomain()
|
|
7195
7261
|
};
|
|
7196
7262
|
};
|
|
7197
7263
|
// Annotate the CommonJS export names for ESM import in node:
|