@fctc/widget-logic 1.10.1 → 1.10.2

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/index.js CHANGED
@@ -4862,32 +4862,8 @@ var useAppProvider = () => {
4862
4862
  return context;
4863
4863
  };
4864
4864
 
4865
- // src/hooks/core/use-menu-item.tsx
4866
- var import_environment5 = require("@fctc/interface-logic/environment");
4867
- var import_hooks9 = require("@fctc/interface-logic/hooks");
4868
- var import_react11 = require("react");
4869
-
4870
- // src/utils.ts
4871
- var utils_exports = {};
4872
- __export(utils_exports, {
4873
- API_APP_URL: () => API_APP_URL,
4874
- API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
4875
- STORAGES: () => STORAGES,
4876
- combineContexts: () => combineContexts,
4877
- convertFieldsToArray: () => convertFieldsToArray,
4878
- countSum: () => countSum,
4879
- getDateRange: () => getDateRange,
4880
- languages: () => languages,
4881
- mergeButtons: () => mergeButtons,
4882
- setStorageItemAsync: () => setStorageItemAsync,
4883
- useGetRowIds: () => useGetRowIds,
4884
- useSelectionState: () => useSelectionState,
4885
- useStorageState: () => useStorageState
4886
- });
4887
- __reExport(utils_exports, require("@fctc/interface-logic/utils"));
4888
-
4889
4865
  // src/hooks/utils/use-click-outside.ts
4890
- var import_react12 = require("react");
4866
+ var import_react11 = require("react");
4891
4867
  var DEFAULT_EVENTS = ["mousedown", "touchstart"];
4892
4868
  var useClickOutside = ({
4893
4869
  handler,
@@ -4895,8 +4871,8 @@ var useClickOutside = ({
4895
4871
  nodes = [],
4896
4872
  refs
4897
4873
  }) => {
4898
- const ref = (0, import_react12.useRef)(null);
4899
- (0, import_react12.useEffect)(() => {
4874
+ const ref = (0, import_react11.useRef)(null);
4875
+ (0, import_react11.useEffect)(() => {
4900
4876
  const listener = (event) => {
4901
4877
  const { target } = event;
4902
4878
  if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
@@ -4918,10 +4894,10 @@ var useClickOutside = ({
4918
4894
  };
4919
4895
 
4920
4896
  // src/hooks/utils/use-debounce.ts
4921
- var import_react13 = require("react");
4897
+ var import_react12 = require("react");
4922
4898
  function useDebounce(value, delay) {
4923
- const [debouncedValue, setDebouncedValue] = (0, import_react13.useState)(value);
4924
- (0, import_react13.useEffect)(() => {
4899
+ const [debouncedValue, setDebouncedValue] = (0, import_react12.useState)(value);
4900
+ (0, import_react12.useEffect)(() => {
4925
4901
  const handler = setTimeout(() => {
4926
4902
  setDebouncedValue(value);
4927
4903
  }, delay);
@@ -5176,20 +5152,20 @@ var ChevronBottomIcon = ({
5176
5152
  };
5177
5153
 
5178
5154
  // src/widget/basic/status-dropdown-field/controller.ts
5179
- var import_react14 = require("react");
5180
- var import_environment6 = require("@fctc/interface-logic/environment");
5181
- var import_hooks11 = require("@fctc/interface-logic/hooks");
5155
+ var import_react13 = require("react");
5156
+ var import_environment5 = require("@fctc/interface-logic/environment");
5157
+ var import_hooks10 = require("@fctc/interface-logic/hooks");
5182
5158
  var statusDropdownController = (props) => {
5183
5159
  const { selection, isForm, id, model, name, state, onRefetch } = props;
5184
- const env = (0, import_environment6.getEnv)();
5160
+ const env = (0, import_environment5.getEnv)();
5185
5161
  const colors = {
5186
5162
  normal: "bg-[#e9ecef]",
5187
5163
  done: "bg-primary",
5188
5164
  blocked: "bg-red-500"
5189
5165
  };
5190
- const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
5191
- const buttonRef = (0, import_react14.useRef)(null);
5192
- (0, import_react14.useEffect)(() => {
5166
+ const [isOpen, setIsOpen] = (0, import_react13.useState)(false);
5167
+ const buttonRef = (0, import_react13.useRef)(null);
5168
+ (0, import_react13.useEffect)(() => {
5193
5169
  const handleClickOutside = (event) => {
5194
5170
  if (buttonRef.current && !buttonRef.current.contains(event.target)) {
5195
5171
  setIsOpen(false);
@@ -5200,7 +5176,7 @@ var statusDropdownController = (props) => {
5200
5176
  document.removeEventListener("mousedown", handleClickOutside);
5201
5177
  };
5202
5178
  }, []);
5203
- const { mutate: onSave } = (0, import_hooks11.useSave)();
5179
+ const { mutate: onSave } = (0, import_hooks10.useSave)();
5204
5180
  const handleClick = async (status) => {
5205
5181
  setIsOpen(!isOpen);
5206
5182
  onSave(
@@ -5230,7 +5206,26 @@ var statusDropdownController = (props) => {
5230
5206
  };
5231
5207
 
5232
5208
  // src/widget/basic/many2one-field/controller.ts
5233
- var import_react15 = require("react");
5209
+ var import_react14 = require("react");
5210
+
5211
+ // src/utils.ts
5212
+ var utils_exports = {};
5213
+ __export(utils_exports, {
5214
+ API_APP_URL: () => API_APP_URL,
5215
+ API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
5216
+ STORAGES: () => STORAGES,
5217
+ combineContexts: () => combineContexts,
5218
+ convertFieldsToArray: () => convertFieldsToArray,
5219
+ countSum: () => countSum,
5220
+ getDateRange: () => getDateRange,
5221
+ languages: () => languages,
5222
+ mergeButtons: () => mergeButtons,
5223
+ setStorageItemAsync: () => setStorageItemAsync,
5224
+ useGetRowIds: () => useGetRowIds,
5225
+ useSelectionState: () => useSelectionState,
5226
+ useStorageState: () => useStorageState
5227
+ });
5228
+ __reExport(utils_exports, require("@fctc/interface-logic/utils"));
5234
5229
 
5235
5230
  // src/provider.ts
5236
5231
  var provider_exports = {};
@@ -5251,13 +5246,13 @@ var many2oneFieldController = (props) => {
5251
5246
  options: fieldOptions,
5252
5247
  showDetail
5253
5248
  } = props;
5254
- const [options, setOptions] = (0, import_react15.useState)([]);
5255
- const [inputValue, setInputValue] = (0, import_react15.useState)("");
5249
+ const [options, setOptions] = (0, import_react14.useState)([]);
5250
+ const [inputValue, setInputValue] = (0, import_react14.useState)("");
5256
5251
  const [debouncedInputValue] = useDebounce(inputValue, 1e3);
5257
- const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react15.useState)(false);
5258
- const [tempSelectedOption, setTempSelectedOption] = (0, import_react15.useState)(null);
5259
- const [domainModal, setDomainModal] = (0, import_react15.useState)(null);
5260
- const [domainObject, setDomainObject] = (0, import_react15.useState)(null);
5252
+ const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react14.useState)(false);
5253
+ const [tempSelectedOption, setTempSelectedOption] = (0, import_react14.useState)(null);
5254
+ const [domainModal, setDomainModal] = (0, import_react14.useState)(null);
5255
+ const [domainObject, setDomainObject] = (0, import_react14.useState)(null);
5261
5256
  const actionData = sessionStorageUtils.getActionData();
5262
5257
  const { menuList } = (0, store_exports.useAppSelector)(store_exports.selectNavbar);
5263
5258
  const { context } = (0, store_exports.useAppSelector)(store_exports.selectEnv);
@@ -5268,7 +5263,7 @@ var many2oneFieldController = (props) => {
5268
5263
  ...fieldContext,
5269
5264
  ...context
5270
5265
  };
5271
- const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
5266
+ const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
5272
5267
  const data = {
5273
5268
  model: relation,
5274
5269
  domain: domainObject,
@@ -5284,23 +5279,23 @@ var many2oneFieldController = (props) => {
5284
5279
  data: dataOfSelection,
5285
5280
  refetch,
5286
5281
  isFetching
5287
- } = useGetSelection3({
5282
+ } = useGetSelection2({
5288
5283
  data,
5289
5284
  queryKey,
5290
5285
  enabled: false
5291
5286
  });
5292
- const selectOptions = (0, import_react15.useMemo)(() => {
5287
+ const selectOptions = (0, import_react14.useMemo)(() => {
5293
5288
  return dataOfSelection?.records?.map((val) => ({
5294
5289
  value: val?.id,
5295
5290
  label: val?.display_name || val?.name
5296
5291
  })) || [];
5297
5292
  }, [dataOfSelection]);
5298
- (0, import_react15.useEffect)(() => {
5293
+ (0, import_react14.useEffect)(() => {
5299
5294
  setOptions(selectOptions);
5300
5295
  setDomainModal(domainObject);
5301
5296
  if (relation === "student.subject") (0, store_exports.setListSubject)(selectOptions);
5302
5297
  }, [selectOptions]);
5303
- (0, import_react15.useEffect)(() => {
5298
+ (0, import_react14.useEffect)(() => {
5304
5299
  setDomainObject(
5305
5300
  (0, utils_exports.evalJSONDomain)(
5306
5301
  domain,
@@ -5308,7 +5303,7 @@ var many2oneFieldController = (props) => {
5308
5303
  )
5309
5304
  );
5310
5305
  }, [domain, formValues]);
5311
- (0, import_react15.useEffect)(() => {
5306
+ (0, import_react14.useEffect)(() => {
5312
5307
  if (!propValue && tempSelectedOption) {
5313
5308
  methods.setValue(name, null);
5314
5309
  setTempSelectedOption(null);
@@ -5319,10 +5314,10 @@ var many2oneFieldController = (props) => {
5319
5314
  });
5320
5315
  }
5321
5316
  }, [propValue]);
5322
- const fetchMoreOptions = (0, import_react15.useCallback)(() => {
5317
+ const fetchMoreOptions = (0, import_react14.useCallback)(() => {
5323
5318
  refetch();
5324
5319
  }, [refetch]);
5325
- (0, import_react15.useEffect)(() => {
5320
+ (0, import_react14.useEffect)(() => {
5326
5321
  if (debouncedInputValue) {
5327
5322
  const filteredDomain = [...domainObject ?? []]?.filter(
5328
5323
  (d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
@@ -5337,7 +5332,7 @@ var many2oneFieldController = (props) => {
5337
5332
  }, 50);
5338
5333
  }
5339
5334
  }, [debouncedInputValue]);
5340
- const handleChooseRecord = (0, import_react15.useCallback)(
5335
+ const handleChooseRecord = (0, import_react14.useCallback)(
5341
5336
  (idRecord) => {
5342
5337
  const newOption = options.find(
5343
5338
  (option) => option.value === idRecord
@@ -5362,8 +5357,8 @@ var many2oneFieldController = (props) => {
5362
5357
  },
5363
5358
  [options, methods, name, onChange]
5364
5359
  );
5365
- const handleClose = (0, import_react15.useCallback)(() => setIsShowModalMany2Many(false), []);
5366
- const handleSelectChange = (0, import_react15.useCallback)(
5360
+ const handleClose = (0, import_react14.useCallback)(() => setIsShowModalMany2Many(false), []);
5361
+ const handleSelectChange = (0, import_react14.useCallback)(
5367
5362
  (selectedOption) => {
5368
5363
  if (!selectedOption) {
5369
5364
  methods.setValue(name, null, { shouldDirty: true });
@@ -5410,20 +5405,20 @@ var many2oneFieldController = (props) => {
5410
5405
  };
5411
5406
 
5412
5407
  // src/widget/basic/many2one-button-field/controller.ts
5413
- var import_environment7 = require("@fctc/interface-logic/environment");
5414
- var import_hooks13 = require("@fctc/interface-logic/hooks");
5415
- var import_utils6 = require("@fctc/interface-logic/utils");
5408
+ var import_environment6 = require("@fctc/interface-logic/environment");
5409
+ var import_hooks12 = require("@fctc/interface-logic/hooks");
5410
+ var import_utils5 = require("@fctc/interface-logic/utils");
5416
5411
  var many2oneButtonController = (props) => {
5417
5412
  const { domain, methods, relation } = props;
5418
5413
  const actionDataString = sessionStorage.getItem("actionData");
5419
- const env = (0, import_environment7.getEnv)();
5420
- const domainObject = (0, import_utils6.evalJSONDomain)(domain, methods?.getValues() || {});
5414
+ const env = (0, import_environment6.getEnv)();
5415
+ const domainObject = (0, import_utils5.evalJSONDomain)(domain, methods?.getValues() || {});
5421
5416
  const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
5422
- const { data: dataOfSelection } = (0, import_hooks13.useGetSelection)({
5417
+ const { data: dataOfSelection } = (0, import_hooks12.useGetSelection)({
5423
5418
  data: {
5424
5419
  model: relation ?? "",
5425
5420
  domain: domainObject,
5426
- context: { ...env.context, ...(0, import_utils6.evalJSONContext)(actionData?.context) }
5421
+ context: { ...env.context, ...(0, import_utils5.evalJSONContext)(actionData?.context) }
5427
5422
  },
5428
5423
  queryKey: [`data_${relation}`, domainObject]
5429
5424
  });
@@ -5437,9 +5432,9 @@ var many2oneButtonController = (props) => {
5437
5432
  };
5438
5433
 
5439
5434
  // src/widget/basic/many2many-field/controller.ts
5440
- var import_react16 = require("react");
5435
+ var import_react15 = require("react");
5441
5436
  var import_store8 = require("@fctc/interface-logic/store");
5442
- var import_utils7 = require("@fctc/interface-logic/utils");
5437
+ var import_utils6 = require("@fctc/interface-logic/utils");
5443
5438
  var many2manyFieldController = (props) => {
5444
5439
  const {
5445
5440
  relation,
@@ -5459,9 +5454,9 @@ var many2manyFieldController = (props) => {
5459
5454
  const appDispatch = (0, import_store8.useAppDispatch)();
5460
5455
  const actionData = sessionStorageUtils.getActionData();
5461
5456
  const [debouncedPage] = useDebounce(page, 500);
5462
- const [order, setOrder] = (0, import_react16.useState)();
5463
- const [isLoadedData, setIsLoadedData] = (0, import_react16.useState)(false);
5464
- const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(domain);
5457
+ const [order, setOrder] = (0, import_react15.useState)();
5458
+ const [isLoadedData, setIsLoadedData] = (0, import_react15.useState)(false);
5459
+ const [domainMany2Many, setDomainMany2Many] = (0, import_react15.useState)(domain);
5465
5460
  const { env } = (0, provider_exports.useEnv)();
5466
5461
  const { useGetView: useGetView2, useGetListData: useGetListData3, useGetFormView } = (0, provider_exports.useService)();
5467
5462
  const viewParams = {
@@ -5473,7 +5468,7 @@ var many2manyFieldController = (props) => {
5473
5468
  context
5474
5469
  };
5475
5470
  const { data: viewResponse } = useGetView2(viewParams, actionData);
5476
- const baseModel = (0, import_react16.useMemo)(
5471
+ const baseModel = (0, import_react15.useMemo)(
5477
5472
  () => ({
5478
5473
  name: String(relation),
5479
5474
  view: viewResponse || {},
@@ -5486,20 +5481,20 @@ var many2manyFieldController = (props) => {
5486
5481
  [model, viewResponse]
5487
5482
  );
5488
5483
  const initModel = (0, hooks_exports.useModel)();
5489
- const modelInstance = (0, import_react16.useMemo)(() => {
5484
+ const modelInstance = (0, import_react15.useMemo)(() => {
5490
5485
  if (viewResponse) {
5491
5486
  return initModel.initModel(baseModel);
5492
5487
  }
5493
5488
  return null;
5494
5489
  }, [baseModel, viewResponse]);
5495
- const specification = (0, import_react16.useMemo)(() => {
5490
+ const specification = (0, import_react15.useMemo)(() => {
5496
5491
  if (modelInstance) {
5497
5492
  return modelInstance.getSpecification();
5498
5493
  }
5499
5494
  return null;
5500
5495
  }, [modelInstance]);
5501
5496
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
5502
- const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
5497
+ const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
5503
5498
  const fetchData = async () => {
5504
5499
  try {
5505
5500
  setDomainMany2Many(domain);
@@ -5537,7 +5532,7 @@ var many2manyFieldController = (props) => {
5537
5532
  context,
5538
5533
  fields: groupByDomain?.fields,
5539
5534
  groupby: [groupByDomain?.contexts[0]?.group_by],
5540
- sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
5535
+ sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
5541
5536
  };
5542
5537
  const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
5543
5538
  const {
@@ -5546,7 +5541,7 @@ var many2manyFieldController = (props) => {
5546
5541
  isFetched: isDataResponseFetched,
5547
5542
  isPlaceholderData
5548
5543
  } = useGetListData3(data, queryKey, enabled);
5549
- (0, import_react16.useEffect)(() => {
5544
+ (0, import_react15.useEffect)(() => {
5550
5545
  if (viewResponse) {
5551
5546
  fetchData();
5552
5547
  }
@@ -5585,13 +5580,13 @@ var many2manyFieldController = (props) => {
5585
5580
  queryKey: [`form-view-action-${relation}`],
5586
5581
  enabled: false
5587
5582
  });
5588
- (0, import_react16.useEffect)(() => {
5583
+ (0, import_react15.useEffect)(() => {
5589
5584
  if (isSuccess && dataFormViewResponse) {
5590
5585
  sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
5591
5586
  window.location.href = `/form/menu?model=${relation}`;
5592
5587
  }
5593
5588
  }, [isSuccess]);
5594
- (0, import_react16.useEffect)(() => {
5589
+ (0, import_react15.useEffect)(() => {
5595
5590
  if (domainMany2Many && !isLoadedData) {
5596
5591
  setIsLoadedData(true);
5597
5592
  }
@@ -5616,11 +5611,9 @@ var many2manyFieldController = (props) => {
5616
5611
  };
5617
5612
 
5618
5613
  // src/widget/basic/many2many-tags-field/controller.ts
5619
- var import_react17 = require("react");
5614
+ var import_react16 = require("react");
5620
5615
  var import_constants4 = require("@fctc/interface-logic/constants");
5621
- var import_environment8 = require("@fctc/interface-logic/environment");
5622
- var import_hooks15 = require("@fctc/interface-logic/hooks");
5623
- var import_utils8 = require("@fctc/interface-logic/utils");
5616
+ var import_utils7 = require("@fctc/interface-logic/utils");
5624
5617
  var many2manyTagsController = (props) => {
5625
5618
  const {
5626
5619
  relation,
@@ -5631,10 +5624,11 @@ var many2manyTagsController = (props) => {
5631
5624
  placeholderNoOption
5632
5625
  } = props;
5633
5626
  const isUser = relation === "res.users" || relation === "res.partner";
5634
- const env = (0, import_environment8.getEnv)();
5635
- const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
5636
- const domainObject = (0, import_react17.useMemo)(
5637
- () => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
5627
+ const { env } = (0, provider_exports.useEnv)();
5628
+ const { useGetSelection: useGetSelection2 } = (0, provider_exports.useService)();
5629
+ const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
5630
+ const domainObject = (0, import_react16.useMemo)(
5631
+ () => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
5638
5632
  [domain, formValues]
5639
5633
  );
5640
5634
  const data = {
@@ -5650,7 +5644,7 @@ var many2manyTagsController = (props) => {
5650
5644
  enabled: true,
5651
5645
  context: env.context
5652
5646
  };
5653
- const { data: dataOfSelection } = (0, import_hooks15.useGetSelection)({
5647
+ const { data: dataOfSelection } = useGetSelection2({
5654
5648
  data,
5655
5649
  queryKey: [`data_${relation}`, domainObject]
5656
5650
  });
@@ -5670,16 +5664,15 @@ var many2manyTagsController = (props) => {
5670
5664
  options,
5671
5665
  customNoOptionsMessage,
5672
5666
  tranfer,
5673
- dataOfSelection,
5674
5667
  isUser
5675
5668
  };
5676
5669
  };
5677
5670
 
5678
5671
  // src/widget/basic/status-bar-field/controller.ts
5679
- var import_react18 = require("react");
5680
- var import_utils9 = require("@fctc/interface-logic/utils");
5672
+ var import_react17 = require("react");
5673
+ var import_utils8 = require("@fctc/interface-logic/utils");
5681
5674
  var durationController = (props) => {
5682
- const { relation, domain, formValues, name, id, model, onRefetch } = props;
5675
+ const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
5683
5676
  const specification = {
5684
5677
  id: 0,
5685
5678
  name: "",
@@ -5687,13 +5680,13 @@ var durationController = (props) => {
5687
5680
  };
5688
5681
  const { useGetListData: useGetListData3, useChangeStatus } = (0, provider_exports.useService)();
5689
5682
  const { env } = (0, provider_exports.useEnv)();
5690
- const [disabled, setDisabled] = (0, import_react18.useState)(false);
5691
- const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
5683
+ const [disabled, setDisabled] = (0, import_react17.useState)(false);
5684
+ const [modelStatus, setModalStatus] = (0, import_react17.useState)(false);
5692
5685
  const queryKey = [`data-status-duration`, specification];
5693
5686
  const listDataProps = {
5694
5687
  model: relation,
5695
5688
  specification,
5696
- domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
5689
+ domain: (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
5697
5690
  limit: 10,
5698
5691
  offset: 0,
5699
5692
  fields: "",
@@ -5703,7 +5696,11 @@ var durationController = (props) => {
5703
5696
  },
5704
5697
  sort: ""
5705
5698
  };
5706
- const { data: dataResponse } = useGetListData3(listDataProps, queryKey);
5699
+ const { data: dataResponse } = useGetListData3(
5700
+ listDataProps,
5701
+ queryKey,
5702
+ enabled
5703
+ );
5707
5704
  const { mutate: fetchChangeStatus } = useChangeStatus();
5708
5705
  const handleClick = async (stage_id) => {
5709
5706
  setDisabled(true);
@@ -5739,32 +5736,18 @@ var durationController = (props) => {
5739
5736
  };
5740
5737
 
5741
5738
  // src/widget/basic/priority-field/controller.ts
5742
- var import_hooks16 = require("@fctc/interface-logic/hooks");
5743
- var import_utils10 = require("@fctc/interface-logic/utils");
5739
+ var import_utils9 = require("@fctc/interface-logic/utils");
5744
5740
  var priorityFieldController = (props) => {
5745
- const {
5746
- value,
5747
- isForm,
5748
- name,
5749
- methods,
5750
- onChange,
5751
- model,
5752
- selection,
5753
- id,
5754
- actionData,
5755
- viewData,
5756
- context
5757
- } = props;
5758
- const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
5741
+ const { name, model, id, actionData, context, onChange } = props;
5742
+ const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
5759
5743
  const contextObject = { ...context, ..._context };
5760
- const defaultPriority = parseInt(value) + 1;
5761
- const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
5762
- const { mutateAsync: fetchSave } = (0, import_hooks16.useSave)();
5744
+ const { useSave: useSave2 } = (0, provider_exports.useService)();
5745
+ const { mutateAsync: fetchSave } = useSave2();
5763
5746
  const savePriorities = async ({
5764
- value: value2,
5747
+ value,
5765
5748
  resetPriority
5766
5749
  }) => {
5767
- const priorityValue = value2 <= 0 ? 0 : value2 - 1;
5750
+ const priorityValue = value <= 0 ? 0 : value - 1;
5768
5751
  try {
5769
5752
  fetchSave({
5770
5753
  ids: id ? [id] : [],
@@ -5782,22 +5765,15 @@ var priorityFieldController = (props) => {
5782
5765
  }
5783
5766
  };
5784
5767
  return {
5785
- selection,
5786
- isForm,
5787
- methods,
5788
- defaultPriority,
5789
- savePriorities,
5790
- label,
5791
- id,
5792
- onChange
5768
+ savePriorities
5793
5769
  };
5794
5770
  };
5795
5771
 
5796
5772
  // src/widget/basic/download-file-field/controller.ts
5797
- var import_react19 = require("react");
5773
+ var import_react18 = require("react");
5798
5774
  var downloadFileController = () => {
5799
- const inputId = (0, import_react19.useId)();
5800
- const [file, setFile] = (0, import_react19.useState)(null);
5775
+ const inputId = (0, import_react18.useId)();
5776
+ const [file, setFile] = (0, import_react18.useState)(null);
5801
5777
  const handleFileChange = (e) => {
5802
5778
  setFile(e.target.files[0]);
5803
5779
  };
@@ -6729,13 +6705,13 @@ var dateFieldController = (props) => {
6729
6705
  };
6730
6706
 
6731
6707
  // src/widget/basic/copy-link-button/controller.ts
6732
- var import_react20 = require("react");
6733
- var import_utils11 = require("@fctc/interface-logic/utils");
6708
+ var import_react19 = require("react");
6709
+ var import_utils10 = require("@fctc/interface-logic/utils");
6734
6710
  var copyLinkButtonController = (props) => {
6735
6711
  const { value, defaultValue } = props;
6736
- const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
6712
+ const [isCopied, setIsCopied] = (0, import_react19.useState)(false);
6737
6713
  const handleCopyToClipboard = async (value2) => {
6738
- await (0, import_utils11.copyTextToClipboard)(value2);
6714
+ await (0, import_utils10.copyTextToClipboard)(value2);
6739
6715
  setIsCopied(true);
6740
6716
  setTimeout(() => setIsCopied(false), 2e3);
6741
6717
  };
@@ -6748,15 +6724,15 @@ var copyLinkButtonController = (props) => {
6748
6724
  };
6749
6725
 
6750
6726
  // src/widget/basic/color-field/color-controller.ts
6751
- var import_utils12 = require("@fctc/interface-logic/utils");
6727
+ var import_utils11 = require("@fctc/interface-logic/utils");
6752
6728
  var colorFieldController = (props) => {
6753
6729
  const { value, isForm, name, formValues, idForm, model, actionData } = props;
6754
6730
  const { env } = (0, provider_exports.useEnv)();
6755
- const { useSave: useSave3 } = (0, provider_exports.useService)();
6756
- const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
6731
+ const { useSave: useSave2 } = (0, provider_exports.useService)();
6732
+ const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) || {} };
6757
6733
  const contextObject = { ...env.context, ..._context };
6758
6734
  const idDefault = isForm ? idForm : formValues?.id;
6759
- const { mutate: onSave } = useSave3();
6735
+ const { mutate: onSave } = useSave2();
6760
6736
  const savePickColor = async (colorObject) => {
6761
6737
  const { id } = colorObject;
6762
6738
  if (value === id) return;
@@ -6781,16 +6757,16 @@ var colorFieldController = (props) => {
6781
6757
  };
6782
6758
 
6783
6759
  // src/widget/basic/binary-field/controller.ts
6784
- var import_react21 = require("react");
6785
- var import_utils13 = require("@fctc/interface-logic/utils");
6760
+ var import_react20 = require("react");
6761
+ var import_utils12 = require("@fctc/interface-logic/utils");
6786
6762
  var binaryFieldController = (props) => {
6787
6763
  const { name, methods, readonly = false, value } = props;
6788
- const inputId = (0, import_react21.useId)();
6789
- const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
6790
- const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
6791
- const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
6764
+ const inputId = (0, import_react20.useId)();
6765
+ const [selectedImage, setSelectedImage] = (0, import_react20.useState)(null);
6766
+ const [initialImage, setInitialImage] = (0, import_react20.useState)(value || null);
6767
+ const [isInsideTable, setIsInsideTable] = (0, import_react20.useState)(false);
6792
6768
  const { setValue } = methods;
6793
- const binaryRef = (0, import_react21.useRef)(null);
6769
+ const binaryRef = (0, import_react20.useRef)(null);
6794
6770
  const convertUrlToBase64 = async (url) => {
6795
6771
  try {
6796
6772
  const response = await fetch(url);
@@ -6839,11 +6815,11 @@ var binaryFieldController = (props) => {
6839
6815
  };
6840
6816
  const checkIsImageLink = (url) => {
6841
6817
  const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
6842
- return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
6818
+ return imageExtensions.test(url) || (0, import_utils12.isBase64Image)(url) || isBlobUrl(url);
6843
6819
  };
6844
6820
  const getImageBase64WithMimeType = (base64) => {
6845
6821
  if (typeof base64 !== "string" || base64.length < 10) return null;
6846
- if ((0, import_utils13.isBase64Image)(base64)) return base64;
6822
+ if ((0, import_utils12.isBase64Image)(base64)) return base64;
6847
6823
  let mimeType = null;
6848
6824
  if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
6849
6825
  else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
@@ -6852,14 +6828,14 @@ var binaryFieldController = (props) => {
6852
6828
  else if (base64.startsWith("UklGR")) mimeType = "image/webp";
6853
6829
  return mimeType ? `data:${mimeType};base64,${base64}` : null;
6854
6830
  };
6855
- (0, import_react21.useEffect)(() => {
6831
+ (0, import_react20.useEffect)(() => {
6856
6832
  return () => {
6857
6833
  if (selectedImage) {
6858
6834
  URL.revokeObjectURL(selectedImage);
6859
6835
  }
6860
6836
  };
6861
6837
  }, [selectedImage]);
6862
- (0, import_react21.useEffect)(() => {
6838
+ (0, import_react20.useEffect)(() => {
6863
6839
  if (binaryRef.current) {
6864
6840
  const isInsideTable2 = !!binaryRef.current.closest("table");
6865
6841
  setIsInsideTable(isInsideTable2);
@@ -6880,7 +6856,7 @@ var binaryFieldController = (props) => {
6880
6856
 
6881
6857
  // src/widget/advance/table/table-body/controller.ts
6882
6858
  var import_store9 = require("@fctc/interface-logic/store");
6883
- var import_react22 = require("react");
6859
+ var import_react21 = require("react");
6884
6860
  var tableBodyController = (props) => {
6885
6861
  const {
6886
6862
  checkedAll,
@@ -6893,7 +6869,7 @@ var tableBodyController = (props) => {
6893
6869
  onClickRow
6894
6870
  } = props;
6895
6871
  const appDispatch = (0, import_store9.useAppDispatch)();
6896
- const checked = (0, import_react22.useMemo)(() => {
6872
+ const checked = (0, import_react21.useMemo)(() => {
6897
6873
  if (!row?.id) return false;
6898
6874
  if (selectedRowKeys?.includes(row.id)) {
6899
6875
  return true;
@@ -6914,7 +6890,7 @@ var tableBodyController = (props) => {
6914
6890
  const handleClickRow = (col, row2) => {
6915
6891
  onClickRow(col, row2);
6916
6892
  };
6917
- (0, import_react22.useEffect)(() => {
6893
+ (0, import_react21.useEffect)(() => {
6918
6894
  if (!row?.id) return;
6919
6895
  if (isAutoSelect) {
6920
6896
  if (checkboxRef?.current === "uncheck") {
@@ -6932,7 +6908,7 @@ var tableBodyController = (props) => {
6932
6908
  }
6933
6909
  }
6934
6910
  }, [isAutoSelect]);
6935
- (0, import_react22.useEffect)(() => {
6911
+ (0, import_react21.useEffect)(() => {
6936
6912
  if (!checkedAll) {
6937
6913
  checkboxRef.current = "enabled";
6938
6914
  false;
@@ -6983,12 +6959,12 @@ var tableHeadController = (props) => {
6983
6959
  };
6984
6960
 
6985
6961
  // src/widget/advance/table/table-view/controller.ts
6986
- var import_react23 = require("react");
6962
+ var import_react22 = require("react");
6987
6963
  var import_store11 = require("@fctc/interface-logic/store");
6988
- var import_utils14 = require("@fctc/interface-logic/utils");
6964
+ var import_utils13 = require("@fctc/interface-logic/utils");
6989
6965
  var tableController = ({ data }) => {
6990
- const [rows, setRows] = (0, import_react23.useState)(data.records || []);
6991
- const [columns, setColumns] = (0, import_react23.useState)([]);
6966
+ const [rows, setRows] = (0, import_react22.useState)(data.records || []);
6967
+ const [columns, setColumns] = (0, import_react22.useState)([]);
6992
6968
  const dataModelFields = data.fields?.map((field) => {
6993
6969
  return {
6994
6970
  ...data.dataModel?.[field?.name],
@@ -7016,14 +6992,14 @@ var tableController = ({ data }) => {
7016
6992
  return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
7017
6993
  });
7018
6994
  };
7019
- (0, import_react23.useEffect)(() => {
6995
+ (0, import_react22.useEffect)(() => {
7020
6996
  setRows(transformData(data.records || null));
7021
6997
  }, [data.records]);
7022
6998
  const handleGetColumns = () => {
7023
6999
  let cols = [];
7024
7000
  try {
7025
7001
  cols = mergeFields?.filter((item) => {
7026
- 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);
7002
+ 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);
7027
7003
  })?.map((field) => {
7028
7004
  return {
7029
7005
  name: field?.name,
@@ -7037,7 +7013,7 @@ var tableController = ({ data }) => {
7037
7013
  }
7038
7014
  return cols;
7039
7015
  };
7040
- (0, import_react23.useEffect)(() => {
7016
+ (0, import_react22.useEffect)(() => {
7041
7017
  const columns2 = handleGetColumns();
7042
7018
  setColumns(columns2);
7043
7019
  }, [data.records]);
@@ -7062,8 +7038,8 @@ var tableController = ({ data }) => {
7062
7038
  };
7063
7039
 
7064
7040
  // src/widget/advance/table/table-group/controller.ts
7065
- var import_react24 = require("react");
7066
- var import_hooks17 = require("@fctc/interface-logic/hooks");
7041
+ var import_react23 = require("react");
7042
+ var import_hooks14 = require("@fctc/interface-logic/hooks");
7067
7043
  var import_store12 = require("@fctc/interface-logic/store");
7068
7044
 
7069
7045
  // src/environment.ts
@@ -7091,18 +7067,18 @@ var tableGroupController = (props) => {
7091
7067
  setIsAutoSelect,
7092
7068
  selectedRowKeysRef
7093
7069
  } = props;
7094
- const [pageGroup, setPageGroup] = (0, import_react24.useState)(0);
7070
+ const [pageGroup, setPageGroup] = (0, import_react23.useState)(0);
7095
7071
  const { groupByDomain, selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
7096
7072
  const { selectedRowKeys } = (0, import_store12.useAppSelector)(import_store12.selectList);
7097
7073
  const appDispatch = (0, import_store12.useAppDispatch)();
7098
- const { toDataJS } = (0, import_hooks17.useOdooDataTransform)();
7074
+ const { toDataJS } = (0, import_hooks14.useOdooDataTransform)();
7099
7075
  const initVal = toDataJS(row, viewData, model);
7100
- const [isShowGroup, setIsShowGroup] = (0, import_react24.useState)(false);
7101
- const [colEmptyGroup, setColEmptyGroup] = (0, import_react24.useState)({
7076
+ const [isShowGroup, setIsShowGroup] = (0, import_react23.useState)(false);
7077
+ const [colEmptyGroup, setColEmptyGroup] = (0, import_react23.useState)({
7102
7078
  fromStart: 1,
7103
7079
  fromEnd: 1
7104
7080
  });
7105
- const processedData = (0, import_react24.useMemo)(() => {
7081
+ const processedData = (0, import_react23.useMemo)(() => {
7106
7082
  const calculateColSpanEmpty = () => {
7107
7083
  const startIndex = columns.findIndex(
7108
7084
  (col) => col.field.type === "monetary" && typeof row[col.key] === "number" || col.field.aggregator === "sum"
@@ -7117,7 +7093,7 @@ var tableGroupController = (props) => {
7117
7093
  };
7118
7094
  return calculateColSpanEmpty();
7119
7095
  }, [columns, row]);
7120
- const shouldFetchData = (0, import_react24.useMemo)(() => {
7096
+ const shouldFetchData = (0, import_react23.useMemo)(() => {
7121
7097
  return !!isShowGroup;
7122
7098
  }, [isShowGroup]);
7123
7099
  const enabled = shouldFetchData && !!processedData;
@@ -7142,7 +7118,7 @@ var tableGroupController = (props) => {
7142
7118
  isPlaceholderData,
7143
7119
  isLoading,
7144
7120
  isFetching
7145
- } = (0, import_hooks17.useGetListData)(listDataProps, queryKey, enabled);
7121
+ } = (0, import_hooks14.useGetListData)(listDataProps, queryKey, enabled);
7146
7122
  const {
7147
7123
  columns: columnsGroup,
7148
7124
  rows: rowsGroup,
@@ -7157,7 +7133,7 @@ var tableGroupController = (props) => {
7157
7133
  }
7158
7134
  });
7159
7135
  const leftPadding = level > 1 ? level * 8 + "px" : "0px";
7160
- (0, import_react24.useEffect)(() => {
7136
+ (0, import_react23.useEffect)(() => {
7161
7137
  if (isShowGroup && selectedTags?.length > 0) {
7162
7138
  setIsShowGroup(false);
7163
7139
  }
@@ -7191,7 +7167,7 @@ var tableGroupController = (props) => {
7191
7167
  }
7192
7168
  toggleShowGroup();
7193
7169
  };
7194
- (0, import_react24.useEffect)(() => {
7170
+ (0, import_react23.useEffect)(() => {
7195
7171
  if (!isQueryFetched || !rowsGroup || !checkedAll || allIdsNull || typeTableGroup === "group") {
7196
7172
  return;
7197
7173
  }
@@ -7232,9 +7208,9 @@ var tableGroupController = (props) => {
7232
7208
 
7233
7209
  // src/widget/advance/search/controller.ts
7234
7210
  var import_constants5 = require("@fctc/interface-logic/constants");
7235
- var import_utils15 = require("@fctc/interface-logic/utils");
7211
+ var import_utils14 = require("@fctc/interface-logic/utils");
7236
7212
  var import_moment2 = __toESM(require_moment());
7237
- var import_react25 = require("react");
7213
+ var import_react24 = require("react");
7238
7214
  var searchController = ({
7239
7215
  viewData,
7240
7216
  actionData,
@@ -7243,12 +7219,12 @@ var searchController = ({
7243
7219
  setSearchMap,
7244
7220
  searchMap
7245
7221
  }) => {
7246
- const [filterBy, setFilterBy] = (0, import_react25.useState)(null);
7247
- const [searchBy, setSearchBy] = (0, import_react25.useState)(null);
7248
- const [groupBy, setGroupBy] = (0, import_react25.useState)(null);
7249
- const [selectedTags, setSelectedTags] = (0, import_react25.useState)(null);
7250
- const [searchString, setSearchString] = (0, import_react25.useState)("");
7251
- const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils15.evalJSONDomain)(actionData?.domain, contextSearch) : [];
7222
+ const [filterBy, setFilterBy] = (0, import_react24.useState)(null);
7223
+ const [searchBy, setSearchBy] = (0, import_react24.useState)(null);
7224
+ const [groupBy, setGroupBy] = (0, import_react24.useState)(null);
7225
+ const [selectedTags, setSelectedTags] = (0, import_react24.useState)(null);
7226
+ const [searchString, setSearchString] = (0, import_react24.useState)("");
7227
+ const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils14.evalJSONDomain)(actionData?.domain, contextSearch) : [];
7252
7228
  const aid = actionData?.id;
7253
7229
  const model = actionData?.res_model;
7254
7230
  const clearSearch = () => {
@@ -7265,7 +7241,7 @@ var searchController = ({
7265
7241
  const dataModel = viewData?.models?.[model];
7266
7242
  const searchViews = viewData?.views?.search;
7267
7243
  const searchByItems = searchViews?.search_by?.filter(
7268
- (item) => !import_utils15.domainHelper.matchDomains(contextSearch, item.invisible)
7244
+ (item) => !import_utils14.domainHelper.matchDomains(contextSearch, item.invisible)
7269
7245
  )?.map(
7270
7246
  ({ string, name, filter_domain, operator, widget }, index) => ({
7271
7247
  dataIndex: index,
@@ -7278,10 +7254,10 @@ var searchController = ({
7278
7254
  })
7279
7255
  );
7280
7256
  const filterByItems = searchViews?.filter_by.filter((item) => {
7281
- return !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible);
7257
+ return !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible);
7282
7258
  })?.map((item) => ({ ...item, active: false }));
7283
7259
  const groupByItems = searchViews?.group_by.filter(
7284
- (item) => !import_utils15.domainHelper.matchDomains(contextSearch, item?.invisible)
7260
+ (item) => !import_utils14.domainHelper.matchDomains(contextSearch, item?.invisible)
7285
7261
  ).map((item) => ({
7286
7262
  ...item,
7287
7263
  string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
@@ -7294,7 +7270,7 @@ var searchController = ({
7294
7270
  }
7295
7271
  }
7296
7272
  };
7297
- (0, import_react25.useEffect)(() => {
7273
+ (0, import_react24.useEffect)(() => {
7298
7274
  clearSearch();
7299
7275
  fetchData();
7300
7276
  }, [aid, model, viewData]);
@@ -7359,14 +7335,14 @@ var searchController = ({
7359
7335
  }
7360
7336
  let valueDomainItem = value?.value;
7361
7337
  if (value?.modelType === "date") {
7362
- valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value);
7338
+ valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value);
7363
7339
  } else if (value?.modelType === "datetime") {
7364
7340
  if (value?.operator === "<=" || value?.operator === "<") {
7365
- const parsedDate = (0, import_utils15.validateAndParseDate)(value?.value, true);
7341
+ const parsedDate = (0, import_utils14.validateAndParseDate)(value?.value, true);
7366
7342
  const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
7367
7343
  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");
7368
7344
  } else {
7369
- valueDomainItem = (0, import_utils15.validateAndParseDate)(value?.value, true);
7345
+ valueDomainItem = (0, import_utils14.validateAndParseDate)(value?.value, true);
7370
7346
  }
7371
7347
  }
7372
7348
  const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
@@ -7377,7 +7353,7 @@ var searchController = ({
7377
7353
  return [...domain];
7378
7354
  }
7379
7355
  };
7380
- const setTagSearch = (0, import_react25.useCallback)(
7356
+ const setTagSearch = (0, import_react24.useCallback)(
7381
7357
  (updatedMap) => {
7382
7358
  if (!updatedMap) return;
7383
7359
  const tagsSearch = Object.entries(updatedMap).map(
@@ -7440,7 +7416,7 @@ var searchController = ({
7440
7416
  },
7441
7417
  [searchMap]
7442
7418
  );
7443
- (0, import_react25.useEffect)(() => {
7419
+ (0, import_react24.useEffect)(() => {
7444
7420
  setSelectedTags(null);
7445
7421
  setTagSearch(searchMap);
7446
7422
  }, [searchMap]);
@@ -7455,7 +7431,7 @@ var searchController = ({
7455
7431
  active,
7456
7432
  dataIndex
7457
7433
  } = tag;
7458
- const domainFormat = new import_utils15.domainHelper.Domain(domain);
7434
+ const domainFormat = new import_utils14.domainHelper.Domain(domain);
7459
7435
  if (type === import_constants5.SearchType.FILTER) {
7460
7436
  addSearchItems(`${import_constants5.SearchType.FILTER}_${groupIndex}`, {
7461
7437
  ...tag,