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