@fctc/widget-logic 2.0.4 → 2.0.8
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 +161 -226
- package/dist/index.mjs +95 -155
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widget.d.mts +2 -13
- package/dist/widget.d.ts +2 -13
- package/dist/widget.js +153 -216
- package/dist/widget.mjs +91 -149
- 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,13 +4972,13 @@ var many2oneFieldController = (props) => {
|
|
|
5015
4972
|
options: fieldOptions,
|
|
5016
4973
|
showDetail
|
|
5017
4974
|
} = props;
|
|
5018
|
-
const [options, setOptions] = (0,
|
|
5019
|
-
const [inputValue, setInputValue] = (0,
|
|
4975
|
+
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
4976
|
+
const [inputValue, setInputValue] = (0, import_react14.useState)("");
|
|
5020
4977
|
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,
|
|
4978
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react14.useState)(false);
|
|
4979
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react14.useState)(null);
|
|
4980
|
+
const [domainModal, setDomainModal] = (0, import_react14.useState)(null);
|
|
4981
|
+
const [domainObject, setDomainObject] = (0, import_react14.useState)(null);
|
|
5025
4982
|
const actionData = sessionStorageUtils.getActionData();
|
|
5026
4983
|
const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
|
|
5027
4984
|
const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
|
|
@@ -5032,7 +4989,7 @@ var many2oneFieldController = (props) => {
|
|
|
5032
4989
|
...fieldContext,
|
|
5033
4990
|
...context
|
|
5034
4991
|
};
|
|
5035
|
-
const { useGetSelection:
|
|
4992
|
+
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5036
4993
|
const data = {
|
|
5037
4994
|
model: relation,
|
|
5038
4995
|
domain: domainObject,
|
|
@@ -5048,23 +5005,23 @@ var many2oneFieldController = (props) => {
|
|
|
5048
5005
|
data: dataOfSelection,
|
|
5049
5006
|
refetch,
|
|
5050
5007
|
isFetching
|
|
5051
|
-
} =
|
|
5008
|
+
} = useGetSelection2({
|
|
5052
5009
|
data,
|
|
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,9 +5158,9 @@ var many2oneButtonController = (props) => {
|
|
|
5201
5158
|
};
|
|
5202
5159
|
|
|
5203
5160
|
// src/widget/basic/many2many-field/controller.ts
|
|
5204
|
-
var
|
|
5161
|
+
var import_react15 = require("react");
|
|
5205
5162
|
var import_store8 = require("@fctc/interface-logic/store");
|
|
5206
|
-
var
|
|
5163
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
5207
5164
|
var many2manyFieldController = (props) => {
|
|
5208
5165
|
const {
|
|
5209
5166
|
relation,
|
|
@@ -5223,9 +5180,9 @@ var many2manyFieldController = (props) => {
|
|
|
5223
5180
|
const appDispatch = (0, import_store8.useAppDispatch)();
|
|
5224
5181
|
const actionData = sessionStorageUtils.getActionData();
|
|
5225
5182
|
const [debouncedPage] = useDebounce(page, 500);
|
|
5226
|
-
const [order, setOrder] = (0,
|
|
5227
|
-
const [isLoadedData, setIsLoadedData] = (0,
|
|
5228
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
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);
|
|
5229
5186
|
const { env } = (0, provider_exports.useEnv)();
|
|
5230
5187
|
const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
|
|
5231
5188
|
const viewParams = {
|
|
@@ -5237,7 +5194,7 @@ var many2manyFieldController = (props) => {
|
|
|
5237
5194
|
context
|
|
5238
5195
|
};
|
|
5239
5196
|
const { data: viewResponse } = useGetView2(viewParams, actionData);
|
|
5240
|
-
const baseModel = (0,
|
|
5197
|
+
const baseModel = (0, import_react15.useMemo)(
|
|
5241
5198
|
() => ({
|
|
5242
5199
|
name: String(relation),
|
|
5243
5200
|
view: viewResponse || {},
|
|
@@ -5250,20 +5207,20 @@ var many2manyFieldController = (props) => {
|
|
|
5250
5207
|
[model, viewResponse]
|
|
5251
5208
|
);
|
|
5252
5209
|
const initModel = (0, hooks_exports.useModel)();
|
|
5253
|
-
const modelInstance = (0,
|
|
5210
|
+
const modelInstance = (0, import_react15.useMemo)(() => {
|
|
5254
5211
|
if (viewResponse) {
|
|
5255
5212
|
return initModel.initModel(baseModel);
|
|
5256
5213
|
}
|
|
5257
5214
|
return null;
|
|
5258
5215
|
}, [baseModel, viewResponse]);
|
|
5259
|
-
const specification = (0,
|
|
5216
|
+
const specification = (0, import_react15.useMemo)(() => {
|
|
5260
5217
|
if (modelInstance) {
|
|
5261
5218
|
return modelInstance.getSpecification();
|
|
5262
5219
|
}
|
|
5263
5220
|
return null;
|
|
5264
5221
|
}, [modelInstance]);
|
|
5265
5222
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5266
|
-
const optionsObject = tab?.options ? (0,
|
|
5223
|
+
const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
|
|
5267
5224
|
const fetchData = async () => {
|
|
5268
5225
|
try {
|
|
5269
5226
|
setDomainMany2Many(domain);
|
|
@@ -5301,7 +5258,7 @@ var many2manyFieldController = (props) => {
|
|
|
5301
5258
|
context,
|
|
5302
5259
|
fields: groupByDomain?.fields,
|
|
5303
5260
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5304
|
-
sort: order ? order : default_order ? (0,
|
|
5261
|
+
sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
|
|
5305
5262
|
};
|
|
5306
5263
|
const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5307
5264
|
const {
|
|
@@ -5310,7 +5267,7 @@ var many2manyFieldController = (props) => {
|
|
|
5310
5267
|
isFetched: isDataResponseFetched,
|
|
5311
5268
|
isPlaceholderData
|
|
5312
5269
|
} = useGetListData3(data, queryKey, enabled);
|
|
5313
|
-
(0,
|
|
5270
|
+
(0, import_react15.useEffect)(() => {
|
|
5314
5271
|
if (viewResponse) {
|
|
5315
5272
|
fetchData();
|
|
5316
5273
|
}
|
|
@@ -5349,13 +5306,13 @@ var many2manyFieldController = (props) => {
|
|
|
5349
5306
|
queryKey: [`form-view-action-${relation}`],
|
|
5350
5307
|
enabled: false
|
|
5351
5308
|
});
|
|
5352
|
-
(0,
|
|
5309
|
+
(0, import_react15.useEffect)(() => {
|
|
5353
5310
|
if (isSuccess && dataFormViewResponse) {
|
|
5354
5311
|
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
5355
5312
|
window.location.href = `/form/menu?model=${relation}`;
|
|
5356
5313
|
}
|
|
5357
5314
|
}, [isSuccess]);
|
|
5358
|
-
(0,
|
|
5315
|
+
(0, import_react15.useEffect)(() => {
|
|
5359
5316
|
if (domainMany2Many && !isLoadedData) {
|
|
5360
5317
|
setIsLoadedData(true);
|
|
5361
5318
|
}
|
|
@@ -5380,11 +5337,9 @@ var many2manyFieldController = (props) => {
|
|
|
5380
5337
|
};
|
|
5381
5338
|
|
|
5382
5339
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5383
|
-
var
|
|
5340
|
+
var import_react16 = require("react");
|
|
5384
5341
|
var import_constants4 = require("@fctc/interface-logic/constants");
|
|
5385
|
-
var
|
|
5386
|
-
var import_hooks15 = require("@fctc/interface-logic/hooks");
|
|
5387
|
-
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5342
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5388
5343
|
var many2manyTagsController = (props) => {
|
|
5389
5344
|
const {
|
|
5390
5345
|
relation,
|
|
@@ -5395,10 +5350,11 @@ var many2manyTagsController = (props) => {
|
|
|
5395
5350
|
placeholderNoOption
|
|
5396
5351
|
} = props;
|
|
5397
5352
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5398
|
-
const env = (0,
|
|
5399
|
-
const
|
|
5400
|
-
const
|
|
5401
|
-
|
|
5353
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
5354
|
+
const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
|
|
5355
|
+
const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
|
|
5356
|
+
const domainObject = (0, import_react16.useMemo)(
|
|
5357
|
+
() => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5402
5358
|
[domain, formValues]
|
|
5403
5359
|
);
|
|
5404
5360
|
const data = {
|
|
@@ -5414,7 +5370,7 @@ var many2manyTagsController = (props) => {
|
|
|
5414
5370
|
enabled: true,
|
|
5415
5371
|
context: env.context
|
|
5416
5372
|
};
|
|
5417
|
-
const { data: dataOfSelection } = (
|
|
5373
|
+
const { data: dataOfSelection } = useGetSelection2({
|
|
5418
5374
|
data,
|
|
5419
5375
|
queryKey: [`data_${relation}`, domainObject]
|
|
5420
5376
|
});
|
|
@@ -5434,16 +5390,15 @@ var many2manyTagsController = (props) => {
|
|
|
5434
5390
|
options,
|
|
5435
5391
|
customNoOptionsMessage,
|
|
5436
5392
|
tranfer,
|
|
5437
|
-
dataOfSelection,
|
|
5438
5393
|
isUser
|
|
5439
5394
|
};
|
|
5440
5395
|
};
|
|
5441
5396
|
|
|
5442
5397
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5443
|
-
var
|
|
5444
|
-
var
|
|
5398
|
+
var import_react17 = require("react");
|
|
5399
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5445
5400
|
var durationController = (props) => {
|
|
5446
|
-
const { relation, domain, formValues, name, id, model, onRefetch } = props;
|
|
5401
|
+
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5447
5402
|
const specification = {
|
|
5448
5403
|
id: 0,
|
|
5449
5404
|
name: "",
|
|
@@ -5451,13 +5406,13 @@ var durationController = (props) => {
|
|
|
5451
5406
|
};
|
|
5452
5407
|
const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
|
|
5453
5408
|
const { env } = (0, provider_exports.useEnv)();
|
|
5454
|
-
const [disabled, setDisabled] = (0,
|
|
5455
|
-
const [modelStatus, setModalStatus] = (0,
|
|
5409
|
+
const [disabled, setDisabled] = (0, import_react17.useState)(false);
|
|
5410
|
+
const [modelStatus, setModalStatus] = (0, import_react17.useState)(false);
|
|
5456
5411
|
const queryKey = [`data-status-duration`, specification];
|
|
5457
5412
|
const listDataProps = {
|
|
5458
5413
|
model: relation,
|
|
5459
5414
|
specification,
|
|
5460
|
-
domain: (0,
|
|
5415
|
+
domain: (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5461
5416
|
limit: 10,
|
|
5462
5417
|
offset: 0,
|
|
5463
5418
|
fields: "",
|
|
@@ -5467,7 +5422,11 @@ var durationController = (props) => {
|
|
|
5467
5422
|
},
|
|
5468
5423
|
sort: ""
|
|
5469
5424
|
};
|
|
5470
|
-
const { data: dataResponse } = useGetListData3(
|
|
5425
|
+
const { data: dataResponse } = useGetListData3(
|
|
5426
|
+
listDataProps,
|
|
5427
|
+
queryKey,
|
|
5428
|
+
enabled
|
|
5429
|
+
);
|
|
5471
5430
|
const { mutate: fetchChangeStatus } = useChangeStatus();
|
|
5472
5431
|
const handleClick = async (stage_id) => {
|
|
5473
5432
|
setDisabled(true);
|
|
@@ -5503,32 +5462,18 @@ var durationController = (props) => {
|
|
|
5503
5462
|
};
|
|
5504
5463
|
|
|
5505
5464
|
// src/widget/basic/priority-field/controller.ts
|
|
5506
|
-
var
|
|
5507
|
-
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5465
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5508
5466
|
var priorityFieldController = (props) => {
|
|
5509
|
-
const {
|
|
5510
|
-
|
|
5511
|
-
isForm,
|
|
5512
|
-
name,
|
|
5513
|
-
methods,
|
|
5514
|
-
onChange,
|
|
5515
|
-
model,
|
|
5516
|
-
selection,
|
|
5517
|
-
id,
|
|
5518
|
-
actionData,
|
|
5519
|
-
viewData,
|
|
5520
|
-
context
|
|
5521
|
-
} = props;
|
|
5522
|
-
const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
|
|
5467
|
+
const { name, model, id, actionData, context, onChange } = props;
|
|
5468
|
+
const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
|
|
5523
5469
|
const contextObject = { ...context, ..._context };
|
|
5524
|
-
const
|
|
5525
|
-
const
|
|
5526
|
-
const { mutateAsync: fetchSave } = (0, import_hooks16.useSave)();
|
|
5470
|
+
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
5471
|
+
const { mutateAsync: fetchSave } = useSave2();
|
|
5527
5472
|
const savePriorities = async ({
|
|
5528
|
-
value
|
|
5473
|
+
value,
|
|
5529
5474
|
resetPriority
|
|
5530
5475
|
}) => {
|
|
5531
|
-
const priorityValue =
|
|
5476
|
+
const priorityValue = value <= 0 ? 0 : value - 1;
|
|
5532
5477
|
try {
|
|
5533
5478
|
fetchSave({
|
|
5534
5479
|
ids: id ? [id] : [],
|
|
@@ -5546,22 +5491,15 @@ var priorityFieldController = (props) => {
|
|
|
5546
5491
|
}
|
|
5547
5492
|
};
|
|
5548
5493
|
return {
|
|
5549
|
-
|
|
5550
|
-
isForm,
|
|
5551
|
-
methods,
|
|
5552
|
-
defaultPriority,
|
|
5553
|
-
savePriorities,
|
|
5554
|
-
label,
|
|
5555
|
-
id,
|
|
5556
|
-
onChange
|
|
5494
|
+
savePriorities
|
|
5557
5495
|
};
|
|
5558
5496
|
};
|
|
5559
5497
|
|
|
5560
5498
|
// src/widget/basic/download-file-field/controller.ts
|
|
5561
|
-
var
|
|
5499
|
+
var import_react18 = require("react");
|
|
5562
5500
|
var downloadFileController = () => {
|
|
5563
|
-
const inputId = (0,
|
|
5564
|
-
const [file, setFile] = (0,
|
|
5501
|
+
const inputId = (0, import_react18.useId)();
|
|
5502
|
+
const [file, setFile] = (0, import_react18.useState)(null);
|
|
5565
5503
|
const handleFileChange = (e) => {
|
|
5566
5504
|
setFile(e.target.files[0]);
|
|
5567
5505
|
};
|
|
@@ -6493,13 +6431,13 @@ var dateFieldController = (props) => {
|
|
|
6493
6431
|
};
|
|
6494
6432
|
|
|
6495
6433
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6496
|
-
var
|
|
6497
|
-
var
|
|
6434
|
+
var import_react19 = require("react");
|
|
6435
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
6498
6436
|
var copyLinkButtonController = (props) => {
|
|
6499
6437
|
const { value, defaultValue } = props;
|
|
6500
|
-
const [isCopied, setIsCopied] = (0,
|
|
6438
|
+
const [isCopied, setIsCopied] = (0, import_react19.useState)(false);
|
|
6501
6439
|
const handleCopyToClipboard = async (value2) => {
|
|
6502
|
-
await (0,
|
|
6440
|
+
await (0, import_utils10.copyTextToClipboard)(value2);
|
|
6503
6441
|
setIsCopied(true);
|
|
6504
6442
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6505
6443
|
};
|
|
@@ -6512,15 +6450,15 @@ var copyLinkButtonController = (props) => {
|
|
|
6512
6450
|
};
|
|
6513
6451
|
|
|
6514
6452
|
// src/widget/basic/color-field/color-controller.ts
|
|
6515
|
-
var
|
|
6453
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
6516
6454
|
var colorFieldController = (props) => {
|
|
6517
6455
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6518
6456
|
const { env } = (0, provider_exports.useEnv)();
|
|
6519
|
-
const { useSave:
|
|
6520
|
-
const _context = { ...(0,
|
|
6457
|
+
const { useSave: useSave2 } = (0, provider_exports.useService)();
|
|
6458
|
+
const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) || {} };
|
|
6521
6459
|
const contextObject = { ...env.context, ..._context };
|
|
6522
6460
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6523
|
-
const { mutate: onSave } =
|
|
6461
|
+
const { mutate: onSave } = useSave2();
|
|
6524
6462
|
const savePickColor = async (colorObject) => {
|
|
6525
6463
|
const { id } = colorObject;
|
|
6526
6464
|
if (value === id) return;
|
|
@@ -6545,16 +6483,16 @@ var colorFieldController = (props) => {
|
|
|
6545
6483
|
};
|
|
6546
6484
|
|
|
6547
6485
|
// src/widget/basic/binary-field/controller.ts
|
|
6548
|
-
var
|
|
6549
|
-
var
|
|
6486
|
+
var import_react20 = require("react");
|
|
6487
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
6550
6488
|
var binaryFieldController = (props) => {
|
|
6551
6489
|
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,
|
|
6490
|
+
const inputId = (0, import_react20.useId)();
|
|
6491
|
+
const [selectedImage, setSelectedImage] = (0, import_react20.useState)(null);
|
|
6492
|
+
const [initialImage, setInitialImage] = (0, import_react20.useState)(value || null);
|
|
6493
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react20.useState)(false);
|
|
6556
6494
|
const { setValue } = methods;
|
|
6557
|
-
const binaryRef = (0,
|
|
6495
|
+
const binaryRef = (0, import_react20.useRef)(null);
|
|
6558
6496
|
const convertUrlToBase64 = async (url) => {
|
|
6559
6497
|
try {
|
|
6560
6498
|
const response = await fetch(url);
|
|
@@ -6603,11 +6541,11 @@ var binaryFieldController = (props) => {
|
|
|
6603
6541
|
};
|
|
6604
6542
|
const checkIsImageLink = (url) => {
|
|
6605
6543
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6606
|
-
return imageExtensions.test(url) || (0,
|
|
6544
|
+
return imageExtensions.test(url) || (0, import_utils12.isBase64Image)(url) || isBlobUrl(url);
|
|
6607
6545
|
};
|
|
6608
6546
|
const getImageBase64WithMimeType = (base64) => {
|
|
6609
6547
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6610
|
-
if ((0,
|
|
6548
|
+
if ((0, import_utils12.isBase64Image)(base64)) return base64;
|
|
6611
6549
|
let mimeType = null;
|
|
6612
6550
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6613
6551
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6616,14 +6554,14 @@ var binaryFieldController = (props) => {
|
|
|
6616
6554
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
6617
6555
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
6618
6556
|
};
|
|
6619
|
-
(0,
|
|
6557
|
+
(0, import_react20.useEffect)(() => {
|
|
6620
6558
|
return () => {
|
|
6621
6559
|
if (selectedImage) {
|
|
6622
6560
|
URL.revokeObjectURL(selectedImage);
|
|
6623
6561
|
}
|
|
6624
6562
|
};
|
|
6625
6563
|
}, [selectedImage]);
|
|
6626
|
-
(0,
|
|
6564
|
+
(0, import_react20.useEffect)(() => {
|
|
6627
6565
|
if (binaryRef.current) {
|
|
6628
6566
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
6629
6567
|
setIsInsideTable(isInsideTable2);
|
|
@@ -6644,20 +6582,20 @@ var binaryFieldController = (props) => {
|
|
|
6644
6582
|
|
|
6645
6583
|
// src/widget/advance/table/table-body/controller.ts
|
|
6646
6584
|
var import_store9 = require("@fctc/interface-logic/store");
|
|
6647
|
-
var
|
|
6585
|
+
var import_react21 = require("react");
|
|
6648
6586
|
var tableBodyController = (props) => {
|
|
6649
6587
|
const {
|
|
6650
6588
|
checkedAll,
|
|
6651
6589
|
checkboxRef,
|
|
6652
6590
|
setIsAutoSelect,
|
|
6653
|
-
selectedRowKeys,
|
|
6654
6591
|
row,
|
|
6655
6592
|
isAutoSelect,
|
|
6656
6593
|
selectedRowKeysRef,
|
|
6657
6594
|
onClickRow
|
|
6658
6595
|
} = props;
|
|
6659
6596
|
const appDispatch = (0, import_store9.useAppDispatch)();
|
|
6660
|
-
const
|
|
6597
|
+
const { selectedRowKeys } = (0, import_store9.useAppSelector)(import_store9.selectList);
|
|
6598
|
+
const checked = (0, import_react21.useMemo)(() => {
|
|
6661
6599
|
if (!row?.id) return false;
|
|
6662
6600
|
if (selectedRowKeys?.includes(row.id)) {
|
|
6663
6601
|
return true;
|
|
@@ -6672,13 +6610,12 @@ var tableBodyController = (props) => {
|
|
|
6672
6610
|
return;
|
|
6673
6611
|
}
|
|
6674
6612
|
const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
|
|
6675
|
-
console.log("newSelectedRowKeys", newSelectedRowKeys);
|
|
6676
6613
|
appDispatch((0, import_store9.setSelectedRowKeys)(newSelectedRowKeys));
|
|
6677
6614
|
};
|
|
6678
6615
|
const handleClickRow = (col, row2) => {
|
|
6679
6616
|
onClickRow(col, row2);
|
|
6680
6617
|
};
|
|
6681
|
-
(0,
|
|
6618
|
+
(0, import_react21.useEffect)(() => {
|
|
6682
6619
|
if (!row?.id) return;
|
|
6683
6620
|
if (isAutoSelect) {
|
|
6684
6621
|
if (checkboxRef?.current === "uncheck") {
|
|
@@ -6696,7 +6633,7 @@ var tableBodyController = (props) => {
|
|
|
6696
6633
|
}
|
|
6697
6634
|
}
|
|
6698
6635
|
}, [isAutoSelect]);
|
|
6699
|
-
(0,
|
|
6636
|
+
(0, import_react21.useEffect)(() => {
|
|
6700
6637
|
if (!checkedAll) {
|
|
6701
6638
|
checkboxRef.current = "enabled";
|
|
6702
6639
|
false;
|
|
@@ -6747,12 +6684,12 @@ var tableHeadController = (props) => {
|
|
|
6747
6684
|
};
|
|
6748
6685
|
|
|
6749
6686
|
// src/widget/advance/table/table-view/controller.ts
|
|
6750
|
-
var
|
|
6687
|
+
var import_react22 = require("react");
|
|
6751
6688
|
var import_store11 = require("@fctc/interface-logic/store");
|
|
6752
|
-
var
|
|
6689
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6753
6690
|
var tableController = ({ data }) => {
|
|
6754
|
-
const [rows, setRows] = (0,
|
|
6755
|
-
const [columns, setColumns] = (0,
|
|
6691
|
+
const [rows, setRows] = (0, import_react22.useState)(data.records || []);
|
|
6692
|
+
const [columns, setColumns] = (0, import_react22.useState)([]);
|
|
6756
6693
|
const dataModelFields = data.fields?.map((field) => {
|
|
6757
6694
|
return {
|
|
6758
6695
|
...data.dataModel?.[field?.name],
|
|
@@ -6780,14 +6717,14 @@ var tableController = ({ data }) => {
|
|
|
6780
6717
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
6781
6718
|
});
|
|
6782
6719
|
};
|
|
6783
|
-
(0,
|
|
6720
|
+
(0, import_react22.useEffect)(() => {
|
|
6784
6721
|
setRows(transformData(data.records || null));
|
|
6785
6722
|
}, [data.records]);
|
|
6786
6723
|
const handleGetColumns = () => {
|
|
6787
6724
|
let cols = [];
|
|
6788
6725
|
try {
|
|
6789
6726
|
cols = mergeFields?.filter((item) => {
|
|
6790
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6727
|
+
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
6728
|
})?.map((field) => {
|
|
6792
6729
|
return {
|
|
6793
6730
|
name: field?.name,
|
|
@@ -6801,7 +6738,7 @@ var tableController = ({ data }) => {
|
|
|
6801
6738
|
}
|
|
6802
6739
|
return cols;
|
|
6803
6740
|
};
|
|
6804
|
-
(0,
|
|
6741
|
+
(0, import_react22.useEffect)(() => {
|
|
6805
6742
|
const columns2 = handleGetColumns();
|
|
6806
6743
|
setColumns(columns2);
|
|
6807
6744
|
}, [data.records]);
|
|
@@ -6826,8 +6763,8 @@ var tableController = ({ data }) => {
|
|
|
6826
6763
|
};
|
|
6827
6764
|
|
|
6828
6765
|
// src/widget/advance/table/table-group/controller.ts
|
|
6829
|
-
var
|
|
6830
|
-
var
|
|
6766
|
+
var import_react23 = require("react");
|
|
6767
|
+
var import_hooks14 = require("@fctc/interface-logic/hooks");
|
|
6831
6768
|
var import_store12 = require("@fctc/interface-logic/store");
|
|
6832
6769
|
|
|
6833
6770
|
// src/environment.ts
|
|
@@ -6855,18 +6792,18 @@ var tableGroupController = (props) => {
|
|
|
6855
6792
|
setIsAutoSelect,
|
|
6856
6793
|
selectedRowKeysRef
|
|
6857
6794
|
} = props;
|
|
6858
|
-
const [pageGroup, setPageGroup] = (0,
|
|
6795
|
+
const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
|
|
6859
6796
|
const { groupByDomain, selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
|
|
6860
6797
|
const { selectedRowKeys } = (0, import_store12.useAppSelector)(import_store12.selectList);
|
|
6861
6798
|
const appDispatch = (0, import_store12.useAppDispatch)();
|
|
6862
|
-
const { toDataJS } = (0,
|
|
6799
|
+
const { toDataJS } = (0, import_hooks14.useOdooDataTransform)();
|
|
6863
6800
|
const initVal = toDataJS(row, viewData, model);
|
|
6864
|
-
const [isShowGroup, setIsShowGroup] = (0,
|
|
6865
|
-
const [colEmptyGroup, setColEmptyGroup] = (0,
|
|
6801
|
+
const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
|
|
6802
|
+
const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
|
|
6866
6803
|
fromStart: 1,
|
|
6867
6804
|
fromEnd: 1
|
|
6868
6805
|
});
|
|
6869
|
-
const processedData = (0,
|
|
6806
|
+
const processedData = (0, import_react23.useMemo)(() => {
|
|
6870
6807
|
const calculateColSpanEmpty = () => {
|
|
6871
6808
|
const startIndex = columns.findIndex(
|
|
6872
6809
|
(col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
|
|
@@ -6881,7 +6818,7 @@ var tableGroupController = (props) => {
|
|
|
6881
6818
|
};
|
|
6882
6819
|
return calculateColSpanEmpty();
|
|
6883
6820
|
}, [columns, row]);
|
|
6884
|
-
const shouldFetchData = (0,
|
|
6821
|
+
const shouldFetchData = (0, import_react23.useMemo)(() => {
|
|
6885
6822
|
return !!isShowGroup;
|
|
6886
6823
|
}, [isShowGroup]);
|
|
6887
6824
|
const enabled = shouldFetchData && !!processedData;
|
|
@@ -6906,7 +6843,7 @@ var tableGroupController = (props) => {
|
|
|
6906
6843
|
isPlaceholderData,
|
|
6907
6844
|
isLoading,
|
|
6908
6845
|
isFetching
|
|
6909
|
-
} = (0,
|
|
6846
|
+
} = (0, import_hooks14.useGetListData)(listDataProps, queryKey, enabled);
|
|
6910
6847
|
const {
|
|
6911
6848
|
columns: columnsGroup,
|
|
6912
6849
|
rows: rowsGroup,
|
|
@@ -6921,7 +6858,7 @@ var tableGroupController = (props) => {
|
|
|
6921
6858
|
}
|
|
6922
6859
|
});
|
|
6923
6860
|
const leftPadding = level > 1 ? level * 8 + "px" : "0px";
|
|
6924
|
-
(0,
|
|
6861
|
+
(0, import_react23.useEffect)(() => {
|
|
6925
6862
|
if (isShowGroup && selectedTags?.length > 0) {
|
|
6926
6863
|
setIsShowGroup(false);
|
|
6927
6864
|
}
|
|
@@ -6955,7 +6892,7 @@ var tableGroupController = (props) => {
|
|
|
6955
6892
|
}
|
|
6956
6893
|
toggleShowGroup();
|
|
6957
6894
|
};
|
|
6958
|
-
(0,
|
|
6895
|
+
(0, import_react23.useEffect)(() => {
|
|
6959
6896
|
if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
|
|
6960
6897
|
return;
|
|
6961
6898
|
}
|
|
@@ -6996,9 +6933,9 @@ var tableGroupController = (props) => {
|
|
|
6996
6933
|
|
|
6997
6934
|
// src/widget/advance/search/controller.ts
|
|
6998
6935
|
var import_constants5 = require("@fctc/interface-logic/constants");
|
|
6999
|
-
var
|
|
6936
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
7000
6937
|
var import_moment2 = __toESM(require_moment());
|
|
7001
|
-
var
|
|
6938
|
+
var import_react24 = require("react");
|
|
7002
6939
|
var searchController = ({
|
|
7003
6940
|
viewData,
|
|
7004
6941
|
actionData,
|
|
@@ -7007,12 +6944,12 @@ var searchController = ({
|
|
|
7007
6944
|
setSearchMap,
|
|
7008
6945
|
searchMap
|
|
7009
6946
|
}) => {
|
|
7010
|
-
const [filterBy, setFilterBy] = (0,
|
|
7011
|
-
const [searchBy, setSearchBy] = (0,
|
|
7012
|
-
const [groupBy, setGroupBy] = (0,
|
|
7013
|
-
const [selectedTags, setSelectedTags] = (0,
|
|
7014
|
-
const [searchString, setSearchString] = (0,
|
|
7015
|
-
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0,
|
|
6947
|
+
const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
|
|
6948
|
+
const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
|
|
6949
|
+
const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
|
|
6950
|
+
const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
|
|
6951
|
+
const [searchString, setSearchString] = (0, import_react24.useState)("");
|
|
6952
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils14.evalJSONDomain)(actionData?.domain, contextSearch) : [];
|
|
7016
6953
|
const aid = actionData?.id;
|
|
7017
6954
|
const model = actionData?.res_model;
|
|
7018
6955
|
const clearSearch = () => {
|
|
@@ -7029,7 +6966,7 @@ var searchController = ({
|
|
|
7029
6966
|
const dataModel = viewData?.models?.[model];
|
|
7030
6967
|
const searchViews = viewData?.views?.search;
|
|
7031
6968
|
const searchByItems = searchViews?.search_by?.filter(
|
|
7032
|
-
(item) => !
|
|
6969
|
+
(item) => !import_utils14.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
7033
6970
|
)?.map(
|
|
7034
6971
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
7035
6972
|
dataIndex: index,
|
|
@@ -7042,10 +6979,10 @@ var searchController = ({
|
|
|
7042
6979
|
})
|
|
7043
6980
|
);
|
|
7044
6981
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
7045
|
-
return !
|
|
6982
|
+
return !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
7046
6983
|
})?.map((item) => ({ ...item, active: false }));
|
|
7047
6984
|
const groupByItems = searchViews?.group_by.filter(
|
|
7048
|
-
(item) => !
|
|
6985
|
+
(item) => !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
7049
6986
|
).map((item) => ({
|
|
7050
6987
|
...item,
|
|
7051
6988
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -7058,7 +6995,7 @@ var searchController = ({
|
|
|
7058
6995
|
}
|
|
7059
6996
|
}
|
|
7060
6997
|
};
|
|
7061
|
-
(0,
|
|
6998
|
+
(0, import_react24.useEffect)(() => {
|
|
7062
6999
|
clearSearch();
|
|
7063
7000
|
fetchData();
|
|
7064
7001
|
}, [aid, model, viewData]);
|
|
@@ -7123,14 +7060,14 @@ var searchController = ({
|
|
|
7123
7060
|
}
|
|
7124
7061
|
let valueDomainItem = value?.value;
|
|
7125
7062
|
if (value?.modelType === "date") {
|
|
7126
|
-
valueDomainItem = (0,
|
|
7063
|
+
valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value);
|
|
7127
7064
|
} else if (value?.modelType === "datetime") {
|
|
7128
7065
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7129
|
-
const parsedDate = (0,
|
|
7066
|
+
const parsedDate = (0, import_utils14.validateAndParseDate)(value?.value, true);
|
|
7130
7067
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7131
7068
|
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
7069
|
} else {
|
|
7133
|
-
valueDomainItem = (0,
|
|
7070
|
+
valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value, true);
|
|
7134
7071
|
}
|
|
7135
7072
|
}
|
|
7136
7073
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -7141,7 +7078,7 @@ var searchController = ({
|
|
|
7141
7078
|
return [...domain];
|
|
7142
7079
|
}
|
|
7143
7080
|
};
|
|
7144
|
-
const setTagSearch = (0,
|
|
7081
|
+
const setTagSearch = (0, import_react24.useCallback)(
|
|
7145
7082
|
(updatedMap) => {
|
|
7146
7083
|
if (!updatedMap) return;
|
|
7147
7084
|
const tagsSearch = Object.entries(updatedMap).map(
|
|
@@ -7204,7 +7141,7 @@ var searchController = ({
|
|
|
7204
7141
|
},
|
|
7205
7142
|
[searchMap]
|
|
7206
7143
|
);
|
|
7207
|
-
(0,
|
|
7144
|
+
(0, import_react24.useEffect)(() => {
|
|
7208
7145
|
setSelectedTags(null);
|
|
7209
7146
|
setTagSearch(searchMap);
|
|
7210
7147
|
}, [searchMap]);
|
|
@@ -7219,7 +7156,7 @@ var searchController = ({
|
|
|
7219
7156
|
active,
|
|
7220
7157
|
dataIndex
|
|
7221
7158
|
} = tag;
|
|
7222
|
-
const domainFormat = new
|
|
7159
|
+
const domainFormat = new import_utils14.domainHelper.Domain(domain);
|
|
7223
7160
|
if (type === import_constants5.SearchType.FILTER) {
|
|
7224
7161
|
addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
|
|
7225
7162
|
...tag,
|