@fctc/widget-logic 2.0.7 → 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/widget.mjs CHANGED
@@ -4978,7 +4978,6 @@ var many2oneFieldController = (props) => {
4978
4978
  options: fieldOptions,
4979
4979
  showDetail
4980
4980
  } = props;
4981
- const { env } = (0, provider_exports.useEnv)();
4982
4981
  const [options, setOptions] = useState7([]);
4983
4982
  const [inputValue, setInputValue] = useState7("");
4984
4983
  const [debouncedInputValue] = useDebounce(inputValue, 1e3);
@@ -4988,14 +4987,15 @@ var many2oneFieldController = (props) => {
4988
4987
  const [domainObject, setDomainObject] = useState7(null);
4989
4988
  const actionData = sessionStorageUtils.getActionData();
4990
4989
  const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
4990
+ const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
4991
4991
  const initValue = methods?.getValues(name);
4992
4992
  const optionsObject = (0, utils_exports.evalJSONContext)(fieldOptions) || {};
4993
4993
  const contextObject = {
4994
4994
  ...(0, utils_exports.evalJSONContext)(actionData?.context) || {},
4995
4995
  ...fieldContext,
4996
- ...env?.context
4996
+ ...context
4997
4997
  };
4998
- const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
4998
+ const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
4999
4999
  const data = {
5000
5000
  model: relation,
5001
5001
  domain: domainObject,
@@ -5011,7 +5011,7 @@ var many2oneFieldController = (props) => {
5011
5011
  data: dataOfSelection,
5012
5012
  refetch,
5013
5013
  isFetching
5014
- } = useGetSelection3({
5014
+ } = useGetSelection2({
5015
5015
  data,
5016
5016
  queryKey,
5017
5017
  enabled: false
@@ -5165,9 +5165,15 @@ var many2oneButtonController = (props) => {
5165
5165
 
5166
5166
  // src/widget/basic/many2many-field/controller.ts
5167
5167
  import { useEffect as useEffect11, useMemo as useMemo10, useState as useState8 } from "react";
5168
+ import {
5169
+ useAppDispatch as useAppDispatch5,
5170
+ setFirstDomain,
5171
+ setViewDataStore,
5172
+ setPage,
5173
+ setGroupByDomain
5174
+ } from "@fctc/interface-logic/store";
5168
5175
  import {
5169
5176
  evalJSONContext as evalJSONContext4,
5170
- evalJSONDomain as evalJSONDomain4,
5171
5177
  formatSortingString as formatSortingString2
5172
5178
  } from "@fctc/interface-logic/utils";
5173
5179
  var many2manyFieldController = (props) => {
@@ -5175,43 +5181,45 @@ var many2manyFieldController = (props) => {
5175
5181
  relation,
5176
5182
  domain,
5177
5183
  context,
5178
- options,
5179
5184
  tab,
5185
+ model,
5186
+ aid,
5180
5187
  setSelectedRowKeys: setSelectedRowKeys4,
5188
+ fields,
5189
+ setFields,
5181
5190
  groupByDomain,
5182
- enabled: enabledCallAPI,
5183
- actionData
5191
+ page,
5192
+ options,
5193
+ sessionStorageUtils
5184
5194
  } = props;
5195
+ const appDispatch = useAppDispatch5();
5196
+ const actionData = sessionStorageUtils.getActionData();
5197
+ const [debouncedPage] = useDebounce(page, 500);
5198
+ const [order, setOrder] = useState8();
5199
+ const [isLoadedData, setIsLoadedData] = useState8(false);
5200
+ const [domainMany2Many, setDomainMany2Many] = useState8(domain);
5185
5201
  const { env } = (0, provider_exports.useEnv)();
5186
5202
  const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
5187
- const [order, setOrder] = useState8();
5188
- const [page, setPage] = useState8(0);
5189
- const [domainMany2Many, setDomainMany2Many] = useState8(null);
5190
- const [debouncedPage] = useDebounce(page, 500);
5191
- const contextObject = {
5192
- ...env.context,
5193
- ...context || {}
5194
- };
5195
5203
  const viewParams = {
5196
5204
  model: relation,
5197
5205
  views: [
5198
5206
  [false, "list"],
5199
5207
  [false, "search"]
5200
5208
  ],
5201
- context: contextObject
5209
+ context
5202
5210
  };
5203
- const { data: viewResponse } = useGetView2(viewParams, enabledCallAPI);
5211
+ const { data: viewResponse } = useGetView2(viewParams, actionData);
5204
5212
  const baseModel = useMemo10(
5205
5213
  () => ({
5206
5214
  name: String(relation),
5207
5215
  view: viewResponse || {},
5208
- actContext: contextObject,
5216
+ actContext: context,
5209
5217
  fields: [
5210
5218
  ...Object.values(viewResponse?.views?.list?.fields ?? {}),
5211
5219
  ...tab?.fields ? tab.fields : []
5212
5220
  ]
5213
5221
  }),
5214
- [relation, viewResponse]
5222
+ [model, viewResponse]
5215
5223
  );
5216
5224
  const initModel = (0, hooks_exports.useModel)();
5217
5225
  const modelInstance = useMemo10(() => {
@@ -5230,15 +5238,26 @@ var many2manyFieldController = (props) => {
5230
5238
  const optionsObject = tab?.options ? evalJSONContext4(tab?.options) : (options ? evalJSONContext4(options) : {}) || {};
5231
5239
  const fetchData = async () => {
5232
5240
  try {
5233
- const domainParse = typeof domain === "string" ? evalJSONDomain4(domain, contextObject) : Array.isArray(domain) ? domain : [];
5234
- setDomainMany2Many(domainParse);
5235
- setPage(0);
5241
+ setDomainMany2Many(domain);
5242
+ appDispatch(setFirstDomain(domain));
5243
+ appDispatch(setViewDataStore(viewResponse));
5244
+ const modalData = viewResponse?.views?.list?.fields.map((field) => ({
5245
+ ...viewResponse?.models?.[String(model)]?.[field?.name],
5246
+ ...field
5247
+ }));
5248
+ if (!fields?.[`${aid}_${relation}_popupmany2many`] && modalData) {
5249
+ setFields({
5250
+ ...fields,
5251
+ [`${aid}_${relation}_popupmany2many`]: modalData
5252
+ });
5253
+ }
5254
+ appDispatch(setPage(0));
5236
5255
  } catch (err) {
5237
5256
  console.log(err);
5238
5257
  }
5239
5258
  };
5240
5259
  const queryKey = [
5241
- `view-${relation}`,
5260
+ `view-${relation}-${aid}`,
5242
5261
  specification,
5243
5262
  domainMany2Many,
5244
5263
  debouncedPage,
@@ -5251,16 +5270,16 @@ var many2manyFieldController = (props) => {
5251
5270
  domain: domainMany2Many,
5252
5271
  offset: debouncedPage * 10,
5253
5272
  limit: 10,
5254
- context: contextObject,
5273
+ context,
5255
5274
  fields: groupByDomain?.fields,
5256
5275
  groupby: [groupByDomain?.contexts[0]?.group_by],
5257
5276
  sort: order ? order : default_order ? formatSortingString2(default_order) : ""
5258
5277
  };
5259
- const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
5278
+ const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
5260
5279
  const {
5261
5280
  data: dataResponse,
5262
- isLoading,
5263
- isFetched,
5281
+ isLoading: isDataLoading,
5282
+ isFetched: isDataResponseFetched,
5264
5283
  isPlaceholderData
5265
5284
  } = useGetListData3(data, queryKey, enabled);
5266
5285
  useEffect11(() => {
@@ -5268,59 +5287,74 @@ var many2manyFieldController = (props) => {
5268
5287
  fetchData();
5269
5288
  }
5270
5289
  return () => {
5271
- setPage(0);
5290
+ appDispatch(setGroupByDomain(null));
5291
+ setFields((prevFields) => ({
5292
+ ...prevFields,
5293
+ [`${aid}_${relation}_popupmany2many`]: null
5294
+ }));
5295
+ appDispatch(setPage(0));
5272
5296
  setSelectedRowKeys4([]);
5273
5297
  setDomainMany2Many(null);
5298
+ setIsLoadedData(false);
5274
5299
  };
5275
5300
  }, [viewResponse]);
5276
- const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
5301
+ const { rows, columns, typeTable } = tableController({
5277
5302
  data: {
5278
- fields: viewResponse?.views?.list?.fields,
5303
+ fields: fields?.[`${aid}_${relation}_popupmany2many`] || viewResponse?.views?.list?.fields,
5279
5304
  records: dataResponse?.records ?? dataResponse?.groups,
5280
5305
  dataModel: viewResponse?.models?.[String(relation)],
5281
- context: contextObject,
5306
+ context: { ...env.context, ...context },
5282
5307
  typeTable: dataResponse?.groups ? "group" : "list"
5283
5308
  }
5284
5309
  });
5285
- const searchControllers = searchController({
5286
- viewData: viewResponse,
5287
- model: relation ?? "",
5288
- context: contextObject,
5289
- domain,
5290
- fieldsList: [
5291
- ...columns?.filter(
5292
- (col) => col?.field?.type_co === "field" && col?.optional !== "hide"
5293
- )?.map((col) => ({ ...col.field })) ?? []
5294
- ]
5310
+ const dataFormView = {
5311
+ id: null,
5312
+ model: relation,
5313
+ context
5314
+ };
5315
+ const {
5316
+ refetch,
5317
+ data: dataFormViewResponse,
5318
+ isSuccess
5319
+ } = useGetFormView({
5320
+ data: dataFormView,
5321
+ queryKey: [`form-view-action-${relation}`],
5322
+ enabled: false
5295
5323
  });
5324
+ useEffect11(() => {
5325
+ if (isSuccess && dataFormViewResponse) {
5326
+ sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
5327
+ window.location.href = `/form/menu?model=${relation}`;
5328
+ }
5329
+ }, [isSuccess]);
5330
+ useEffect11(() => {
5331
+ if (domainMany2Many && !isLoadedData) {
5332
+ setIsLoadedData(true);
5333
+ }
5334
+ }, [domainMany2Many]);
5296
5335
  const handleCreateNewOnPage = async () => {
5336
+ try {
5337
+ refetch();
5338
+ } catch (error) {
5339
+ console.log(error);
5340
+ }
5297
5341
  };
5298
5342
  return {
5299
5343
  handleCreateNewOnPage,
5300
5344
  optionsObject,
5301
- totalRows: dataResponse?.length ?? 0,
5302
5345
  rows,
5303
5346
  columns,
5304
- onToggleColumnOptional,
5305
5347
  typeTable,
5306
- isLoading,
5307
- isFetched,
5308
- isPlaceholderData,
5309
- setPage,
5310
- page,
5311
- viewData: viewResponse,
5312
- domain: domainMany2Many,
5313
- setDomain: setDomainMany2Many,
5314
- searchController: searchControllers
5348
+ isDataLoading,
5349
+ isDataResponseFetched,
5350
+ isPlaceholderData
5315
5351
  };
5316
5352
  };
5317
5353
 
5318
5354
  // src/widget/basic/many2many-tags-field/controller.ts
5319
5355
  import { useMemo as useMemo11 } from "react";
5320
5356
  import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
5321
- import { getEnv as getEnv7 } from "@fctc/interface-logic/environment";
5322
- import { useGetSelection as useGetSelection2 } from "@fctc/interface-logic/hooks";
5323
- import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
5357
+ import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain4 } from "@fctc/interface-logic/utils";
5324
5358
  var many2manyTagsController = (props) => {
5325
5359
  const {
5326
5360
  relation,
@@ -5331,10 +5365,11 @@ var many2manyTagsController = (props) => {
5331
5365
  placeholderNoOption
5332
5366
  } = props;
5333
5367
  const isUser = relation === "res.users" || relation === "res.partner";
5334
- const env = getEnv7();
5368
+ const { env } = (0, provider_exports.useEnv)();
5369
+ const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
5335
5370
  const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
5336
5371
  const domainObject = useMemo11(
5337
- () => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
5372
+ () => evalJSONDomain4(domain, JSON.parse(JSON.stringify(formValues || {}))),
5338
5373
  [domain, formValues]
5339
5374
  );
5340
5375
  const data = {
@@ -5370,16 +5405,15 @@ var many2manyTagsController = (props) => {
5370
5405
  options,
5371
5406
  customNoOptionsMessage,
5372
5407
  tranfer,
5373
- dataOfSelection,
5374
5408
  isUser
5375
5409
  };
5376
5410
  };
5377
5411
 
5378
5412
  // src/widget/basic/status-bar-field/controller.ts
5379
5413
  import { useState as useState9 } from "react";
5380
- import { evalJSONDomain as evalJSONDomain6 } from "@fctc/interface-logic/utils";
5414
+ import { evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
5381
5415
  var durationController = (props) => {
5382
- const { relation, domain, formValues, name, id, model, onRefetch } = props;
5416
+ const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
5383
5417
  const specification = {
5384
5418
  id: 0,
5385
5419
  name: "",
@@ -5393,7 +5427,7 @@ var durationController = (props) => {
5393
5427
  const listDataProps = {
5394
5428
  model: relation,
5395
5429
  specification,
5396
- domain: evalJSONDomain6(domain, JSON.parse(JSON.stringify(formValues))),
5430
+ domain: evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues))),
5397
5431
  limit: 10,
5398
5432
  offset: 0,
5399
5433
  fields: "",
@@ -5403,7 +5437,11 @@ var durationController = (props) => {
5403
5437
  },
5404
5438
  sort: ""
5405
5439
  };
5406
- const { data: dataResponse } = useGetListData3(listDataProps, queryKey);
5440
+ const { data: dataResponse } = useGetListData3(
5441
+ listDataProps,
5442
+ queryKey,
5443
+ enabled
5444
+ );
5407
5445
  const { mutate: fetchChangeStatus } = useChangeStatus();
5408
5446
  const handleClick = async (stage_id) => {
5409
5447
  setDisabled(true);
@@ -5439,32 +5477,18 @@ var durationController = (props) => {
5439
5477
  };
5440
5478
 
5441
5479
  // src/widget/basic/priority-field/controller.ts
5442
- import { useSave as useSave2 } from "@fctc/interface-logic/hooks";
5443
5480
  import { evalJSONContext as evalJSONContext6 } from "@fctc/interface-logic/utils";
5444
5481
  var priorityFieldController = (props) => {
5445
- const {
5446
- value,
5447
- isForm,
5448
- name,
5449
- methods,
5450
- onChange,
5451
- model,
5452
- selection,
5453
- id,
5454
- actionData,
5455
- viewData,
5456
- context
5457
- } = props;
5482
+ const { name, model, id, actionData, context, onChange } = props;
5458
5483
  const _context = { ...evalJSONContext6(actionData?.context) };
5459
5484
  const contextObject = { ...context, ..._context };
5460
- const defaultPriority = parseInt(value) + 1;
5461
- const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
5485
+ const { useSave: useSave2 } = (0, provider_exports.useService)();
5462
5486
  const { mutateAsync: fetchSave } = useSave2();
5463
5487
  const savePriorities = async ({
5464
- value: value2,
5488
+ value,
5465
5489
  resetPriority
5466
5490
  }) => {
5467
- const priorityValue = value2 <= 0 ? 0 : value2 - 1;
5491
+ const priorityValue = value <= 0 ? 0 : value - 1;
5468
5492
  try {
5469
5493
  fetchSave({
5470
5494
  ids: id ? [id] : [],
@@ -5482,14 +5506,7 @@ var priorityFieldController = (props) => {
5482
5506
  }
5483
5507
  };
5484
5508
  return {
5485
- selection,
5486
- isForm,
5487
- methods,
5488
- defaultPriority,
5489
- savePriorities,
5490
- label,
5491
- id,
5492
- onChange
5509
+ savePriorities
5493
5510
  };
5494
5511
  };
5495
5512
 
@@ -6452,11 +6469,11 @@ import { evalJSONContext as evalJSONContext7 } from "@fctc/interface-logic/utils
6452
6469
  var colorFieldController = (props) => {
6453
6470
  const { value, isForm, name, formValues, idForm, model, actionData } = props;
6454
6471
  const { env } = (0, provider_exports.useEnv)();
6455
- const { useSave: useSave3 } = (0, provider_exports.useService)();
6472
+ const { useSave: useSave2 } = (0, provider_exports.useService)();
6456
6473
  const _context = { ...evalJSONContext7(actionData?.context) || {} };
6457
6474
  const contextObject = { ...env.context, ..._context };
6458
6475
  const idDefault = isForm ? idForm : formValues?.id;
6459
- const { mutate: onSave } = useSave3();
6476
+ const { mutate: onSave } = useSave2();
6460
6477
  const savePickColor = async (colorObject) => {
6461
6478
  const { id } = colorObject;
6462
6479
  if (value === id) return;
@@ -6579,20 +6596,25 @@ var binaryFieldController = (props) => {
6579
6596
  };
6580
6597
 
6581
6598
  // src/widget/advance/table/table-body/controller.ts
6582
- import { useAppDispatch as useAppDispatch5, setSelectedRowKeys } from "@fctc/interface-logic/store";
6599
+ import {
6600
+ useAppDispatch as useAppDispatch6,
6601
+ setSelectedRowKeys,
6602
+ useAppSelector as useAppSelector4,
6603
+ selectList as selectList3
6604
+ } from "@fctc/interface-logic/store";
6583
6605
  import { useEffect as useEffect13, useMemo as useMemo12 } from "react";
6584
6606
  var tableBodyController = (props) => {
6585
6607
  const {
6586
6608
  checkedAll,
6587
6609
  checkboxRef,
6588
6610
  setIsAutoSelect,
6589
- selectedRowKeys,
6590
6611
  row,
6591
6612
  isAutoSelect,
6592
6613
  selectedRowKeysRef,
6593
6614
  onClickRow
6594
6615
  } = props;
6595
- const appDispatch = useAppDispatch5();
6616
+ const appDispatch = useAppDispatch6();
6617
+ const { selectedRowKeys } = useAppSelector4(selectList3);
6596
6618
  const checked = useMemo12(() => {
6597
6619
  if (!row?.id) return false;
6598
6620
  if (selectedRowKeys?.includes(row.id)) {
@@ -6608,7 +6630,6 @@ var tableBodyController = (props) => {
6608
6630
  return;
6609
6631
  }
6610
6632
  const newSelectedRowKeys = selectedRowKeys?.includes(row.id) ? selectedRowKeys?.filter((key) => key !== row.id) : [...selectedRowKeys, row.id];
6611
- console.log("newSelectedRowKeys", newSelectedRowKeys);
6612
6633
  appDispatch(setSelectedRowKeys(newSelectedRowKeys));
6613
6634
  };
6614
6635
  const handleClickRow = (col, row2) => {
@@ -6647,15 +6668,15 @@ var tableBodyController = (props) => {
6647
6668
 
6648
6669
  // src/widget/advance/table/table-head/controller.ts
6649
6670
  import {
6650
- useAppDispatch as useAppDispatch6,
6651
- useAppSelector as useAppSelector4,
6671
+ useAppDispatch as useAppDispatch7,
6672
+ useAppSelector as useAppSelector5,
6652
6673
  selectSearch as selectSearch3,
6653
6674
  setSelectedRowKeys as setSelectedRowKeys2
6654
6675
  } from "@fctc/interface-logic/store";
6655
6676
  var tableHeadController = (props) => {
6656
6677
  const { typeTable, rows, selectedRowKeysRef } = props;
6657
- const appDispatch = useAppDispatch6();
6658
- const { groupByDomain } = useAppSelector4(selectSearch3);
6678
+ const appDispatch = useAppDispatch7();
6679
+ const { groupByDomain } = useAppSelector5(selectSearch3);
6659
6680
  const handleCheckBoxAll = (event) => {
6660
6681
  if (event?.target?.checked && typeTable === "list") {
6661
6682
  const allRowKeys = Array.isArray(rows) ? rows.map((record) => record?.id) : [];
@@ -6690,9 +6711,9 @@ var tableHeadController = (props) => {
6690
6711
  // src/widget/advance/table/table-view/controller.ts
6691
6712
  import { useEffect as useEffect14, useMemo as useMemo13, useRef as useRef5, useState as useState13 } from "react";
6692
6713
  import {
6693
- useAppSelector as useAppSelector5,
6714
+ useAppSelector as useAppSelector6,
6694
6715
  selectSearch as selectSearch4,
6695
- selectList as selectList3
6716
+ selectList as selectList4
6696
6717
  } from "@fctc/interface-logic/store";
6697
6718
  import { domainHelper } from "@fctc/interface-logic/utils";
6698
6719
  var tableController = ({ data }) => {
@@ -6777,10 +6798,10 @@ import {
6777
6798
  useGetListData as useGetListData2
6778
6799
  } from "@fctc/interface-logic/hooks";
6779
6800
  import {
6780
- useAppSelector as useAppSelector6,
6801
+ useAppSelector as useAppSelector7,
6781
6802
  selectSearch as selectSearch5,
6782
- selectList as selectList4,
6783
- useAppDispatch as useAppDispatch7,
6803
+ selectList as selectList5,
6804
+ useAppDispatch as useAppDispatch8,
6784
6805
  setSelectedRowKeys as setSelectedRowKeys3
6785
6806
  } from "@fctc/interface-logic/store";
6786
6807
 
@@ -6811,9 +6832,9 @@ var tableGroupController = (props) => {
6811
6832
  selectedRowKeysRef
6812
6833
  } = props;
6813
6834
  const [pageGroup, setPageGroup] = useState14(0);
6814
- const { groupByDomain, selectedTags } = useAppSelector6(selectSearch5);
6815
- const { selectedRowKeys } = useAppSelector6(selectList4);
6816
- const appDispatch = useAppDispatch7();
6835
+ const { groupByDomain, selectedTags } = useAppSelector7(selectSearch5);
6836
+ const { selectedRowKeys } = useAppSelector7(selectList5);
6837
+ const appDispatch = useAppDispatch8();
6817
6838
  const { toDataJS } = useOdooDataTransform();
6818
6839
  const initVal = toDataJS(row, viewData, model);
6819
6840
  const [isShowGroup, setIsShowGroup] = useState14(false);
@@ -6954,28 +6975,26 @@ var import_moment2 = __toESM(require_moment());
6954
6975
  import { SearchType } from "@fctc/interface-logic/constants";
6955
6976
  import {
6956
6977
  domainHelper as domainHelper2,
6957
- evalJSONContext as evalJSONContext8,
6958
- evalJSONDomain as evalJSONDomain7,
6978
+ evalJSONDomain as evalJSONDomain6,
6959
6979
  validateAndParseDate
6960
6980
  } from "@fctc/interface-logic/utils";
6961
6981
  import { useCallback as useCallback3, useEffect as useEffect16, useState as useState15 } from "react";
6962
6982
  var searchController = ({
6963
6983
  viewData,
6964
- model,
6965
- domain,
6966
- context,
6967
- fieldsList
6984
+ actionData,
6985
+ fieldsList,
6986
+ contextSearch,
6987
+ setSearchMap,
6988
+ searchMap
6968
6989
  }) => {
6969
- const { env } = (0, provider_exports.useEnv)();
6970
6990
  const [filterBy, setFilterBy] = useState15(null);
6971
6991
  const [searchBy, setSearchBy] = useState15(null);
6972
6992
  const [groupBy, setGroupBy] = useState15(null);
6973
6993
  const [selectedTags, setSelectedTags] = useState15(null);
6974
6994
  const [searchString, setSearchString] = useState15("");
6975
- const [searchMap, setSearchMap] = useState15({});
6976
- const actionContext = typeof context === "string" ? evalJSONContext8(context) : context;
6977
- const contextSearch = { ...env.context, ...actionContext };
6978
- const domainAction = domain ? Array.isArray(domain) ? [...domain] : evalJSONDomain7(domain, contextSearch) : [];
6995
+ const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : evalJSONDomain6(actionData?.domain, contextSearch) : [];
6996
+ const aid = actionData?.id;
6997
+ const model = actionData?.res_model;
6979
6998
  const clearSearch = () => {
6980
6999
  setFilterBy([]);
6981
7000
  setGroupBy([]);
@@ -7020,8 +7039,9 @@ var searchController = ({
7020
7039
  }
7021
7040
  };
7022
7041
  useEffect16(() => {
7042
+ clearSearch();
7023
7043
  fetchData();
7024
- }, [model, viewData]);
7044
+ }, [aid, model, viewData]);
7025
7045
  const onChangeSearchInput = (search_string) => {
7026
7046
  setSearchString(search_string);
7027
7047
  };
@@ -7058,28 +7078,27 @@ var searchController = ({
7058
7078
  };
7059
7079
  const formatDomain = () => {
7060
7080
  if (domainAction) {
7061
- console.log("domainAction", domainAction);
7062
- const domain2 = [];
7081
+ const domain = [];
7063
7082
  if (domainAction?.length > 0) {
7064
7083
  if (Object.keys(searchMap).length > 0) {
7065
- domain2.push("&");
7084
+ domain.push("&");
7066
7085
  }
7067
7086
  domainAction.forEach((domainItem) => {
7068
- domain2.push(domainItem);
7087
+ domain.push(domainItem);
7069
7088
  });
7070
7089
  }
7071
7090
  Object.keys(searchMap).forEach((key, keyIndex, keys) => {
7072
7091
  if (!key?.includes(SearchType.GROUP)) {
7073
7092
  if (keys.length > 1 && keyIndex < keys.length - 1) {
7074
- domain2.push("&");
7093
+ domain.push("&");
7075
7094
  }
7076
7095
  const valuesOfKey = searchMap[key];
7077
7096
  valuesOfKey.forEach((value, index) => {
7078
7097
  if (index < valuesOfKey.length - 1) {
7079
- domain2.push("|");
7098
+ domain.push("|");
7080
7099
  }
7081
7100
  if (value.domain) {
7082
- domain2.push(...value.domain);
7101
+ domain.push(...value.domain);
7083
7102
  return;
7084
7103
  }
7085
7104
  let valueDomainItem = value?.value;
@@ -7095,11 +7114,11 @@ var searchController = ({
7095
7114
  }
7096
7115
  }
7097
7116
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
7098
- domain2.push([value.name, operator, valueDomainItem]);
7117
+ domain.push([value.name, operator, valueDomainItem]);
7099
7118
  });
7100
7119
  }
7101
7120
  });
7102
- return [...domain2];
7121
+ return [...domain];
7103
7122
  }
7104
7123
  };
7105
7124
  const setTagSearch = useCallback3(
@@ -7130,16 +7149,16 @@ var searchController = ({
7130
7149
  const contexts = [];
7131
7150
  let groupValues = [];
7132
7151
  objValues?.forEach((objValue) => {
7133
- const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
7152
+ const { context, value, active, groupIndex: groupIndex2, isDefault } = objValue;
7134
7153
  const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
7135
7154
  contexts.push(
7136
- ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
7155
+ ...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({ group_by: item })) : [context]
7137
7156
  );
7138
7157
  groupValues[indexAppend] = {
7139
7158
  contexts: [
7140
- ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
7159
+ ...Array.isArray(context?.group_by) ? context.group_by.map((item) => ({
7141
7160
  group_by: item
7142
- })) : [context2]
7161
+ })) : [context]
7143
7162
  ],
7144
7163
  strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
7145
7164
  };
@@ -7166,38 +7185,39 @@ var searchController = ({
7166
7185
  [searchMap]
7167
7186
  );
7168
7187
  useEffect16(() => {
7188
+ setSelectedTags(null);
7169
7189
  setTagSearch(searchMap);
7170
7190
  }, [searchMap]);
7171
7191
  const handleAddTagSearch = (tag) => {
7172
7192
  const {
7173
- domain: domain2,
7193
+ domain,
7174
7194
  groupIndex,
7175
7195
  value,
7176
7196
  type,
7177
7197
  title,
7178
- context: context2,
7198
+ context,
7179
7199
  active,
7180
7200
  dataIndex
7181
7201
  } = tag;
7182
- const domainFormat = new domainHelper2.Domain(domain2);
7202
+ const domainFormat = new domainHelper2.Domain(domain);
7183
7203
  if (type === SearchType.FILTER) {
7184
7204
  addSearchItems(`${SearchType.FILTER}_${groupIndex}`, {
7185
7205
  ...tag,
7186
- domain: domain2 ? domainFormat.toList(context2) : null
7206
+ domain: domain ? domainFormat.toList(context) : null
7187
7207
  });
7188
7208
  } else if (type === SearchType.SEARCH) {
7189
7209
  addSearchItems(`${SearchType.SEARCH}_${String(dataIndex)}`, {
7190
7210
  ...tag,
7191
- domain: domain2 ? domainFormat.toList({
7192
- ...context2,
7211
+ domain: domain ? domainFormat.toList({
7212
+ ...context,
7193
7213
  self: value
7194
7214
  }) : null
7195
7215
  });
7196
7216
  } else if (type === SearchType.GROUP) {
7197
7217
  addSearchItems(`${SearchType.GROUP}`, {
7198
7218
  ...tag,
7199
- domain: domain2 ? domainFormat.toList({
7200
- context: context2,
7219
+ domain: domain ? domainFormat.toList({
7220
+ context,
7201
7221
  self: value
7202
7222
  }) : null
7203
7223
  });
@@ -7217,8 +7237,7 @@ var searchController = ({
7217
7237
  removeSearchItems,
7218
7238
  onSearchString: onChangeSearchInput,
7219
7239
  handleAddTagSearch,
7220
- domain: formatDomain(),
7221
- context: contextSearch
7240
+ domain: formatDomain()
7222
7241
  };
7223
7242
  };
7224
7243
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/widget-logic",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",