@fctc/widget-logic 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.mts +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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +256 -310
- package/dist/index.mjs +229 -292
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widget.d.mts +46 -34
- package/dist/widget.d.ts +46 -34
- package/dist/widget.js +246 -302
- package/dist/widget.mjs +223 -287
- package/package.json +2 -2
package/dist/widget.js
CHANGED
|
@@ -4049,7 +4049,6 @@ __export(widget_exports, {
|
|
|
4049
4049
|
priorityFieldController: () => priorityFieldController,
|
|
4050
4050
|
searchController: () => searchController,
|
|
4051
4051
|
statusDropdownController: () => statusDropdownController,
|
|
4052
|
-
tableBodyController: () => tableBodyController,
|
|
4053
4052
|
tableController: () => tableController,
|
|
4054
4053
|
tableGroupController: () => tableGroupController,
|
|
4055
4054
|
tableHeadController: () => tableHeadController
|
|
@@ -4111,7 +4110,7 @@ var statusDropdownController = (props) => {
|
|
|
4111
4110
|
};
|
|
4112
4111
|
|
|
4113
4112
|
// src/widget/basic/many2one-field/controller.ts
|
|
4114
|
-
var
|
|
4113
|
+
var import_react15 = require("react");
|
|
4115
4114
|
|
|
4116
4115
|
// src/hooks.ts
|
|
4117
4116
|
var hooks_exports = {};
|
|
@@ -4126,6 +4125,7 @@ __export(hooks_exports, {
|
|
|
4126
4125
|
useDetail: () => useDetail,
|
|
4127
4126
|
useListData: () => useListData,
|
|
4128
4127
|
useMenu: () => useMenu,
|
|
4128
|
+
useMenuItem: () => useMenuItem,
|
|
4129
4129
|
useProfile: () => useProfile,
|
|
4130
4130
|
useUser: () => useUser,
|
|
4131
4131
|
useViewV2: () => useViewV2
|
|
@@ -4885,8 +4885,69 @@ var useAppProvider = () => {
|
|
|
4885
4885
|
return context;
|
|
4886
4886
|
};
|
|
4887
4887
|
|
|
4888
|
-
// src/hooks/
|
|
4888
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4889
|
+
var import_environment6 = require("@fctc/interface-logic/environment");
|
|
4890
|
+
var import_hooks10 = require("@fctc/interface-logic/hooks");
|
|
4889
4891
|
var import_react12 = require("react");
|
|
4892
|
+
|
|
4893
|
+
// src/utils.ts
|
|
4894
|
+
var utils_exports = {};
|
|
4895
|
+
__export(utils_exports, {
|
|
4896
|
+
API_APP_URL: () => API_APP_URL,
|
|
4897
|
+
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
4898
|
+
STORAGES: () => STORAGES,
|
|
4899
|
+
combineContexts: () => combineContexts,
|
|
4900
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
4901
|
+
countSum: () => countSum,
|
|
4902
|
+
getDateRange: () => getDateRange,
|
|
4903
|
+
languages: () => languages,
|
|
4904
|
+
mergeButtons: () => mergeButtons,
|
|
4905
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
4906
|
+
useGetRowIds: () => useGetRowIds,
|
|
4907
|
+
useSelectionState: () => useSelectionState,
|
|
4908
|
+
useStorageState: () => useStorageState
|
|
4909
|
+
});
|
|
4910
|
+
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4911
|
+
|
|
4912
|
+
// src/hooks/core/use-menu-item.tsx
|
|
4913
|
+
var useMenuItem = (props) => {
|
|
4914
|
+
const { menu, activeMenuId } = props;
|
|
4915
|
+
const model = menu?.action?.res_model;
|
|
4916
|
+
const aid = menu?.action?.id?.id;
|
|
4917
|
+
const id = menu?.id;
|
|
4918
|
+
const context = (0, import_environment6.getEnv)().context;
|
|
4919
|
+
const queryActionDetail = (0, import_hooks10.useGetActionDetail)({
|
|
4920
|
+
aid,
|
|
4921
|
+
id,
|
|
4922
|
+
model,
|
|
4923
|
+
context,
|
|
4924
|
+
enabled: true,
|
|
4925
|
+
queryKey: [`action-${aid}`]
|
|
4926
|
+
}).data;
|
|
4927
|
+
const [path, setPath] = (0, import_react12.useState)("");
|
|
4928
|
+
const handleClick = () => {
|
|
4929
|
+
if (location?.pathname === "/list/menu" && activeMenuId === menu?.id) {
|
|
4930
|
+
return;
|
|
4931
|
+
}
|
|
4932
|
+
const hasListView = queryActionDetail.views.some(
|
|
4933
|
+
([id2, type]) => type === "list"
|
|
4934
|
+
);
|
|
4935
|
+
const viewType = hasListView ? "list" : "form";
|
|
4936
|
+
const isAccountPayment = menu?.action?.res_model === "account.payment" && menu?.action?.id?.id === 1551;
|
|
4937
|
+
const isConvertCurrencyMenu = menu?.action?.res_model === "currency.convert" && menu?.action?.id?.id === 1562;
|
|
4938
|
+
const path2 = (0, utils_exports.formatUrlPath)({
|
|
4939
|
+
viewType,
|
|
4940
|
+
actionPath: isConvertCurrencyMenu ? "menu" : isAccountPayment ? "menu" : menu?.action?.path || "menu",
|
|
4941
|
+
aid: menu?.action?.id?.id,
|
|
4942
|
+
model: queryActionDetail.res_model
|
|
4943
|
+
});
|
|
4944
|
+
setPath(path2);
|
|
4945
|
+
};
|
|
4946
|
+
return { handleClick, path, queryActionDetail };
|
|
4947
|
+
};
|
|
4948
|
+
|
|
4949
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4950
|
+
var import_react13 = require("react");
|
|
4890
4951
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4891
4952
|
var useClickOutside = ({
|
|
4892
4953
|
handler,
|
|
@@ -4894,8 +4955,8 @@ var useClickOutside = ({
|
|
|
4894
4955
|
nodes = [],
|
|
4895
4956
|
refs
|
|
4896
4957
|
}) => {
|
|
4897
|
-
const ref = (0,
|
|
4898
|
-
(0,
|
|
4958
|
+
const ref = (0, import_react13.useRef)(null);
|
|
4959
|
+
(0, import_react13.useEffect)(() => {
|
|
4899
4960
|
const listener = (event) => {
|
|
4900
4961
|
const { target } = event;
|
|
4901
4962
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4917,10 +4978,10 @@ var useClickOutside = ({
|
|
|
4917
4978
|
};
|
|
4918
4979
|
|
|
4919
4980
|
// src/hooks/utils/use-debounce.ts
|
|
4920
|
-
var
|
|
4981
|
+
var import_react14 = require("react");
|
|
4921
4982
|
function useDebounce(value, delay) {
|
|
4922
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4923
|
-
(0,
|
|
4983
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
|
|
4984
|
+
(0, import_react14.useEffect)(() => {
|
|
4924
4985
|
const handler = setTimeout(() => {
|
|
4925
4986
|
setDebouncedValue(value);
|
|
4926
4987
|
}, delay);
|
|
@@ -4934,25 +4995,6 @@ function useDebounce(value, delay) {
|
|
|
4934
4995
|
// src/hooks.ts
|
|
4935
4996
|
__reExport(hooks_exports, require("@fctc/interface-logic/hooks"));
|
|
4936
4997
|
|
|
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
4998
|
// src/provider.ts
|
|
4957
4999
|
var provider_exports = {};
|
|
4958
5000
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
@@ -4972,22 +5014,22 @@ var many2oneFieldController = (props) => {
|
|
|
4972
5014
|
options: fieldOptions,
|
|
4973
5015
|
showDetail
|
|
4974
5016
|
} = props;
|
|
4975
|
-
const
|
|
4976
|
-
const [
|
|
5017
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
5018
|
+
const [options, setOptions] = (0, import_react15.useState)([]);
|
|
5019
|
+
const [inputValue, setInputValue] = (0, import_react15.useState)("");
|
|
4977
5020
|
const [debouncedInputValue] = useDebounce(inputValue, 1e3);
|
|
4978
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
4979
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
4980
|
-
const [domainModal, setDomainModal] = (0,
|
|
4981
|
-
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);
|
|
4982
5025
|
const actionData = sessionStorageUtils.getActionData();
|
|
4983
5026
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
4984
|
-
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
4985
5027
|
const initValue = methods?.getValues(name);
|
|
4986
5028
|
const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
|
|
4987
5029
|
const contextObject = {
|
|
4988
5030
|
...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
|
|
4989
5031
|
...fieldContext,
|
|
4990
|
-
...context
|
|
5032
|
+
...env?.context
|
|
4991
5033
|
};
|
|
4992
5034
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
4993
5035
|
const data = {
|
|
@@ -5010,18 +5052,18 @@ var many2oneFieldController = (props) => {
|
|
|
5010
5052
|
queryKey,
|
|
5011
5053
|
enabled: false
|
|
5012
5054
|
});
|
|
5013
|
-
const selectOptions = (0,
|
|
5055
|
+
const selectOptions = (0, import_react15.useMemo)(() => {
|
|
5014
5056
|
return dataOfSelection?.records?.map((val) => ({
|
|
5015
5057
|
value: val?.id,
|
|
5016
5058
|
label: val?.display_name || val?.name
|
|
5017
5059
|
})) || [];
|
|
5018
5060
|
}, [dataOfSelection]);
|
|
5019
|
-
(0,
|
|
5061
|
+
(0, import_react15.useEffect)(() => {
|
|
5020
5062
|
setOptions(selectOptions);
|
|
5021
5063
|
setDomainModal(domainObject);
|
|
5022
5064
|
if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
|
|
5023
5065
|
}, [selectOptions]);
|
|
5024
|
-
(0,
|
|
5066
|
+
(0, import_react15.useEffect)(() => {
|
|
5025
5067
|
setDomainObject(
|
|
5026
5068
|
(0, utils_exports.evalJSONDomain)(
|
|
5027
5069
|
domain,
|
|
@@ -5029,7 +5071,7 @@ var many2oneFieldController = (props) => {
|
|
|
5029
5071
|
)
|
|
5030
5072
|
);
|
|
5031
5073
|
}, [domain, formValues]);
|
|
5032
|
-
(0,
|
|
5074
|
+
(0, import_react15.useEffect)(() => {
|
|
5033
5075
|
if (!propValue && tempSelectedOption) {
|
|
5034
5076
|
methods.setValue(name, null);
|
|
5035
5077
|
setTempSelectedOption(null);
|
|
@@ -5040,10 +5082,10 @@ var many2oneFieldController = (props) => {
|
|
|
5040
5082
|
});
|
|
5041
5083
|
}
|
|
5042
5084
|
}, [propValue]);
|
|
5043
|
-
const fetchMoreOptions = (0,
|
|
5085
|
+
const fetchMoreOptions = (0, import_react15.useCallback)(() => {
|
|
5044
5086
|
refetch();
|
|
5045
5087
|
}, [refetch]);
|
|
5046
|
-
(0,
|
|
5088
|
+
(0, import_react15.useEffect)(() => {
|
|
5047
5089
|
if (debouncedInputValue) {
|
|
5048
5090
|
const filteredDomain = [...domainObject ?? []]?.filter(
|
|
5049
5091
|
(d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
|
|
@@ -5058,7 +5100,7 @@ var many2oneFieldController = (props) => {
|
|
|
5058
5100
|
}, 50);
|
|
5059
5101
|
}
|
|
5060
5102
|
}, [debouncedInputValue]);
|
|
5061
|
-
const handleChooseRecord = (0,
|
|
5103
|
+
const handleChooseRecord = (0, import_react15.useCallback)(
|
|
5062
5104
|
(idRecord) => {
|
|
5063
5105
|
const newOption = options.find(
|
|
5064
5106
|
(option) => option.value === idRecord
|
|
@@ -5083,8 +5125,8 @@ var many2oneFieldController = (props) => {
|
|
|
5083
5125
|
},
|
|
5084
5126
|
[options, methods, name, onChange]
|
|
5085
5127
|
);
|
|
5086
|
-
const handleClose = (0,
|
|
5087
|
-
const handleSelectChange = (0,
|
|
5128
|
+
const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
5129
|
+
const handleSelectChange = (0, import_react15.useCallback)(
|
|
5088
5130
|
(selectedOption) => {
|
|
5089
5131
|
if (!selectedOption) {
|
|
5090
5132
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -5131,20 +5173,20 @@ var many2oneFieldController = (props) => {
|
|
|
5131
5173
|
};
|
|
5132
5174
|
|
|
5133
5175
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5134
|
-
var
|
|
5135
|
-
var
|
|
5136
|
-
var
|
|
5176
|
+
var import_environment7 = require("@fctc/interface-logic/environment");
|
|
5177
|
+
var import_hooks13 = require("@fctc/interface-logic/hooks");
|
|
5178
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5137
5179
|
var many2oneButtonController = (props) => {
|
|
5138
5180
|
const { domain, methods, relation } = props;
|
|
5139
5181
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5140
|
-
const env = (0,
|
|
5141
|
-
const domainObject = (0,
|
|
5182
|
+
const env = (0, import_environment7.getEnv)();
|
|
5183
|
+
const domainObject = (0, import_utils6.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5142
5184
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5143
|
-
const { data: dataOfSelection } = (0,
|
|
5185
|
+
const { data: dataOfSelection } = (0, import_hooks13.useGetSelection)({
|
|
5144
5186
|
data: {
|
|
5145
5187
|
model: relation ?? "",
|
|
5146
5188
|
domain: domainObject,
|
|
5147
|
-
context: { ...env.context, ...(0,
|
|
5189
|
+
context: { ...env.context, ...(0, import_utils6.evalJSONContext)(actionData?.context) }
|
|
5148
5190
|
},
|
|
5149
5191
|
queryKey: [`data_${relation}`, domainObject]
|
|
5150
5192
|
});
|
|
@@ -5158,91 +5200,77 @@ var many2oneButtonController = (props) => {
|
|
|
5158
5200
|
};
|
|
5159
5201
|
|
|
5160
5202
|
// src/widget/basic/many2many-field/controller.ts
|
|
5161
|
-
var
|
|
5162
|
-
var
|
|
5163
|
-
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5203
|
+
var import_react16 = require("react");
|
|
5204
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5164
5205
|
var many2manyFieldController = (props) => {
|
|
5165
5206
|
const {
|
|
5166
5207
|
relation,
|
|
5167
5208
|
domain,
|
|
5168
5209
|
context,
|
|
5210
|
+
options,
|
|
5169
5211
|
tab,
|
|
5170
|
-
|
|
5171
|
-
aid,
|
|
5172
|
-
setSelectedRowKeys: setSelectedRowKeys4,
|
|
5173
|
-
fields,
|
|
5174
|
-
setFields,
|
|
5212
|
+
setSelectedRowKeys: setSelectedRowKeys3,
|
|
5175
5213
|
groupByDomain,
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
sessionStorageUtils
|
|
5214
|
+
enabled: enabledCallAPI,
|
|
5215
|
+
actionData
|
|
5179
5216
|
} = props;
|
|
5180
|
-
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
5181
|
-
const actionData = sessionStorageUtils.getActionData();
|
|
5182
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
5183
|
-
const [order, setOrder] = (0, import_react15.useState)();
|
|
5184
|
-
const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
|
|
5185
|
-
const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(domain);
|
|
5186
5217
|
const { env } = (0, provider_exports.useEnv)();
|
|
5187
5218
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5219
|
+
const [order, setOrder] = (0, import_react16.useState)();
|
|
5220
|
+
const [page, setPage] = (0, import_react16.useState)(0);
|
|
5221
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(null);
|
|
5222
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
5223
|
+
const contextObject = {
|
|
5224
|
+
...env.context,
|
|
5225
|
+
...context || {}
|
|
5226
|
+
};
|
|
5188
5227
|
const viewParams = {
|
|
5189
5228
|
model: relation,
|
|
5190
5229
|
views: [
|
|
5191
5230
|
[false, "list"],
|
|
5192
5231
|
[false, "search"]
|
|
5193
5232
|
],
|
|
5194
|
-
context
|
|
5233
|
+
context: contextObject
|
|
5195
5234
|
};
|
|
5196
|
-
const { data: viewResponse } = useGetView2(viewParams,
|
|
5197
|
-
const baseModel = (0,
|
|
5235
|
+
const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
|
|
5236
|
+
const baseModel = (0, import_react16.useMemo)(
|
|
5198
5237
|
() => ({
|
|
5199
5238
|
name: String(relation),
|
|
5200
5239
|
view: viewResponse || {},
|
|
5201
|
-
actContext:
|
|
5240
|
+
actContext: contextObject,
|
|
5202
5241
|
fields: [
|
|
5203
5242
|
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
5204
5243
|
...tab?.fields ? tab.fields : []
|
|
5205
5244
|
]
|
|
5206
5245
|
}),
|
|
5207
|
-
[
|
|
5246
|
+
[relation, viewResponse]
|
|
5208
5247
|
);
|
|
5209
5248
|
const initModel = (0, hooks_exports.useModel)();
|
|
5210
|
-
const modelInstance = (0,
|
|
5249
|
+
const modelInstance = (0, import_react16.useMemo)(() => {
|
|
5211
5250
|
if (viewResponse) {
|
|
5212
5251
|
return initModel.initModel(baseModel);
|
|
5213
5252
|
}
|
|
5214
5253
|
return null;
|
|
5215
5254
|
}, [baseModel, viewResponse]);
|
|
5216
|
-
const specification = (0,
|
|
5255
|
+
const specification = (0, import_react16.useMemo)(() => {
|
|
5217
5256
|
if (modelInstance) {
|
|
5218
5257
|
return modelInstance.getSpecification();
|
|
5219
5258
|
}
|
|
5220
5259
|
return null;
|
|
5221
5260
|
}, [modelInstance]);
|
|
5222
5261
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5223
|
-
const optionsObject = tab?.options ? (0,
|
|
5262
|
+
const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
|
|
5224
5263
|
const fetchData = async () => {
|
|
5225
5264
|
try {
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
5230
|
-
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
5231
|
-
...field
|
|
5232
|
-
}));
|
|
5233
|
-
if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
|
|
5234
|
-
setFields({
|
|
5235
|
-
...fields,
|
|
5236
|
-
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
5237
|
-
});
|
|
5238
|
-
}
|
|
5239
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5265
|
+
const domainParse = typeof domain === "string" ? (0, import_utils7.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5266
|
+
setDomainMany2Many(domainParse);
|
|
5267
|
+
setPage(0);
|
|
5240
5268
|
} catch (err) {
|
|
5241
5269
|
console.log(err);
|
|
5242
5270
|
}
|
|
5243
5271
|
};
|
|
5244
5272
|
const queryKey = [
|
|
5245
|
-
`view-${relation}
|
|
5273
|
+
`view-${relation}`,
|
|
5246
5274
|
specification,
|
|
5247
5275
|
domainMany2Many,
|
|
5248
5276
|
debouncedPage,
|
|
@@ -5255,91 +5283,74 @@ var many2manyFieldController = (props) => {
|
|
|
5255
5283
|
domain: domainMany2Many,
|
|
5256
5284
|
offset: debouncedPage * 10,
|
|
5257
5285
|
limit: 10,
|
|
5258
|
-
context,
|
|
5286
|
+
context: contextObject,
|
|
5259
5287
|
fields: groupByDomain?.fields,
|
|
5260
5288
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5261
|
-
sort: order ? order : default_order ? (0,
|
|
5289
|
+
sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
|
|
5262
5290
|
};
|
|
5263
|
-
const enabled =
|
|
5291
|
+
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5264
5292
|
const {
|
|
5265
5293
|
data: dataResponse,
|
|
5266
|
-
isLoading
|
|
5267
|
-
isFetched
|
|
5294
|
+
isLoading,
|
|
5295
|
+
isFetched,
|
|
5268
5296
|
isPlaceholderData
|
|
5269
5297
|
} = useGetListData3(data, queryKey, enabled);
|
|
5270
|
-
(0,
|
|
5298
|
+
(0, import_react16.useEffect)(() => {
|
|
5271
5299
|
if (viewResponse) {
|
|
5272
5300
|
fetchData();
|
|
5273
5301
|
}
|
|
5274
5302
|
return () => {
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
...prevFields,
|
|
5278
|
-
[`${aid}_${relation}_popupmany2many`]: null
|
|
5279
|
-
}));
|
|
5280
|
-
appDispatch((0, import_store8.setPage)(0));
|
|
5281
|
-
setSelectedRowKeys4([]);
|
|
5303
|
+
setPage(0);
|
|
5304
|
+
setSelectedRowKeys3([]);
|
|
5282
5305
|
setDomainMany2Many(null);
|
|
5283
|
-
setIsLoadedData(false);
|
|
5284
5306
|
};
|
|
5285
5307
|
}, [viewResponse]);
|
|
5286
|
-
const { rows, columns, typeTable } = tableController({
|
|
5308
|
+
const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
|
|
5287
5309
|
data: {
|
|
5288
|
-
fields:
|
|
5310
|
+
fields: viewResponse?.views?.list?.fields,
|
|
5289
5311
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
5290
5312
|
dataModel: viewResponse?.models?.[String(relation)],
|
|
5291
|
-
context:
|
|
5313
|
+
context: contextObject,
|
|
5292
5314
|
typeTable: dataResponse?.groups ? "group" : "list"
|
|
5293
5315
|
}
|
|
5294
5316
|
});
|
|
5295
|
-
const
|
|
5296
|
-
|
|
5297
|
-
model: relation,
|
|
5298
|
-
context
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
data: dataFormView,
|
|
5306
|
-
queryKey: [`form-view-action-${relation}`],
|
|
5307
|
-
enabled: false
|
|
5317
|
+
const searchControllers = searchController({
|
|
5318
|
+
viewData: viewResponse,
|
|
5319
|
+
model: relation ?? "",
|
|
5320
|
+
context: contextObject,
|
|
5321
|
+
domain,
|
|
5322
|
+
fieldsList: [
|
|
5323
|
+
...columns?.filter(
|
|
5324
|
+
(col) => col?.field?.type_co === "field" && col?.optional !== "hide"
|
|
5325
|
+
)?.map((col) => ({ ...col.field })) ?? []
|
|
5326
|
+
]
|
|
5308
5327
|
});
|
|
5309
|
-
(0, import_react15.useEffect)(() => {
|
|
5310
|
-
if (isSuccess && dataFormViewResponse) {
|
|
5311
|
-
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5312
|
-
window.location.href = `/form/menu?model=${relation}`;
|
|
5313
|
-
}
|
|
5314
|
-
}, [isSuccess]);
|
|
5315
|
-
(0, import_react15.useEffect)(() => {
|
|
5316
|
-
if (domainMany2Many && !isLoadedData) {
|
|
5317
|
-
setIsLoadedData(true);
|
|
5318
|
-
}
|
|
5319
|
-
}, [domainMany2Many]);
|
|
5320
5328
|
const handleCreateNewOnPage = async () => {
|
|
5321
|
-
try {
|
|
5322
|
-
refetch();
|
|
5323
|
-
} catch (error) {
|
|
5324
|
-
console.log(error);
|
|
5325
|
-
}
|
|
5326
5329
|
};
|
|
5327
5330
|
return {
|
|
5328
5331
|
handleCreateNewOnPage,
|
|
5329
5332
|
optionsObject,
|
|
5333
|
+
totalRows: dataResponse?.length ?? 0,
|
|
5330
5334
|
rows,
|
|
5331
5335
|
columns,
|
|
5336
|
+
onToggleColumnOptional,
|
|
5332
5337
|
typeTable,
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
isPlaceholderData
|
|
5338
|
+
isLoading,
|
|
5339
|
+
isFetched,
|
|
5340
|
+
isPlaceholderData,
|
|
5341
|
+
setPage,
|
|
5342
|
+
page,
|
|
5343
|
+
viewData: viewResponse,
|
|
5344
|
+
domain: domainMany2Many,
|
|
5345
|
+
setDomain: setDomainMany2Many,
|
|
5346
|
+
searchController: searchControllers
|
|
5336
5347
|
};
|
|
5337
5348
|
};
|
|
5338
5349
|
|
|
5339
5350
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5340
|
-
var
|
|
5351
|
+
var import_react17 = require("react");
|
|
5341
5352
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5342
|
-
var
|
|
5353
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5343
5354
|
var many2manyTagsController = (props) => {
|
|
5344
5355
|
const {
|
|
5345
5356
|
relation,
|
|
@@ -5352,9 +5363,9 @@ var many2manyTagsController = (props) => {
|
|
|
5352
5363
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5353
5364
|
const { env } = (0, provider_exports.useEnv)();
|
|
5354
5365
|
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5355
|
-
const addtionalFields = optionsFields ? (0,
|
|
5356
|
-
const domainObject = (0,
|
|
5357
|
-
() => (0,
|
|
5366
|
+
const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
|
|
5367
|
+
const domainObject = (0, import_react17.useMemo)(
|
|
5368
|
+
() => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5358
5369
|
[domain, formValues]
|
|
5359
5370
|
);
|
|
5360
5371
|
const data = {
|
|
@@ -5395,8 +5406,8 @@ var many2manyTagsController = (props) => {
|
|
|
5395
5406
|
};
|
|
5396
5407
|
|
|
5397
5408
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5398
|
-
var
|
|
5399
|
-
var
|
|
5409
|
+
var import_react18 = require("react");
|
|
5410
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5400
5411
|
var durationController = (props) => {
|
|
5401
5412
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5402
5413
|
const specification = {
|
|
@@ -5406,13 +5417,13 @@ var durationController = (props) => {
|
|
|
5406
5417
|
};
|
|
5407
5418
|
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5408
5419
|
const { env } = (0, provider_exports.useEnv)();
|
|
5409
|
-
const [disabled, setDisabled] = (0,
|
|
5410
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5420
|
+
const [disabled, setDisabled] = (0, import_react18.useState)(false);
|
|
5421
|
+
const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
|
|
5411
5422
|
const queryKey = [`data-status-duration`, specification];
|
|
5412
5423
|
const listDataProps = {
|
|
5413
5424
|
model: relation,
|
|
5414
5425
|
specification,
|
|
5415
|
-
domain: (0,
|
|
5426
|
+
domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5416
5427
|
limit: 10,
|
|
5417
5428
|
offset: 0,
|
|
5418
5429
|
fields: "",
|
|
@@ -5462,10 +5473,10 @@ var durationController = (props) => {
|
|
|
5462
5473
|
};
|
|
5463
5474
|
|
|
5464
5475
|
// src/widget/basic/priority-field/controller.ts
|
|
5465
|
-
var
|
|
5476
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5466
5477
|
var priorityFieldController = (props) => {
|
|
5467
5478
|
const { name, model, id, actionData, context, onChange } = props;
|
|
5468
|
-
const _context = { ...(0,
|
|
5479
|
+
const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
|
|
5469
5480
|
const contextObject = { ...context, ..._context };
|
|
5470
5481
|
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
5471
5482
|
const { mutateAsync: fetchSave } = useSave2();
|
|
@@ -5496,10 +5507,10 @@ var priorityFieldController = (props) => {
|
|
|
5496
5507
|
};
|
|
5497
5508
|
|
|
5498
5509
|
// src/widget/basic/download-file-field/controller.ts
|
|
5499
|
-
var
|
|
5510
|
+
var import_react19 = require("react");
|
|
5500
5511
|
var downloadFileController = () => {
|
|
5501
|
-
const inputId = (0,
|
|
5502
|
-
const [file, setFile] = (0,
|
|
5512
|
+
const inputId = (0, import_react19.useId)();
|
|
5513
|
+
const [file, setFile] = (0, import_react19.useState)(null);
|
|
5503
5514
|
const handleFileChange = (e) => {
|
|
5504
5515
|
setFile(e.target.files[0]);
|
|
5505
5516
|
};
|
|
@@ -6431,13 +6442,13 @@ var dateFieldController = (props) => {
|
|
|
6431
6442
|
};
|
|
6432
6443
|
|
|
6433
6444
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6434
|
-
var
|
|
6435
|
-
var
|
|
6445
|
+
var import_react20 = require("react");
|
|
6446
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6436
6447
|
var copyLinkButtonController = (props) => {
|
|
6437
6448
|
const { value, defaultValue } = props;
|
|
6438
|
-
const [isCopied, setIsCopied] = (0,
|
|
6449
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
6439
6450
|
const handleCopyToClipboard = async (value2) => {
|
|
6440
|
-
await (0,
|
|
6451
|
+
await (0, import_utils11.copyTextToClipboard)(value2);
|
|
6441
6452
|
setIsCopied(true);
|
|
6442
6453
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6443
6454
|
};
|
|
@@ -6450,12 +6461,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6450
6461
|
};
|
|
6451
6462
|
|
|
6452
6463
|
// src/widget/basic/color-field/color-controller.ts
|
|
6453
|
-
var
|
|
6464
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
6454
6465
|
var colorFieldController = (props) => {
|
|
6455
6466
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6456
6467
|
const { env } = (0, provider_exports.useEnv)();
|
|
6457
6468
|
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
6458
|
-
const _context = { ...(0,
|
|
6469
|
+
const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
|
|
6459
6470
|
const contextObject = { ...env.context, ..._context };
|
|
6460
6471
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6461
6472
|
const { mutate: onSave } = useSave2();
|
|
@@ -6483,16 +6494,16 @@ var colorFieldController = (props) => {
|
|
|
6483
6494
|
};
|
|
6484
6495
|
|
|
6485
6496
|
// src/widget/basic/binary-field/controller.ts
|
|
6486
|
-
var
|
|
6487
|
-
var
|
|
6497
|
+
var import_react21 = require("react");
|
|
6498
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6488
6499
|
var binaryFieldController = (props) => {
|
|
6489
6500
|
const { name, methods, readonly = false, value } = props;
|
|
6490
|
-
const inputId = (0,
|
|
6491
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
6492
|
-
const [initialImage, setInitialImage] = (0,
|
|
6493
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
6501
|
+
const inputId = (0, import_react21.useId)();
|
|
6502
|
+
const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
|
|
6503
|
+
const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
|
|
6504
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
|
|
6494
6505
|
const { setValue } = methods;
|
|
6495
|
-
const binaryRef = (0,
|
|
6506
|
+
const binaryRef = (0, import_react21.useRef)(null);
|
|
6496
6507
|
const convertUrlToBase64 = async (url) => {
|
|
6497
6508
|
try {
|
|
6498
6509
|
const response = await fetch(url);
|
|
@@ -6541,11 +6552,11 @@ var binaryFieldController = (props) => {
|
|
|
6541
6552
|
};
|
|
6542
6553
|
const checkIsImageLink = (url) => {
|
|
6543
6554
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6544
|
-
return imageExtensions.test(url) || (0,
|
|
6555
|
+
return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
|
|
6545
6556
|
};
|
|
6546
6557
|
const getImageBase64WithMimeType = (base64) => {
|
|
6547
6558
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6548
|
-
if ((0,
|
|
6559
|
+
if ((0, import_utils13.isBase64Image)(base64)) return base64;
|
|
6549
6560
|
let mimeType = null;
|
|
6550
6561
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6551
6562
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6554,14 +6565,14 @@ var binaryFieldController = (props) => {
|
|
|
6554
6565
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6555
6566
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6556
6567
|
};
|
|
6557
|
-
(0,
|
|
6568
|
+
(0, import_react21.useEffect)(() => {
|
|
6558
6569
|
return () => {
|
|
6559
6570
|
if (selectedImage) {
|
|
6560
6571
|
URL.revokeObjectURL(selectedImage);
|
|
6561
6572
|
}
|
|
6562
6573
|
};
|
|
6563
6574
|
}, [selectedImage]);
|
|
6564
|
-
(0,
|
|
6575
|
+
(0, import_react21.useEffect)(() => {
|
|
6565
6576
|
if (binaryRef.current) {
|
|
6566
6577
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6567
6578
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6580,102 +6591,36 @@ var binaryFieldController = (props) => {
|
|
|
6580
6591
|
};
|
|
6581
6592
|
};
|
|
6582
6593
|
|
|
6583
|
-
// src/widget/advance/table/table-body/controller.ts
|
|
6584
|
-
var import_store9 = require("@fctc/interface-logic/store");
|
|
6585
|
-
var import_react21 = require("react");
|
|
6586
|
-
var tableBodyController = (props) => {
|
|
6587
|
-
const {
|
|
6588
|
-
checkedAll,
|
|
6589
|
-
checkboxRef,
|
|
6590
|
-
setIsAutoSelect,
|
|
6591
|
-
row,
|
|
6592
|
-
isAutoSelect,
|
|
6593
|
-
selectedRowKeysRef,
|
|
6594
|
-
onClickRow
|
|
6595
|
-
} = props;
|
|
6596
|
-
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6597
|
-
const { selectedRowKeys } = (0, import_store9.useAppSelector)(import_store9.selectList);
|
|
6598
|
-
const checked = (0, import_react21.useMemo)(() => {
|
|
6599
|
-
if (!row?.id) return false;
|
|
6600
|
-
if (selectedRowKeys?.includes(row.id)) {
|
|
6601
|
-
return true;
|
|
6602
|
-
}
|
|
6603
|
-
return checkedAll;
|
|
6604
|
-
}, [row?.id, selectedRowKeys, checkedAll]);
|
|
6605
|
-
const handleCheckBoxSingle = (event) => {
|
|
6606
|
-
event.stopPropagation();
|
|
6607
|
-
if (checkedAll) {
|
|
6608
|
-
checkboxRef.current = "uncheck";
|
|
6609
|
-
setIsAutoSelect(true);
|
|
6610
|
-
return;
|
|
6611
|
-
}
|
|
6612
|
-
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6613
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6614
|
-
};
|
|
6615
|
-
const handleClickRow = (col, row2) => {
|
|
6616
|
-
onClickRow(col, row2);
|
|
6617
|
-
};
|
|
6618
|
-
(0, import_react21.useEffect)(() => {
|
|
6619
|
-
if (!row?.id) return;
|
|
6620
|
-
if (isAutoSelect) {
|
|
6621
|
-
if (checkboxRef?.current === "uncheck") {
|
|
6622
|
-
const filtered = selectedRowKeysRef.current.filter(
|
|
6623
|
-
(id) => id !== row.id
|
|
6624
|
-
);
|
|
6625
|
-
selectedRowKeysRef.current = filtered;
|
|
6626
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(filtered));
|
|
6627
|
-
} else {
|
|
6628
|
-
const unique = Array.from(
|
|
6629
|
-
/* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
|
|
6630
|
-
);
|
|
6631
|
-
selectedRowKeysRef.current = unique;
|
|
6632
|
-
appDispatch((0, import_store9.setSelectedRowKeys)(unique));
|
|
6633
|
-
}
|
|
6634
|
-
}
|
|
6635
|
-
}, [isAutoSelect]);
|
|
6636
|
-
(0, import_react21.useEffect)(() => {
|
|
6637
|
-
if (!checkedAll) {
|
|
6638
|
-
checkboxRef.current = "enabled";
|
|
6639
|
-
false;
|
|
6640
|
-
}
|
|
6641
|
-
}, [checkedAll]);
|
|
6642
|
-
return {
|
|
6643
|
-
handleCheckBoxSingle,
|
|
6644
|
-
checked,
|
|
6645
|
-
handleClickRow
|
|
6646
|
-
};
|
|
6647
|
-
};
|
|
6648
|
-
|
|
6649
6594
|
// src/widget/advance/table/table-head/controller.ts
|
|
6650
|
-
var
|
|
6595
|
+
var import_store8 = require("@fctc/interface-logic/store");
|
|
6651
6596
|
var tableHeadController = (props) => {
|
|
6652
6597
|
const { typeTable, rows, selectedRowKeysRef } = props;
|
|
6653
|
-
const appDispatch = (0,
|
|
6654
|
-
const { groupByDomain } = (0,
|
|
6598
|
+
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
6599
|
+
const { groupByDomain } = (0, import_store8.useAppSelector)(import_store8.selectSearch);
|
|
6655
6600
|
const handleCheckBoxAll = (event) => {
|
|
6656
6601
|
if (event?.target?.checked && typeTable === "list") {
|
|
6657
6602
|
const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
|
|
6658
|
-
appDispatch((0,
|
|
6603
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(allRowKeys));
|
|
6659
6604
|
} else if (event?.target?.checked && typeTable === "group") {
|
|
6660
6605
|
const rowsIDs = document.querySelectorAll("tr[data-row-id]");
|
|
6661
6606
|
const ids = Array.from(rowsIDs)?.map(
|
|
6662
6607
|
(row) => Number(row?.getAttribute("data-row-id"))
|
|
6663
6608
|
);
|
|
6664
6609
|
if (ids?.length > 0) {
|
|
6665
|
-
appDispatch((0,
|
|
6610
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(ids));
|
|
6666
6611
|
} else {
|
|
6667
6612
|
const sum = countSum(
|
|
6668
6613
|
rows,
|
|
6669
6614
|
typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
|
|
6670
6615
|
);
|
|
6671
6616
|
const keys = Array.from({ length: sum }, (_) => void 0);
|
|
6672
|
-
appDispatch((0,
|
|
6617
|
+
appDispatch((0, import_store8.setSelectedRowKeys)(keys));
|
|
6673
6618
|
}
|
|
6674
6619
|
if (selectedRowKeysRef) {
|
|
6675
6620
|
selectedRowKeysRef.current = [];
|
|
6676
6621
|
}
|
|
6677
6622
|
} else {
|
|
6678
|
-
appDispatch((0,
|
|
6623
|
+
appDispatch((0, import_store8.setSelectedRowKeys)([]));
|
|
6679
6624
|
}
|
|
6680
6625
|
};
|
|
6681
6626
|
return {
|
|
@@ -6685,8 +6630,8 @@ var tableHeadController = (props) => {
|
|
|
6685
6630
|
|
|
6686
6631
|
// src/widget/advance/table/table-view/controller.ts
|
|
6687
6632
|
var import_react22 = require("react");
|
|
6688
|
-
var
|
|
6689
|
-
var
|
|
6633
|
+
var import_store9 = require("@fctc/interface-logic/store");
|
|
6634
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6690
6635
|
var tableController = ({ data }) => {
|
|
6691
6636
|
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
6692
6637
|
const [columns, setColumns] = (0, import_react22.useState)([]);
|
|
@@ -6724,7 +6669,7 @@ var tableController = ({ data }) => {
|
|
|
6724
6669
|
let cols = [];
|
|
6725
6670
|
try {
|
|
6726
6671
|
cols = mergeFields?.filter((item) => {
|
|
6727
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6672
|
+
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);
|
|
6728
6673
|
})?.map((field) => {
|
|
6729
6674
|
return {
|
|
6730
6675
|
name: field?.name,
|
|
@@ -6764,8 +6709,8 @@ var tableController = ({ data }) => {
|
|
|
6764
6709
|
|
|
6765
6710
|
// src/widget/advance/table/table-group/controller.ts
|
|
6766
6711
|
var import_react23 = require("react");
|
|
6767
|
-
var
|
|
6768
|
-
var
|
|
6712
|
+
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
6713
|
+
var import_store10 = require("@fctc/interface-logic/store");
|
|
6769
6714
|
|
|
6770
6715
|
// src/environment.ts
|
|
6771
6716
|
var environment_exports = {};
|
|
@@ -6793,10 +6738,10 @@ var tableGroupController = (props) => {
|
|
|
6793
6738
|
selectedRowKeysRef
|
|
6794
6739
|
} = props;
|
|
6795
6740
|
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
6796
|
-
const { groupByDomain, selectedTags } = (0,
|
|
6797
|
-
const { selectedRowKeys } = (0,
|
|
6798
|
-
const appDispatch = (0,
|
|
6799
|
-
const { toDataJS } = (0,
|
|
6741
|
+
const { groupByDomain, selectedTags } = (0, import_store10.useAppSelector)(import_store10.selectSearch);
|
|
6742
|
+
const { selectedRowKeys } = (0, import_store10.useAppSelector)(import_store10.selectList);
|
|
6743
|
+
const appDispatch = (0, import_store10.useAppDispatch)();
|
|
6744
|
+
const { toDataJS } = (0, import_hooks15.useOdooDataTransform)();
|
|
6800
6745
|
const initVal = toDataJS(row, viewData, model);
|
|
6801
6746
|
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
6802
6747
|
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
@@ -6843,7 +6788,7 @@ var tableGroupController = (props) => {
|
|
|
6843
6788
|
isPlaceholderData,
|
|
6844
6789
|
isLoading,
|
|
6845
6790
|
isFetching
|
|
6846
|
-
} = (0,
|
|
6791
|
+
} = (0, import_hooks15.useGetListData)(listDataProps, queryKey, enabled);
|
|
6847
6792
|
const {
|
|
6848
6793
|
columns: columnsGroup,
|
|
6849
6794
|
rows: rowsGroup,
|
|
@@ -6881,14 +6826,14 @@ var tableGroupController = (props) => {
|
|
|
6881
6826
|
const filteredIds = selectedRowKeys.filter(
|
|
6882
6827
|
(id) => !ids.includes(id)
|
|
6883
6828
|
);
|
|
6884
|
-
appDispatch((0,
|
|
6829
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredIds));
|
|
6885
6830
|
} else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
|
|
6886
6831
|
const clonedKeys = [...selectedRowKeys];
|
|
6887
|
-
appDispatch((0,
|
|
6888
|
-
setTimeout(() => appDispatch((0,
|
|
6832
|
+
appDispatch((0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]));
|
|
6833
|
+
setTimeout(() => appDispatch((0, import_store10.setSelectedRowKeys)(clonedKeys)), 500);
|
|
6889
6834
|
} else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
|
|
6890
6835
|
const filteredKeys = selectedRowKeys.filter((id) => id > -1);
|
|
6891
|
-
appDispatch((0,
|
|
6836
|
+
appDispatch((0, import_store10.setSelectedRowKeys)(filteredKeys));
|
|
6892
6837
|
}
|
|
6893
6838
|
toggleShowGroup();
|
|
6894
6839
|
};
|
|
@@ -6897,8 +6842,8 @@ var tableGroupController = (props) => {
|
|
|
6897
6842
|
return;
|
|
6898
6843
|
}
|
|
6899
6844
|
const clonedKeys = [...selectedRowKeys];
|
|
6900
|
-
(0,
|
|
6901
|
-
setTimeout(() => (0,
|
|
6845
|
+
(0, import_store10.setSelectedRowKeys)([...clonedKeys, -1]);
|
|
6846
|
+
setTimeout(() => (0, import_store10.setSelectedRowKeys)(clonedKeys), 500);
|
|
6902
6847
|
}, [isQueryFetched]);
|
|
6903
6848
|
return {
|
|
6904
6849
|
handleExpandChildGroup,
|
|
@@ -6933,25 +6878,26 @@ var tableGroupController = (props) => {
|
|
|
6933
6878
|
|
|
6934
6879
|
// src/widget/advance/search/controller.ts
|
|
6935
6880
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
6936
|
-
var
|
|
6881
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6937
6882
|
var import_moment2 = __toESM(require_moment());
|
|
6938
6883
|
var import_react24 = require("react");
|
|
6939
6884
|
var searchController = ({
|
|
6940
6885
|
viewData,
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
searchMap
|
|
6886
|
+
model,
|
|
6887
|
+
domain,
|
|
6888
|
+
context,
|
|
6889
|
+
fieldsList
|
|
6946
6890
|
}) => {
|
|
6891
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
6947
6892
|
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
6948
6893
|
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
6949
6894
|
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
6950
6895
|
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
6951
6896
|
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
6952
|
-
const
|
|
6953
|
-
const
|
|
6954
|
-
const
|
|
6897
|
+
const [searchMap, setSearchMap] = (0, import_react24.useState)({});
|
|
6898
|
+
const actionContext = typeof context === "string" ? (0, import_utils15.evalJSONContext)(context) : context;
|
|
6899
|
+
const contextSearch = { ...env.context, ...actionContext };
|
|
6900
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils15.evalJSONDomain)(domain, contextSearch) : [];
|
|
6955
6901
|
const clearSearch = () => {
|
|
6956
6902
|
setFilterBy([]);
|
|
6957
6903
|
setGroupBy([]);
|
|
@@ -6966,7 +6912,7 @@ var searchController = ({
|
|
|
6966
6912
|
const dataModel = viewData?.models?.[model];
|
|
6967
6913
|
const searchViews = viewData?.views?.search;
|
|
6968
6914
|
const searchByItems = searchViews?.search_by?.filter(
|
|
6969
|
-
(item) => !
|
|
6915
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
6970
6916
|
)?.map(
|
|
6971
6917
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
6972
6918
|
dataIndex: index,
|
|
@@ -6979,10 +6925,10 @@ var searchController = ({
|
|
|
6979
6925
|
})
|
|
6980
6926
|
);
|
|
6981
6927
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
6982
|
-
return !
|
|
6928
|
+
return !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
6983
6929
|
})?.map((item) => ({ ...item, active: false }));
|
|
6984
6930
|
const groupByItems = searchViews?.group_by.filter(
|
|
6985
|
-
(item) => !
|
|
6931
|
+
(item) => !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
6986
6932
|
).map((item) => ({
|
|
6987
6933
|
...item,
|
|
6988
6934
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -6996,9 +6942,8 @@ var searchController = ({
|
|
|
6996
6942
|
}
|
|
6997
6943
|
};
|
|
6998
6944
|
(0, import_react24.useEffect)(() => {
|
|
6999
|
-
clearSearch();
|
|
7000
6945
|
fetchData();
|
|
7001
|
-
}, [
|
|
6946
|
+
}, [model, viewData]);
|
|
7002
6947
|
const onChangeSearchInput = (search_string) => {
|
|
7003
6948
|
setSearchString(search_string);
|
|
7004
6949
|
};
|
|
@@ -7035,47 +6980,47 @@ var searchController = ({
|
|
|
7035
6980
|
};
|
|
7036
6981
|
const formatDomain = () => {
|
|
7037
6982
|
if (domainAction) {
|
|
7038
|
-
const
|
|
6983
|
+
const domain2 = [];
|
|
7039
6984
|
if (domainAction?.length > 0) {
|
|
7040
|
-
if (Object.keys(searchMap).
|
|
7041
|
-
|
|
6985
|
+
if (Object.keys(searchMap).some((key) => !key.includes(import_constants5.SearchType.GROUP))) {
|
|
6986
|
+
domain2.push("&");
|
|
7042
6987
|
}
|
|
7043
6988
|
domainAction.forEach((domainItem) => {
|
|
7044
|
-
|
|
6989
|
+
domain2.push(domainItem);
|
|
7045
6990
|
});
|
|
7046
6991
|
}
|
|
7047
6992
|
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
7048
6993
|
if (!key?.includes(import_constants5.SearchType.GROUP)) {
|
|
7049
6994
|
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
7050
|
-
|
|
6995
|
+
domain2.push("&");
|
|
7051
6996
|
}
|
|
7052
6997
|
const valuesOfKey = searchMap[key];
|
|
7053
6998
|
valuesOfKey.forEach((value, index) => {
|
|
7054
6999
|
if (index < valuesOfKey.length - 1) {
|
|
7055
|
-
|
|
7000
|
+
domain2.push("|");
|
|
7056
7001
|
}
|
|
7057
7002
|
if (value.domain) {
|
|
7058
|
-
|
|
7003
|
+
domain2.push(...value.domain);
|
|
7059
7004
|
return;
|
|
7060
7005
|
}
|
|
7061
7006
|
let valueDomainItem = value?.value;
|
|
7062
7007
|
if (value?.modelType === "date") {
|
|
7063
|
-
valueDomainItem = (0,
|
|
7008
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value);
|
|
7064
7009
|
} else if (value?.modelType === "datetime") {
|
|
7065
7010
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7066
|
-
const parsedDate = (0,
|
|
7011
|
+
const parsedDate = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7067
7012
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7068
7013
|
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");
|
|
7069
7014
|
} else {
|
|
7070
|
-
valueDomainItem = (0,
|
|
7015
|
+
valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value, true);
|
|
7071
7016
|
}
|
|
7072
7017
|
}
|
|
7073
7018
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
7074
|
-
|
|
7019
|
+
domain2.push([value.name, operator, valueDomainItem]);
|
|
7075
7020
|
});
|
|
7076
7021
|
}
|
|
7077
7022
|
});
|
|
7078
|
-
return [...
|
|
7023
|
+
return [...domain2];
|
|
7079
7024
|
}
|
|
7080
7025
|
};
|
|
7081
7026
|
const setTagSearch = (0, import_react24.useCallback)(
|
|
@@ -7106,16 +7051,16 @@ var searchController = ({
|
|
|
7106
7051
|
const contexts = [];
|
|
7107
7052
|
let groupValues = [];
|
|
7108
7053
|
objValues?.forEach((objValue) => {
|
|
7109
|
-
const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7054
|
+
const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
|
|
7110
7055
|
const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
|
|
7111
7056
|
contexts.push(
|
|
7112
|
-
...Array.isArray(
|
|
7057
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
|
|
7113
7058
|
);
|
|
7114
7059
|
groupValues[indexAppend] = {
|
|
7115
7060
|
contexts: [
|
|
7116
|
-
...Array.isArray(
|
|
7061
|
+
...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
|
|
7117
7062
|
group_by: item
|
|
7118
|
-
})) : [
|
|
7063
|
+
})) : [context2]
|
|
7119
7064
|
],
|
|
7120
7065
|
strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
|
|
7121
7066
|
};
|
|
@@ -7142,39 +7087,38 @@ var searchController = ({
|
|
|
7142
7087
|
[searchMap]
|
|
7143
7088
|
);
|
|
7144
7089
|
(0, import_react24.useEffect)(() => {
|
|
7145
|
-
setSelectedTags(null);
|
|
7146
7090
|
setTagSearch(searchMap);
|
|
7147
7091
|
}, [searchMap]);
|
|
7148
7092
|
const handleAddTagSearch = (tag) => {
|
|
7149
7093
|
const {
|
|
7150
|
-
domain,
|
|
7094
|
+
domain: domain2,
|
|
7151
7095
|
groupIndex,
|
|
7152
7096
|
value,
|
|
7153
7097
|
type,
|
|
7154
7098
|
title,
|
|
7155
|
-
context,
|
|
7099
|
+
context: context2,
|
|
7156
7100
|
active,
|
|
7157
7101
|
dataIndex
|
|
7158
7102
|
} = tag;
|
|
7159
|
-
const domainFormat = new
|
|
7103
|
+
const domainFormat = new import_utils15.domainHelper.Domain(domain2);
|
|
7160
7104
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7161
7105
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7162
7106
|
...tag,
|
|
7163
|
-
domain:
|
|
7107
|
+
domain: domain2 ? domainFormat.toList(context2) : null
|
|
7164
7108
|
});
|
|
7165
7109
|
} else if (type === import_constants5.SearchType.SEARCH) {
|
|
7166
7110
|
addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
|
|
7167
7111
|
...tag,
|
|
7168
|
-
domain:
|
|
7169
|
-
...
|
|
7112
|
+
domain: domain2 ? domainFormat.toList({
|
|
7113
|
+
...context2,
|
|
7170
7114
|
self: value
|
|
7171
7115
|
}) : null
|
|
7172
7116
|
});
|
|
7173
7117
|
} else if (type === import_constants5.SearchType.GROUP) {
|
|
7174
7118
|
addSearchItems(`${import_constants5.SearchType.GROUP}`, {
|
|
7175
7119
|
...tag,
|
|
7176
|
-
domain:
|
|
7177
|
-
context,
|
|
7120
|
+
domain: domain2 ? domainFormat.toList({
|
|
7121
|
+
context: context2,
|
|
7178
7122
|
self: value
|
|
7179
7123
|
}) : null
|
|
7180
7124
|
});
|
|
@@ -7194,7 +7138,8 @@ var searchController = ({
|
|
|
7194
7138
|
removeSearchItems,
|
|
7195
7139
|
onSearchString: onChangeSearchInput,
|
|
7196
7140
|
handleAddTagSearch,
|
|
7197
|
-
domain: formatDomain()
|
|
7141
|
+
domain: formatDomain(),
|
|
7142
|
+
context: contextSearch
|
|
7198
7143
|
};
|
|
7199
7144
|
};
|
|
7200
7145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -7213,7 +7158,6 @@ var searchController = ({
|
|
|
7213
7158
|
priorityFieldController,
|
|
7214
7159
|
searchController,
|
|
7215
7160
|
statusDropdownController,
|
|
7216
|
-
tableBodyController,
|
|
7217
7161
|
tableController,
|
|
7218
7162
|
tableGroupController,
|
|
7219
7163
|
tableHeadController
|