@fctc/widget-logic 1.10.1 → 1.10.3

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/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 import_react15 = require("react");
4114
+ var import_react14 = require("react");
4115
4115
 
4116
4116
  // src/hooks.ts
4117
4117
  var hooks_exports = {};
@@ -4885,32 +4885,8 @@ var useAppProvider = () => {
4885
4885
  return context;
4886
4886
  };
4887
4887
 
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");
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
4888
  // src/hooks/utils/use-click-outside.ts
4913
- var import_react13 = require("react");
4889
+ var import_react12 = require("react");
4914
4890
  var DEFAULT_EVENTS = ["mousedown", "touchstart"];
4915
4891
  var useClickOutside = ({
4916
4892
  handler,
@@ -4918,8 +4894,8 @@ var useClickOutside = ({
4918
4894
  nodes = [],
4919
4895
  refs
4920
4896
  }) => {
4921
- const ref = (0, import_react13.useRef)(null);
4922
- (0, import_react13.useEffect)(() => {
4897
+ const ref = (0, import_react12.useRef)(null);
4898
+ (0, import_react12.useEffect)(() => {
4923
4899
  const listener = (event) => {
4924
4900
  const { target } = event;
4925
4901
  if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
@@ -4941,10 +4917,10 @@ var useClickOutside = ({
4941
4917
  };
4942
4918
 
4943
4919
  // src/hooks/utils/use-debounce.ts
4944
- var import_react14 = require("react");
4920
+ var import_react13 = require("react");
4945
4921
  function useDebounce(value, delay) {
4946
- const [debouncedValue, setDebouncedValue] = (0, import_react14.useState)(value);
4947
- (0, import_react14.useEffect)(() => {
4922
+ const [debouncedValue, setDebouncedValue] = (0, import_react13.useState)(value);
4923
+ (0, import_react13.useEffect)(() => {
4948
4924
  const handler = setTimeout(() => {
4949
4925
  setDebouncedValue(value);
4950
4926
  }, delay);
@@ -4958,6 +4934,25 @@ function useDebounce(value, delay) {
4958
4934
  // src/hooks.ts
4959
4935
  __reExport(hooks_exports, require("@fctc/interface-logic/hooks"));
4960
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
+
4961
4956
  // src/provider.ts
4962
4957
  var provider_exports = {};
4963
4958
  __reExport(provider_exports, require("@fctc/interface-logic/provider"));
@@ -4977,22 +4972,22 @@ var many2oneFieldController = (props) => {
4977
4972
  options: fieldOptions,
4978
4973
  showDetail
4979
4974
  } = props;
4980
- const [options, setOptions] = (0, import_react15.useState)([]);
4981
- const [inputValue, setInputValue] = (0, import_react15.useState)("");
4975
+ const { env } = (0, provider_exports.useEnv)();
4976
+ const [options, setOptions] = (0, import_react14.useState)([]);
4977
+ const [inputValue, setInputValue] = (0, import_react14.useState)("");
4982
4978
  const [debouncedInputValue] = useDebounce(inputValue, 1e3);
4983
- const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react15.useState)(false);
4984
- const [tempSelectedOption, setTempSelectedOption] = (0, import_react15.useState)(null);
4985
- const [domainModal, setDomainModal] = (0, import_react15.useState)(null);
4986
- const [domainObject, setDomainObject] = (0, import_react15.useState)(null);
4979
+ const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react14.useState)(false);
4980
+ const [tempSelectedOption, setTempSelectedOption] = (0, import_react14.useState)(null);
4981
+ const [domainModal, setDomainModal] = (0, import_react14.useState)(null);
4982
+ const [domainObject, setDomainObject] = (0, import_react14.useState)(null);
4987
4983
  const actionData = sessionStorageUtils.getActionData();
4988
4984
  const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
4989
- const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
4990
4985
  const initValue = methods?.getValues(name);
4991
4986
  const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
4992
4987
  const contextObject = {
4993
4988
  ...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
4994
4989
  ...fieldContext,
4995
- ...context
4990
+ ...env?.context
4996
4991
  };
4997
4992
  const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
4998
4993
  const data = {
@@ -5015,18 +5010,18 @@ var many2oneFieldController = (props) => {
5015
5010
  queryKey,
5016
5011
  enabled: false
5017
5012
  });
5018
- const selectOptions = (0, import_react15.useMemo)(() => {
5013
+ const selectOptions = (0, import_react14.useMemo)(() => {
5019
5014
  return dataOfSelection?.records?.map((val) => ({
5020
5015
  value: val?.id,
5021
5016
  label: val?.display_name || val?.name
5022
5017
  })) || [];
5023
5018
  }, [dataOfSelection]);
5024
- (0, import_react15.useEffect)(() => {
5019
+ (0, import_react14.useEffect)(() => {
5025
5020
  setOptions(selectOptions);
5026
5021
  setDomainModal(domainObject);
5027
5022
  if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
5028
5023
  }, [selectOptions]);
5029
- (0, import_react15.useEffect)(() => {
5024
+ (0, import_react14.useEffect)(() => {
5030
5025
  setDomainObject(
5031
5026
  (0, utils_exports.evalJSONDomain)(
5032
5027
  domain,
@@ -5034,7 +5029,7 @@ var many2oneFieldController = (props) => {
5034
5029
  )
5035
5030
  );
5036
5031
  }, [domain, formValues]);
5037
- (0, import_react15.useEffect)(() => {
5032
+ (0, import_react14.useEffect)(() => {
5038
5033
  if (!propValue && tempSelectedOption) {
5039
5034
  methods.setValue(name, null);
5040
5035
  setTempSelectedOption(null);
@@ -5045,10 +5040,10 @@ var many2oneFieldController = (props) => {
5045
5040
  });
5046
5041
  }
5047
5042
  }, [propValue]);
5048
- const fetchMoreOptions = (0, import_react15.useCallback)(() => {
5043
+ const fetchMoreOptions = (0, import_react14.useCallback)(() => {
5049
5044
  refetch();
5050
5045
  }, [refetch]);
5051
- (0, import_react15.useEffect)(() => {
5046
+ (0, import_react14.useEffect)(() => {
5052
5047
  if (debouncedInputValue) {
5053
5048
  const filteredDomain = [...domainObject ?? []]?.filter(
5054
5049
  (d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
@@ -5063,7 +5058,7 @@ var many2oneFieldController = (props) => {
5063
5058
  }, 50);
5064
5059
  }
5065
5060
  }, [debouncedInputValue]);
5066
- const handleChooseRecord = (0, import_react15.useCallback)(
5061
+ const handleChooseRecord = (0, import_react14.useCallback)(
5067
5062
  (idRecord) => {
5068
5063
  const newOption = options.find(
5069
5064
  (option) => option.value === idRecord
@@ -5088,8 +5083,8 @@ var many2oneFieldController = (props) => {
5088
5083
  },
5089
5084
  [options, methods, name, onChange]
5090
5085
  );
5091
- const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
5092
- const handleSelectChange = (0, import_react15.useCallback)(
5086
+ const handleClose = (0, import_react14.useCallback)(() => setIsShowModalMany2Many(false), []);
5087
+ const handleSelectChange = (0, import_react14.useCallback)(
5093
5088
  (selectedOption) => {
5094
5089
  if (!selectedOption) {
5095
5090
  methods.setValue(name, null, { shouldDirty: true });
@@ -5136,20 +5131,20 @@ var many2oneFieldController = (props) => {
5136
5131
  };
5137
5132
 
5138
5133
  // src/widget/basic/many2one-button-field/controller.ts
5139
- var import_environment7 = require("@fctc/interface-logic/environment");
5140
- var import_hooks13 = require("@fctc/interface-logic/hooks");
5141
- var import_utils6 = require("@fctc/interface-logic/utils");
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");
5142
5137
  var many2oneButtonController = (props) => {
5143
5138
  const { domain, methods, relation } = props;
5144
5139
  const actionDataString = sessionStorage.getItem("actionData");
5145
- const env = (0, import_environment7.getEnv)();
5146
- const domainObject = (0, import_utils6.evalJSONDomain)(domain, methods?.getValues() || {});
5140
+ const env = (0, import_environment6.getEnv)();
5141
+ const domainObject = (0, import_utils5.evalJSONDomain)(domain, methods?.getValues() || {});
5147
5142
  const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
5148
- const { data: dataOfSelection } = (0, import_hooks13.useGetSelection)({
5143
+ const { data: dataOfSelection } = (0, import_hooks12.useGetSelection)({
5149
5144
  data: {
5150
5145
  model: relation ?? "",
5151
5146
  domain: domainObject,
5152
- context: { ...env.context, ...(0, import_utils6.evalJSONContext)(actionData?.context) }
5147
+ context: { ...env.context, ...(0, import_utils5.evalJSONContext)(actionData?.context) }
5153
5148
  },
5154
5149
  queryKey: [`data_${relation}`, domainObject]
5155
5150
  });
@@ -5163,91 +5158,78 @@ var many2oneButtonController = (props) => {
5163
5158
  };
5164
5159
 
5165
5160
  // src/widget/basic/many2many-field/controller.ts
5166
- var import_react16 = require("react");
5167
- var import_store8 = require("@fctc/interface-logic/store");
5168
- var import_utils7 = require("@fctc/interface-logic/utils");
5161
+ var import_react15 = require("react");
5162
+ var import_utils6 = require("@fctc/interface-logic/utils");
5169
5163
  var many2manyFieldController = (props) => {
5170
5164
  const {
5171
5165
  relation,
5172
5166
  domain,
5173
5167
  context,
5168
+ options,
5174
5169
  tab,
5175
- model,
5176
- aid,
5177
5170
  setSelectedRowKeys: setSelectedRowKeys4,
5178
- fields,
5179
- setFields,
5180
5171
  groupByDomain,
5181
- page,
5182
- options,
5183
- sessionStorageUtils
5172
+ enabled: enabledCallAPI,
5173
+ actionData
5184
5174
  } = props;
5185
- const appDispatch = (0, import_store8.useAppDispatch)();
5186
- const actionData = sessionStorageUtils.getActionData();
5187
- const [debouncedPage] = useDebounce(page, 500);
5188
- const [order, setOrder] = (0, import_react16.useState)();
5189
- const [isLoadedData, setIsLoadedData] = (0, import_react16.useState)(false);
5190
- const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(domain);
5191
5175
  const { env } = (0, provider_exports.useEnv)();
5192
5176
  const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
5177
+ const [order, setOrder] = (0, import_react15.useState)();
5178
+ const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
5179
+ const [page, setPage] = (0, import_react15.useState)(0);
5180
+ const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(null);
5181
+ const [debouncedPage] = useDebounce(page, 500);
5182
+ const contextObject = {
5183
+ ...env.context,
5184
+ ...context || {}
5185
+ };
5193
5186
  const viewParams = {
5194
5187
  model: relation,
5195
5188
  views: [
5196
5189
  [false, "list"],
5197
5190
  [false, "search"]
5198
5191
  ],
5199
- context
5192
+ context: contextObject
5200
5193
  };
5201
- const { data: viewResponse } = useGetView2(viewParams, actionData);
5202
- const baseModel = (0, import_react16.useMemo)(
5194
+ const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
5195
+ const baseModel = (0, import_react15.useMemo)(
5203
5196
  () => ({
5204
5197
  name: String(relation),
5205
5198
  view: viewResponse || {},
5206
- actContext: context,
5199
+ actContext: contextObject,
5207
5200
  fields: [
5208
5201
  ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5209
5202
  ...tab?.fields ? tab.fields : []
5210
5203
  ]
5211
5204
  }),
5212
- [model, viewResponse]
5205
+ [relation, viewResponse]
5213
5206
  );
5214
5207
  const initModel = (0, hooks_exports.useModel)();
5215
- const modelInstance = (0, import_react16.useMemo)(() => {
5208
+ const modelInstance = (0, import_react15.useMemo)(() => {
5216
5209
  if (viewResponse) {
5217
5210
  return initModel.initModel(baseModel);
5218
5211
  }
5219
5212
  return null;
5220
5213
  }, [baseModel, viewResponse]);
5221
- const specification = (0, import_react16.useMemo)(() => {
5214
+ const specification = (0, import_react15.useMemo)(() => {
5222
5215
  if (modelInstance) {
5223
5216
  return modelInstance.getSpecification();
5224
5217
  }
5225
5218
  return null;
5226
5219
  }, [modelInstance]);
5227
5220
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
5228
- const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
5221
+ const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
5229
5222
  const fetchData = async () => {
5230
5223
  try {
5231
- setDomainMany2Many(domain);
5232
- appDispatch((0, import_store8.setFirstDomain)(domain));
5233
- appDispatch((0, import_store8.setViewDataStore)(viewResponse));
5234
- const modalData = viewResponse?.views?.list?.fields.map((field) => ({
5235
- ...viewResponse?.models?.[String(model)]?.[field?.name],
5236
- ...field
5237
- }));
5238
- if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
5239
- setFields({
5240
- ...fields,
5241
- [`${aid}_${relation}_popupmany2many`]: modalData
5242
- });
5243
- }
5244
- appDispatch((0, import_store8.setPage)(0));
5224
+ const domainParse = typeof domain === "string" ? (0, import_utils6.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
5225
+ setDomainMany2Many(domainParse);
5226
+ setPage(0);
5245
5227
  } catch (err) {
5246
5228
  console.log(err);
5247
5229
  }
5248
5230
  };
5249
5231
  const queryKey = [
5250
- `view-${relation}-${aid}`,
5232
+ `view-${relation}`,
5251
5233
  specification,
5252
5234
  domainMany2Many,
5253
5235
  debouncedPage,
@@ -5260,93 +5242,104 @@ var many2manyFieldController = (props) => {
5260
5242
  domain: domainMany2Many,
5261
5243
  offset: debouncedPage * 10,
5262
5244
  limit: 10,
5263
- context,
5245
+ context: contextObject,
5264
5246
  fields: groupByDomain?.fields,
5265
5247
  groupby: [groupByDomain?.contexts[0]?.group_by],
5266
- sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
5248
+ sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
5267
5249
  };
5268
- const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
5250
+ const enabled = enabledCallAPI && isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
5269
5251
  const {
5270
5252
  data: dataResponse,
5271
- isLoading: isDataLoading,
5272
- isFetched: isDataResponseFetched,
5253
+ isLoading,
5254
+ isFetched,
5273
5255
  isPlaceholderData
5274
5256
  } = useGetListData3(data, queryKey, enabled);
5275
- (0, import_react16.useEffect)(() => {
5257
+ (0, import_react15.useEffect)(() => {
5276
5258
  if (viewResponse) {
5277
5259
  fetchData();
5278
5260
  }
5279
5261
  return () => {
5280
- appDispatch((0, import_store8.setGroupByDomain)(null));
5281
- setFields((prevFields) => ({
5282
- ...prevFields,
5283
- [`${aid}_${relation}_popupmany2many`]: null
5284
- }));
5285
- appDispatch((0, import_store8.setPage)(0));
5262
+ setPage(0);
5286
5263
  setSelectedRowKeys4([]);
5287
5264
  setDomainMany2Many(null);
5288
5265
  setIsLoadedData(false);
5289
5266
  };
5290
5267
  }, [viewResponse]);
5291
- const { rows, columns, typeTable } = tableController({
5268
+ const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
5292
5269
  data: {
5293
- fields: fields?.[`${aid}_${relation}_popupmany2many`] || viewResponse?.views?.list?.fields,
5270
+ fields: viewResponse?.views?.list?.fields,
5294
5271
  records: dataResponse?.records ?? dataResponse?.groups,
5295
5272
  dataModel: viewResponse?.models?.[String(relation)],
5296
- context: { ...env.context, ...context },
5273
+ context: contextObject,
5297
5274
  typeTable: dataResponse?.groups ? "group" : "list"
5298
5275
  }
5299
5276
  });
5300
- const dataFormView = {
5301
- id: null,
5302
- model: relation,
5303
- context
5304
- };
5305
5277
  const {
5306
- refetch,
5307
- data: dataFormViewResponse,
5308
- isSuccess
5309
- } = useGetFormView({
5310
- data: dataFormView,
5311
- queryKey: [`form-view-action-${relation}`],
5312
- enabled: false
5278
+ removeSearchItems,
5279
+ selectedTags,
5280
+ filterBy,
5281
+ setFilterBy,
5282
+ searchString,
5283
+ onSearchString,
5284
+ handleAddTagSearch,
5285
+ searchBy,
5286
+ groupBy,
5287
+ setGroupBy,
5288
+ domain: domainSearch
5289
+ } = searchController({
5290
+ viewData: viewResponse,
5291
+ actionData,
5292
+ fieldsList: [
5293
+ ...columns?.filter(
5294
+ (col) => col?.field?.type_co === "field" && col?.optional !== "hide"
5295
+ )?.map((col) => ({ ...col.field })) ?? []
5296
+ ]
5313
5297
  });
5314
- (0, import_react16.useEffect)(() => {
5315
- if (isSuccess && dataFormViewResponse) {
5316
- sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
5317
- window.location.href = `/form/menu?model=${relation}`;
5318
- }
5319
- }, [isSuccess]);
5320
- (0, import_react16.useEffect)(() => {
5298
+ (0, import_react15.useEffect)(() => {
5321
5299
  if (domainMany2Many && !isLoadedData) {
5322
5300
  setIsLoadedData(true);
5323
5301
  }
5324
5302
  }, [domainMany2Many]);
5303
+ (0, import_react15.useEffect)(() => {
5304
+ setDomainMany2Many(domainSearch);
5305
+ }, [domainSearch]);
5325
5306
  const handleCreateNewOnPage = async () => {
5326
- try {
5327
- refetch();
5328
- } catch (error) {
5329
- console.log(error);
5330
- }
5331
5307
  };
5332
5308
  return {
5333
5309
  handleCreateNewOnPage,
5334
5310
  optionsObject,
5311
+ totalRows: dataResponse?.length ?? 0,
5335
5312
  rows,
5336
5313
  columns,
5314
+ onToggleColumnOptional,
5337
5315
  typeTable,
5338
- isDataLoading,
5339
- isDataResponseFetched,
5340
- isPlaceholderData
5316
+ isLoading,
5317
+ isFetched,
5318
+ isPlaceholderData,
5319
+ setPage,
5320
+ page,
5321
+ viewData: viewResponse,
5322
+ domain: domainMany2Many,
5323
+ // search
5324
+ removeSearchItems,
5325
+ selectedTags,
5326
+ filterBy,
5327
+ setFilterBy,
5328
+ searchString,
5329
+ onSearchString,
5330
+ handleAddTagSearch,
5331
+ searchBy,
5332
+ groupBy,
5333
+ setGroupBy
5341
5334
  };
5342
5335
  };
5343
5336
 
5344
5337
  // src/widget/basic/many2many-tags-field/controller.ts
5345
- var import_react17 = require("react");
5338
+ var import_react16 = require("react");
5346
5339
  var import_constants4 = require("@fctc/interface-logic/constants");
5347
- var import_environment8 = require("@fctc/interface-logic/environment");
5348
- var import_hooks15 = require("@fctc/interface-logic/hooks");
5349
- var import_utils8 = require("@fctc/interface-logic/utils");
5340
+ var import_environment7 = require("@fctc/interface-logic/environment");
5341
+ var import_hooks14 = require("@fctc/interface-logic/hooks");
5342
+ var import_utils7 = require("@fctc/interface-logic/utils");
5350
5343
  var many2manyTagsController = (props) => {
5351
5344
  const {
5352
5345
  relation,
@@ -5357,10 +5350,10 @@ var many2manyTagsController = (props) => {
5357
5350
  placeholderNoOption
5358
5351
  } = props;
5359
5352
  const isUser = relation === "res.users" || relation === "res.partner";
5360
- const env = (0, import_environment8.getEnv)();
5361
- const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
5362
- const domainObject = (0, import_react17.useMemo)(
5363
- () => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
5353
+ const env = (0, import_environment7.getEnv)();
5354
+ const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
5355
+ const domainObject = (0, import_react16.useMemo)(
5356
+ () => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
5364
5357
  [domain, formValues]
5365
5358
  );
5366
5359
  const data = {
@@ -5376,7 +5369,7 @@ var many2manyTagsController = (props) => {
5376
5369
  enabled: true,
5377
5370
  context: env.context
5378
5371
  };
5379
- const { data: dataOfSelection } = (0, import_hooks15.useGetSelection)({
5372
+ const { data: dataOfSelection } = (0, import_hooks14.useGetSelection)({
5380
5373
  data,
5381
5374
  queryKey: [`data_${relation}`, domainObject]
5382
5375
  });
@@ -5402,8 +5395,8 @@ var many2manyTagsController = (props) => {
5402
5395
  };
5403
5396
 
5404
5397
  // src/widget/basic/status-bar-field/controller.ts
5405
- var import_react18 = require("react");
5406
- var import_utils9 = require("@fctc/interface-logic/utils");
5398
+ var import_react17 = require("react");
5399
+ var import_utils8 = require("@fctc/interface-logic/utils");
5407
5400
  var durationController = (props) => {
5408
5401
  const { relation, domain, formValues, name, id, model, onRefetch } = props;
5409
5402
  const specification = {
@@ -5413,13 +5406,13 @@ var durationController = (props) => {
5413
5406
  };
5414
5407
  const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
5415
5408
  const { env } = (0, provider_exports.useEnv)();
5416
- const [disabled, setDisabled] = (0, import_react18.useState)(false);
5417
- const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
5409
+ const [disabled, setDisabled] = (0, import_react17.useState)(false);
5410
+ const [modelStatus, setModalStatus] = (0, import_react17.useState)(false);
5418
5411
  const queryKey = [`data-status-duration`, specification];
5419
5412
  const listDataProps = {
5420
5413
  model: relation,
5421
5414
  specification,
5422
- domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
5415
+ domain: (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
5423
5416
  limit: 10,
5424
5417
  offset: 0,
5425
5418
  fields: "",
@@ -5465,8 +5458,8 @@ var durationController = (props) => {
5465
5458
  };
5466
5459
 
5467
5460
  // src/widget/basic/priority-field/controller.ts
5468
- var import_hooks16 = require("@fctc/interface-logic/hooks");
5469
- var import_utils10 = require("@fctc/interface-logic/utils");
5461
+ var import_hooks15 = require("@fctc/interface-logic/hooks");
5462
+ var import_utils9 = require("@fctc/interface-logic/utils");
5470
5463
  var priorityFieldController = (props) => {
5471
5464
  const {
5472
5465
  value,
@@ -5481,11 +5474,11 @@ var priorityFieldController = (props) => {
5481
5474
  viewData,
5482
5475
  context
5483
5476
  } = props;
5484
- const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
5477
+ const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
5485
5478
  const contextObject = { ...context, ..._context };
5486
5479
  const defaultPriority = parseInt(value) + 1;
5487
5480
  const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
5488
- const { mutateAsync: fetchSave } = (0, import_hooks16.useSave)();
5481
+ const { mutateAsync: fetchSave } = (0, import_hooks15.useSave)();
5489
5482
  const savePriorities = async ({
5490
5483
  value: value2,
5491
5484
  resetPriority
@@ -5520,10 +5513,10 @@ var priorityFieldController = (props) => {
5520
5513
  };
5521
5514
 
5522
5515
  // src/widget/basic/download-file-field/controller.ts
5523
- var import_react19 = require("react");
5516
+ var import_react18 = require("react");
5524
5517
  var downloadFileController = () => {
5525
- const inputId = (0, import_react19.useId)();
5526
- const [file, setFile] = (0, import_react19.useState)(null);
5518
+ const inputId = (0, import_react18.useId)();
5519
+ const [file, setFile] = (0, import_react18.useState)(null);
5527
5520
  const handleFileChange = (e) => {
5528
5521
  setFile(e.target.files[0]);
5529
5522
  };
@@ -6455,13 +6448,13 @@ var dateFieldController = (props) => {
6455
6448
  };
6456
6449
 
6457
6450
  // src/widget/basic/copy-link-button/controller.ts
6458
- var import_react20 = require("react");
6459
- var import_utils11 = require("@fctc/interface-logic/utils");
6451
+ var import_react19 = require("react");
6452
+ var import_utils10 = require("@fctc/interface-logic/utils");
6460
6453
  var copyLinkButtonController = (props) => {
6461
6454
  const { value, defaultValue } = props;
6462
- const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
6455
+ const [isCopied, setIsCopied] = (0, import_react19.useState)(false);
6463
6456
  const handleCopyToClipboard = async (value2) => {
6464
- await (0, import_utils11.copyTextToClipboard)(value2);
6457
+ await (0, import_utils10.copyTextToClipboard)(value2);
6465
6458
  setIsCopied(true);
6466
6459
  setTimeout(() => setIsCopied(false), 2e3);
6467
6460
  };
@@ -6474,12 +6467,12 @@ var copyLinkButtonController = (props) => {
6474
6467
  };
6475
6468
 
6476
6469
  // src/widget/basic/color-field/color-controller.ts
6477
- var import_utils12 = require("@fctc/interface-logic/utils");
6470
+ var import_utils11 = require("@fctc/interface-logic/utils");
6478
6471
  var colorFieldController = (props) => {
6479
6472
  const { value, isForm, name, formValues, idForm, model, actionData } = props;
6480
6473
  const { env } = (0, provider_exports.useEnv)();
6481
6474
  const { useSave: useSave3 } = (0, provider_exports.useService)();
6482
- const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
6475
+ const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) || {} };
6483
6476
  const contextObject = { ...env.context, ..._context };
6484
6477
  const idDefault = isForm ? idForm : formValues?.id;
6485
6478
  const { mutate: onSave } = useSave3();
@@ -6507,16 +6500,16 @@ var colorFieldController = (props) => {
6507
6500
  };
6508
6501
 
6509
6502
  // src/widget/basic/binary-field/controller.ts
6510
- var import_react21 = require("react");
6511
- var import_utils13 = require("@fctc/interface-logic/utils");
6503
+ var import_react20 = require("react");
6504
+ var import_utils12 = require("@fctc/interface-logic/utils");
6512
6505
  var binaryFieldController = (props) => {
6513
6506
  const { name, methods, readonly = false, value } = props;
6514
- const inputId = (0, import_react21.useId)();
6515
- const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
6516
- const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
6517
- const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
6507
+ const inputId = (0, import_react20.useId)();
6508
+ const [selectedImage, setSelectedImage] = (0, import_react20.useState)(null);
6509
+ const [initialImage, setInitialImage] = (0, import_react20.useState)(value || null);
6510
+ const [isInsideTable, setIsInsideTable] = (0, import_react20.useState)(false);
6518
6511
  const { setValue } = methods;
6519
- const binaryRef = (0, import_react21.useRef)(null);
6512
+ const binaryRef = (0, import_react20.useRef)(null);
6520
6513
  const convertUrlToBase64 = async (url) => {
6521
6514
  try {
6522
6515
  const response = await fetch(url);
@@ -6565,11 +6558,11 @@ var binaryFieldController = (props) => {
6565
6558
  };
6566
6559
  const checkIsImageLink = (url) => {
6567
6560
  const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
6568
- return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
6561
+ return imageExtensions.test(url) || (0, import_utils12.isBase64Image)(url) || isBlobUrl(url);
6569
6562
  };
6570
6563
  const getImageBase64WithMimeType = (base64) => {
6571
6564
  if (typeof base64 !== "string" || base64.length < 10) return null;
6572
- if ((0, import_utils13.isBase64Image)(base64)) return base64;
6565
+ if ((0, import_utils12.isBase64Image)(base64)) return base64;
6573
6566
  let mimeType = null;
6574
6567
  if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
6575
6568
  else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
@@ -6578,14 +6571,14 @@ var binaryFieldController = (props) => {
6578
6571
  else if (base64.startsWith("UklGR")) mimeType = "image/webp";
6579
6572
  return mimeType ? `data:${mimeType};base64,${base64}` : null;
6580
6573
  };
6581
- (0, import_react21.useEffect)(() => {
6574
+ (0, import_react20.useEffect)(() => {
6582
6575
  return () => {
6583
6576
  if (selectedImage) {
6584
6577
  URL.revokeObjectURL(selectedImage);
6585
6578
  }
6586
6579
  };
6587
6580
  }, [selectedImage]);
6588
- (0, import_react21.useEffect)(() => {
6581
+ (0, import_react20.useEffect)(() => {
6589
6582
  if (binaryRef.current) {
6590
6583
  const isInsideTable2 = !!binaryRef.current.closest("table");
6591
6584
  setIsInsideTable(isInsideTable2);
@@ -6605,8 +6598,8 @@ var binaryFieldController = (props) => {
6605
6598
  };
6606
6599
 
6607
6600
  // src/widget/advance/table/table-body/controller.ts
6608
- var import_store9 = require("@fctc/interface-logic/store");
6609
- var import_react22 = require("react");
6601
+ var import_store8 = require("@fctc/interface-logic/store");
6602
+ var import_react21 = require("react");
6610
6603
  var tableBodyController = (props) => {
6611
6604
  const {
6612
6605
  checkedAll,
@@ -6618,8 +6611,8 @@ var tableBodyController = (props) => {
6618
6611
  selectedRowKeysRef,
6619
6612
  onClickRow
6620
6613
  } = props;
6621
- const appDispatch = (0, import_store9.useAppDispatch)();
6622
- const checked = (0, import_react22.useMemo)(() => {
6614
+ const appDispatch = (0, import_store8.useAppDispatch)();
6615
+ const checked = (0, import_react21.useMemo)(() => {
6623
6616
  if (!row?.id) return false;
6624
6617
  if (selectedRowKeys?.includes(row.id)) {
6625
6618
  return true;
@@ -6635,12 +6628,12 @@ var tableBodyController = (props) => {
6635
6628
  }
6636
6629
  const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
6637
6630
  console.log("newSelectedRowKeys", newSelectedRowKeys);
6638
- appDispatch((0, import_store9.setSelectedRowKeys)(newSelectedRowKeys));
6631
+ appDispatch((0, import_store8.setSelectedRowKeys)(newSelectedRowKeys));
6639
6632
  };
6640
6633
  const handleClickRow = (col, row2) => {
6641
6634
  onClickRow(col, row2);
6642
6635
  };
6643
- (0, import_react22.useEffect)(() => {
6636
+ (0, import_react21.useEffect)(() => {
6644
6637
  if (!row?.id) return;
6645
6638
  if (isAutoSelect) {
6646
6639
  if (checkboxRef?.current === "uncheck") {
@@ -6648,17 +6641,17 @@ var tableBodyController = (props) => {
6648
6641
  (id) => id !== row.id
6649
6642
  );
6650
6643
  selectedRowKeysRef.current = filtered;
6651
- appDispatch((0, import_store9.setSelectedRowKeys)(filtered));
6644
+ appDispatch((0, import_store8.setSelectedRowKeys)(filtered));
6652
6645
  } else {
6653
6646
  const unique = Array.from(
6654
6647
  /* @__PURE__ */ new Set([...selectedRowKeysRef?.current, row?.id])
6655
6648
  );
6656
6649
  selectedRowKeysRef.current = unique;
6657
- appDispatch((0, import_store9.setSelectedRowKeys)(unique));
6650
+ appDispatch((0, import_store8.setSelectedRowKeys)(unique));
6658
6651
  }
6659
6652
  }
6660
6653
  }, [isAutoSelect]);
6661
- (0, import_react22.useEffect)(() => {
6654
+ (0, import_react21.useEffect)(() => {
6662
6655
  if (!checkedAll) {
6663
6656
  checkboxRef.current = "enabled";
6664
6657
  false;
@@ -6672,35 +6665,35 @@ var tableBodyController = (props) => {
6672
6665
  };
6673
6666
 
6674
6667
  // src/widget/advance/table/table-head/controller.ts
6675
- var import_store10 = require("@fctc/interface-logic/store");
6668
+ var import_store9 = require("@fctc/interface-logic/store");
6676
6669
  var tableHeadController = (props) => {
6677
6670
  const { typeTable, rows, selectedRowKeysRef } = props;
6678
- const appDispatch = (0, import_store10.useAppDispatch)();
6679
- const { groupByDomain } = (0, import_store10.useAppSelector)(import_store10.selectSearch);
6671
+ const appDispatch = (0, import_store9.useAppDispatch)();
6672
+ const { groupByDomain } = (0, import_store9.useAppSelector)(import_store9.selectSearch);
6680
6673
  const handleCheckBoxAll = (event) => {
6681
6674
  if (event?.target?.checked && typeTable === "list") {
6682
6675
  const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
6683
- appDispatch((0, import_store10.setSelectedRowKeys)(allRowKeys));
6676
+ appDispatch((0, import_store9.setSelectedRowKeys)(allRowKeys));
6684
6677
  } else if (event?.target?.checked && typeTable === "group") {
6685
6678
  const rowsIDs = document.querySelectorAll("tr[data-row-id]");
6686
6679
  const ids = Array.from(rowsIDs)?.map(
6687
6680
  (row) => Number(row?.getAttribute("data-row-id"))
6688
6681
  );
6689
6682
  if (ids?.length > 0) {
6690
- appDispatch((0, import_store10.setSelectedRowKeys)(ids));
6683
+ appDispatch((0, import_store9.setSelectedRowKeys)(ids));
6691
6684
  } else {
6692
6685
  const sum = countSum(
6693
6686
  rows,
6694
6687
  typeof groupByDomain === "object" ? groupByDomain?.contexts?.[0]?.group_by : void 0
6695
6688
  );
6696
6689
  const keys = Array.from({ length: sum }, (_) => void 0);
6697
- appDispatch((0, import_store10.setSelectedRowKeys)(keys));
6690
+ appDispatch((0, import_store9.setSelectedRowKeys)(keys));
6698
6691
  }
6699
6692
  if (selectedRowKeysRef) {
6700
6693
  selectedRowKeysRef.current = [];
6701
6694
  }
6702
6695
  } else {
6703
- appDispatch((0, import_store10.setSelectedRowKeys)([]));
6696
+ appDispatch((0, import_store9.setSelectedRowKeys)([]));
6704
6697
  }
6705
6698
  };
6706
6699
  return {
@@ -6709,12 +6702,12 @@ var tableHeadController = (props) => {
6709
6702
  };
6710
6703
 
6711
6704
  // src/widget/advance/table/table-view/controller.ts
6712
- var import_react23 = require("react");
6713
- var import_store11 = require("@fctc/interface-logic/store");
6714
- var import_utils14 = require("@fctc/interface-logic/utils");
6705
+ var import_react22 = require("react");
6706
+ var import_store10 = require("@fctc/interface-logic/store");
6707
+ var import_utils13 = require("@fctc/interface-logic/utils");
6715
6708
  var tableController = ({ data }) => {
6716
- const [rows, setRows] = (0, import_react23.useState)(data.records || []);
6717
- const [columns, setColumns] = (0, import_react23.useState)([]);
6709
+ const [rows, setRows] = (0, import_react22.useState)(data.records || []);
6710
+ const [columns, setColumns] = (0, import_react22.useState)([]);
6718
6711
  const dataModelFields = data.fields?.map((field) => {
6719
6712
  return {
6720
6713
  ...data.dataModel?.[field?.name],
@@ -6742,14 +6735,14 @@ var tableController = ({ data }) => {
6742
6735
  return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
6743
6736
  });
6744
6737
  };
6745
- (0, import_react23.useEffect)(() => {
6738
+ (0, import_react22.useEffect)(() => {
6746
6739
  setRows(transformData(data.records || null));
6747
6740
  }, [data.records]);
6748
6741
  const handleGetColumns = () => {
6749
6742
  let cols = [];
6750
6743
  try {
6751
6744
  cols = mergeFields?.filter((item) => {
6752
- 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);
6745
+ 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);
6753
6746
  })?.map((field) => {
6754
6747
  return {
6755
6748
  name: field?.name,
@@ -6763,7 +6756,7 @@ var tableController = ({ data }) => {
6763
6756
  }
6764
6757
  return cols;
6765
6758
  };
6766
- (0, import_react23.useEffect)(() => {
6759
+ (0, import_react22.useEffect)(() => {
6767
6760
  const columns2 = handleGetColumns();
6768
6761
  setColumns(columns2);
6769
6762
  }, [data.records]);
@@ -6788,9 +6781,9 @@ var tableController = ({ data }) => {
6788
6781
  };
6789
6782
 
6790
6783
  // src/widget/advance/table/table-group/controller.ts
6791
- var import_react24 = require("react");
6792
- var import_hooks17 = require("@fctc/interface-logic/hooks");
6793
- var import_store12 = require("@fctc/interface-logic/store");
6784
+ var import_react23 = require("react");
6785
+ var import_hooks16 = require("@fctc/interface-logic/hooks");
6786
+ var import_store11 = require("@fctc/interface-logic/store");
6794
6787
 
6795
6788
  // src/environment.ts
6796
6789
  var environment_exports = {};
@@ -6817,18 +6810,18 @@ var tableGroupController = (props) => {
6817
6810
  setIsAutoSelect,
6818
6811
  selectedRowKeysRef
6819
6812
  } = props;
6820
- const [pageGroup, setPageGroup] = (0, import_react24.useState)(0);
6821
- const { groupByDomain, selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
6822
- const { selectedRowKeys } = (0, import_store12.useAppSelector)(import_store12.selectList);
6823
- const appDispatch = (0, import_store12.useAppDispatch)();
6824
- const { toDataJS } = (0, import_hooks17.useOdooDataTransform)();
6813
+ const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
6814
+ const { groupByDomain, selectedTags } = (0, import_store11.useAppSelector)(import_store11.selectSearch);
6815
+ const { selectedRowKeys } = (0, import_store11.useAppSelector)(import_store11.selectList);
6816
+ const appDispatch = (0, import_store11.useAppDispatch)();
6817
+ const { toDataJS } = (0, import_hooks16.useOdooDataTransform)();
6825
6818
  const initVal = toDataJS(row, viewData, model);
6826
- const [isShowGroup, setIsShowGroup] = (0, import_react24.useState)(false);
6827
- const [colEmptyGroup, setColEmptyGroup] = (0, import_react24.useState)({
6819
+ const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
6820
+ const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
6828
6821
  fromStart: 1,
6829
6822
  fromEnd: 1
6830
6823
  });
6831
- const processedData = (0, import_react24.useMemo)(() => {
6824
+ const processedData = (0, import_react23.useMemo)(() => {
6832
6825
  const calculateColSpanEmpty = () => {
6833
6826
  const startIndex = columns.findIndex(
6834
6827
  (col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
@@ -6843,7 +6836,7 @@ var tableGroupController = (props) => {
6843
6836
  };
6844
6837
  return calculateColSpanEmpty();
6845
6838
  }, [columns, row]);
6846
- const shouldFetchData = (0, import_react24.useMemo)(() => {
6839
+ const shouldFetchData = (0, import_react23.useMemo)(() => {
6847
6840
  return !!isShowGroup;
6848
6841
  }, [isShowGroup]);
6849
6842
  const enabled = shouldFetchData && !!processedData;
@@ -6868,7 +6861,7 @@ var tableGroupController = (props) => {
6868
6861
  isPlaceholderData,
6869
6862
  isLoading,
6870
6863
  isFetching
6871
- } = (0, import_hooks17.useGetListData)(listDataProps, queryKey, enabled);
6864
+ } = (0, import_hooks16.useGetListData)(listDataProps, queryKey, enabled);
6872
6865
  const {
6873
6866
  columns: columnsGroup,
6874
6867
  rows: rowsGroup,
@@ -6883,7 +6876,7 @@ var tableGroupController = (props) => {
6883
6876
  }
6884
6877
  });
6885
6878
  const leftPadding = level > 1 ? level * 8 + "px" : "0px";
6886
- (0, import_react24.useEffect)(() => {
6879
+ (0, import_react23.useEffect)(() => {
6887
6880
  if (isShowGroup && selectedTags?.length > 0) {
6888
6881
  setIsShowGroup(false);
6889
6882
  }
@@ -6906,24 +6899,24 @@ var tableGroupController = (props) => {
6906
6899
  const filteredIds = selectedRowKeys.filter(
6907
6900
  (id) => !ids.includes(id)
6908
6901
  );
6909
- appDispatch((0, import_store12.setSelectedRowKeys)(filteredIds));
6902
+ appDispatch((0, import_store11.setSelectedRowKeys)(filteredIds));
6910
6903
  } else if (!isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && checkedAll && !allIdsNull && isQueryFetched) {
6911
6904
  const clonedKeys = [...selectedRowKeys];
6912
- appDispatch((0, import_store12.setSelectedRowKeys)([...clonedKeys, -1]));
6913
- setTimeout(() => appDispatch((0, import_store12.setSelectedRowKeys)(clonedKeys)), 500);
6905
+ appDispatch((0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]));
6906
+ setTimeout(() => appDispatch((0, import_store11.setSelectedRowKeys)(clonedKeys)), 500);
6914
6907
  } else if (isShowGroup && selectedRowKeys?.length > 0 && typeTableGroup === "list" && !checkedAll && !allIdsNull) {
6915
6908
  const filteredKeys = selectedRowKeys.filter((id) => id > -1);
6916
- appDispatch((0, import_store12.setSelectedRowKeys)(filteredKeys));
6909
+ appDispatch((0, import_store11.setSelectedRowKeys)(filteredKeys));
6917
6910
  }
6918
6911
  toggleShowGroup();
6919
6912
  };
6920
- (0, import_react24.useEffect)(() => {
6913
+ (0, import_react23.useEffect)(() => {
6921
6914
  if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
6922
6915
  return;
6923
6916
  }
6924
6917
  const clonedKeys = [...selectedRowKeys];
6925
- (0, import_store12.setSelectedRowKeys)([...clonedKeys, -1]);
6926
- setTimeout(() => (0, import_store12.setSelectedRowKeys)(clonedKeys), 500);
6918
+ (0, import_store11.setSelectedRowKeys)([...clonedKeys, -1]);
6919
+ setTimeout(() => (0, import_store11.setSelectedRowKeys)(clonedKeys), 500);
6927
6920
  }, [isQueryFetched]);
6928
6921
  return {
6929
6922
  handleExpandChildGroup,
@@ -6958,23 +6951,25 @@ var tableGroupController = (props) => {
6958
6951
 
6959
6952
  // src/widget/advance/search/controller.ts
6960
6953
  var import_constants5 = require("@fctc/interface-logic/constants");
6961
- var import_utils15 = require("@fctc/interface-logic/utils");
6954
+ var import_utils14 = require("@fctc/interface-logic/utils");
6962
6955
  var import_moment2 = __toESM(require_moment());
6963
- var import_react25 = require("react");
6956
+ var import_react24 = require("react");
6964
6957
  var searchController = ({
6965
6958
  viewData,
6966
6959
  actionData,
6967
- fieldsList,
6968
- contextSearch,
6969
- setSearchMap,
6970
- searchMap
6960
+ fieldsList
6971
6961
  }) => {
6972
- const [filterBy, setFilterBy] = (0, import_react25.useState)(null);
6973
- const [searchBy, setSearchBy] = (0, import_react25.useState)(null);
6974
- const [groupBy, setGroupBy] = (0, import_react25.useState)(null);
6975
- const [selectedTags, setSelectedTags] = (0, import_react25.useState)(null);
6976
- const [searchString, setSearchString] = (0, import_react25.useState)("");
6977
- const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils15.evalJSONDomain)(actionData?.domain, contextSearch) : [];
6962
+ const { env } = (0, provider_exports.useEnv)();
6963
+ const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
6964
+ const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
6965
+ const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
6966
+ const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
6967
+ const [searchString, setSearchString] = (0, import_react24.useState)("");
6968
+ const [searchMap, setSearchMap] = (0, import_react24.useState)({});
6969
+ const { context } = actionData || {};
6970
+ const actionContext = typeof context === "string" ? (0, import_utils14.evalJSONContext)(context) : context;
6971
+ const contextSearch = { ...env.context, ...actionContext };
6972
+ const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils14.evalJSONDomain)(actionData?.domain, contextSearch) : [];
6978
6973
  const aid = actionData?.id;
6979
6974
  const model = actionData?.res_model;
6980
6975
  const clearSearch = () => {
@@ -6991,7 +6986,7 @@ var searchController = ({
6991
6986
  const dataModel = viewData?.models?.[model];
6992
6987
  const searchViews = viewData?.views?.search;
6993
6988
  const searchByItems = searchViews?.search_by?.filter(
6994
- (item) => !import_utils15.domainHelper.matchDomains(contextSearch, item.invisible)
6989
+ (item) => !import_utils14.domainHelper.matchDomains(contextSearch, item.invisible)
6995
6990
  )?.map(
6996
6991
  ({ string, name, filter_domain, operator, widget }, index) => ({
6997
6992
  dataIndex: index,
@@ -7004,10 +6999,10 @@ var searchController = ({
7004
6999
  })
7005
7000
  );
7006
7001
  const filterByItems = searchViews?.filter_by.filter((item) => {
7007
- return !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible);
7002
+ return !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible);
7008
7003
  })?.map((item) => ({ ...item, active: false }));
7009
7004
  const groupByItems = searchViews?.group_by.filter(
7010
- (item) => !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible)
7005
+ (item) => !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible)
7011
7006
  ).map((item) => ({
7012
7007
  ...item,
7013
7008
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -7020,7 +7015,7 @@ var searchController = ({
7020
7015
  }
7021
7016
  }
7022
7017
  };
7023
- (0, import_react25.useEffect)(() => {
7018
+ (0, import_react24.useEffect)(() => {
7024
7019
  clearSearch();
7025
7020
  fetchData();
7026
7021
  }, [aid, model, viewData]);
@@ -7085,14 +7080,14 @@ var searchController = ({
7085
7080
  }
7086
7081
  let valueDomainItem = value?.value;
7087
7082
  if (value?.modelType === "date") {
7088
- valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value);
7083
+ valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value);
7089
7084
  } else if (value?.modelType === "datetime") {
7090
7085
  if (value?.operator === "<=" || value?.operator === "<") {
7091
- const parsedDate = (0, import_utils15.validateAndParseDate)(value?.value, true);
7086
+ const parsedDate = (0, import_utils14.validateAndParseDate)(value?.value, true);
7092
7087
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
7093
7088
  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");
7094
7089
  } else {
7095
- valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value, true);
7090
+ valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value, true);
7096
7091
  }
7097
7092
  }
7098
7093
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -7103,7 +7098,7 @@ var searchController = ({
7103
7098
  return [...domain];
7104
7099
  }
7105
7100
  };
7106
- const setTagSearch = (0, import_react25.useCallback)(
7101
+ const setTagSearch = (0, import_react24.useCallback)(
7107
7102
  (updatedMap) => {
7108
7103
  if (!updatedMap) return;
7109
7104
  const tagsSearch = Object.entries(updatedMap).map(
@@ -7131,16 +7126,16 @@ var searchController = ({
7131
7126
  const contexts = [];
7132
7127
  let groupValues = [];
7133
7128
  objValues?.forEach((objValue) => {
7134
- const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
7129
+ const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
7135
7130
  const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
7136
7131
  contexts.push(
7137
- ...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({ group_by: item })) : [context]
7132
+ ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
7138
7133
  );
7139
7134
  groupValues[indexAppend] = {
7140
7135
  contexts: [
7141
- ...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({
7136
+ ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
7142
7137
  group_by: item
7143
- })) : [context]
7138
+ })) : [context2]
7144
7139
  ],
7145
7140
  strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
7146
7141
  };
@@ -7166,7 +7161,7 @@ var searchController = ({
7166
7161
  },
7167
7162
  [searchMap]
7168
7163
  );
7169
- (0, import_react25.useEffect)(() => {
7164
+ (0, import_react24.useEffect)(() => {
7170
7165
  setSelectedTags(null);
7171
7166
  setTagSearch(searchMap);
7172
7167
  }, [searchMap]);
@@ -7177,21 +7172,21 @@ var searchController = ({
7177
7172
  value,
7178
7173
  type,
7179
7174
  title,
7180
- context,
7175
+ context: context2,
7181
7176
  active,
7182
7177
  dataIndex
7183
7178
  } = tag;
7184
- const domainFormat = new import_utils15.domainHelper.Domain(domain);
7179
+ const domainFormat = new import_utils14.domainHelper.Domain(domain);
7185
7180
  if (type === import_constants5.SearchType.FILTER) {
7186
7181
  addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
7187
7182
  ...tag,
7188
- domain: domain ? domainFormat.toList(context) : null
7183
+ domain: domain ? domainFormat.toList(context2) : null
7189
7184
  });
7190
7185
  } else if (type === import_constants5.SearchType.SEARCH) {
7191
7186
  addSearchItems(`${import_constants5.SearchType.SEARCH}_${String(dataIndex)}`, {
7192
7187
  ...tag,
7193
7188
  domain: domain ? domainFormat.toList({
7194
- ...context,
7189
+ ...context2,
7195
7190
  self: value
7196
7191
  }) : null
7197
7192
  });
@@ -7199,7 +7194,7 @@ var searchController = ({
7199
7194
  addSearchItems(`${import_constants5.SearchType.GROUP}`, {
7200
7195
  ...tag,
7201
7196
  domain: domain ? domainFormat.toList({
7202
- context,
7197
+ context: context2,
7203
7198
  self: value
7204
7199
  }) : null
7205
7200
  });
@@ -7219,7 +7214,8 @@ var searchController = ({
7219
7214
  removeSearchItems,
7220
7215
  onSearchString: onChangeSearchInput,
7221
7216
  handleAddTagSearch,
7222
- domain: formatDomain()
7217
+ domain: formatDomain(),
7218
+ context: contextSearch
7223
7219
  };
7224
7220
  };
7225
7221
  // Annotate the CommonJS export names for ESM import in node: