@fctc/widget-logic 1.7.9 → 1.8.1

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
@@ -4049,6 +4049,7 @@ __export(widget_exports, {
4049
4049
  many2oneButtonController: () => many2oneButtonController,
4050
4050
  many2oneFieldController: () => many2oneFieldController,
4051
4051
  priorityFieldController: () => priorityFieldController,
4052
+ searchController: () => searchController,
4052
4053
  statusDropdownController: () => statusDropdownController,
4053
4054
  tableBodyController: () => tableBodyController,
4054
4055
  tableController: () => tableController,
@@ -4312,7 +4313,7 @@ var many2oneButtonController = (props) => {
4312
4313
  };
4313
4314
 
4314
4315
  // src/widget/basic/many2many-field/controller.ts
4315
- var import_react18 = require("react");
4316
+ var import_react19 = require("react");
4316
4317
 
4317
4318
  // src/hooks.ts
4318
4319
  var hooks_exports = {};
@@ -4847,7 +4848,6 @@ var useAuth = () => {
4847
4848
  },
4848
4849
  {
4849
4850
  onSuccess: (res) => {
4850
- setAccessToken(res.access_token);
4851
4851
  },
4852
4852
  onError: (err) => {
4853
4853
  }
@@ -6158,10 +6158,353 @@ var tableGroupController = (props) => {
6158
6158
  };
6159
6159
  };
6160
6160
 
6161
+ // src/widget/advance/search/controller.ts
6162
+ var import_constants3 = require("@fctc/interface-logic/constants");
6163
+ var import_utils6 = require("@fctc/interface-logic/utils");
6164
+ var import_moment = __toESM(require_moment());
6165
+ var import_react18 = require("react");
6166
+
6167
+ // src/provider.ts
6168
+ var provider_exports = {};
6169
+ __reExport(provider_exports, require("@fctc/interface-logic/provider"));
6170
+
6171
+ // src/store.ts
6172
+ var store_exports = {};
6173
+ __reExport(store_exports, require("@fctc/interface-logic/store"));
6174
+
6175
+ // src/widget/advance/search/controller.ts
6176
+ var searchController = ({
6177
+ viewData,
6178
+ actionData,
6179
+ fieldsList,
6180
+ setDomain
6181
+ }) => {
6182
+ const { env } = (0, provider_exports.useEnv)();
6183
+ const { context } = actionData || {};
6184
+ const actionContext = typeof context === "string" ? (0, import_utils6.evalJSONContext)(context) : context;
6185
+ const contextSearch = { ...env.context, ...actionContext };
6186
+ const [filterBy, setFilterBy] = (0, import_react18.useState)(null);
6187
+ const [searchBy, setSearchBy] = (0, import_react18.useState)(null);
6188
+ const [groupBy, setGroupBy] = (0, import_react18.useState)(null);
6189
+ const [selectedTags, setSelectedTags] = (0, import_react18.useState)(null);
6190
+ const [searchString, setSearchString] = (0, import_react18.useState)("");
6191
+ const [searchMap, setSearchMap] = (0, import_react18.useState)({});
6192
+ const [isReadyFormatDomain, setIsReadyFormatDomain] = (0, import_react18.useState)(false);
6193
+ const [didInit, setDidInit] = (0, import_react18.useState)(false);
6194
+ const dispatch = (0, store_exports.useAppDispatch)();
6195
+ const aid = actionData?.id;
6196
+ const model = actionData?.res_model;
6197
+ const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils6.evalJSONDomain)(actionData?.domain, contextSearch) : [];
6198
+ const clearSearch = () => {
6199
+ setFilterBy([]);
6200
+ setGroupBy([]);
6201
+ setSearchBy([]);
6202
+ setSelectedTags(null);
6203
+ setSearchString("");
6204
+ setSearchMap({});
6205
+ };
6206
+ const fetchData = async () => {
6207
+ if (viewData) {
6208
+ try {
6209
+ const dataModel = viewData?.models?.[model];
6210
+ const searchViews = viewData?.views?.search;
6211
+ const searchByItems = searchViews?.search_by?.filter(
6212
+ (item) => !import_utils6.domainHelper.matchDomains(contextSearch, item.invisible)
6213
+ )?.map(
6214
+ ({ string, name, filter_domain, operator, widget }, index) => ({
6215
+ dataIndex: index,
6216
+ title: string ?? dataModel[name]?.string,
6217
+ name: name ?? dataModel[name]?.name,
6218
+ filter_domain,
6219
+ operator,
6220
+ widget,
6221
+ type: dataModel[name]?.type
6222
+ })
6223
+ );
6224
+ const filterByItems = searchViews?.filter_by.filter((item) => {
6225
+ return !import_utils6.domainHelper.matchDomains(contextSearch, item?.invisible);
6226
+ })?.map((item) => ({ ...item, active: false }));
6227
+ const groupByItems = searchViews?.group_by.filter(
6228
+ (item) => !import_utils6.domainHelper.matchDomains(contextSearch, item?.invisible)
6229
+ ).map((item) => ({
6230
+ ...item,
6231
+ string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
6232
+ }));
6233
+ setSearchBy(searchByItems);
6234
+ setFilterBy(filterByItems);
6235
+ setGroupBy(groupByItems);
6236
+ } catch (error) {
6237
+ console.error("Error fetching data:", error);
6238
+ }
6239
+ }
6240
+ };
6241
+ (0, import_react18.useEffect)(() => {
6242
+ clearSearch();
6243
+ fetchData();
6244
+ }, [aid, model, viewData]);
6245
+ const onChangeSearchInput = (search_string) => {
6246
+ setSearchString(search_string);
6247
+ };
6248
+ const removeKeyFromSearchMap = ({
6249
+ key,
6250
+ item
6251
+ }) => {
6252
+ const values = searchMap[key];
6253
+ if (!values) return searchMap;
6254
+ const newSearchMap = { ...searchMap };
6255
+ if (item) {
6256
+ const filtered = values.filter((value) => value.name !== item.name);
6257
+ if (filtered.length > 0) {
6258
+ newSearchMap[key] = filtered;
6259
+ } else {
6260
+ delete newSearchMap[key];
6261
+ }
6262
+ } else {
6263
+ delete newSearchMap[key];
6264
+ }
6265
+ setSearchMap(newSearchMap);
6266
+ };
6267
+ const updateSearchMap = ({ key, item }) => {
6268
+ const newSearchMap = { ...searchMap };
6269
+ const currentValues = searchMap[key] ?? [];
6270
+ newSearchMap[key] = [...currentValues, item];
6271
+ setSearchMap(newSearchMap);
6272
+ };
6273
+ const removeSearchItems = (key, item) => {
6274
+ removeKeyFromSearchMap({ key: String(key), item });
6275
+ };
6276
+ const addSearchItems = (key, newItem) => {
6277
+ updateSearchMap({ key, item: newItem });
6278
+ };
6279
+ const setTagSearch = (0, import_react18.useCallback)(
6280
+ (updatedMap) => {
6281
+ if (!updatedMap) return;
6282
+ const tagsSearch = Object.entries(updatedMap).map(
6283
+ ([key, objValues]) => {
6284
+ const {
6285
+ title,
6286
+ name,
6287
+ groupIndex,
6288
+ type,
6289
+ widget,
6290
+ modelType,
6291
+ dataIndex
6292
+ } = objValues[0];
6293
+ if (!key?.includes(import_constants3.SearchType.GROUP)) {
6294
+ const values = objValues?.map((objValue) => objValue.value);
6295
+ return {
6296
+ title,
6297
+ name: type === import_constants3.SearchType.SEARCH ? `${import_constants3.SearchType.SEARCH}_${String(dataIndex)}` : groupIndex ?? name,
6298
+ values,
6299
+ type,
6300
+ widget,
6301
+ modelType
6302
+ };
6303
+ } else {
6304
+ const contexts = [];
6305
+ let groupValues = [];
6306
+ objValues?.forEach((objValue) => {
6307
+ const { context: context2, value, active, groupIndex: groupIndex2, isDefault } = objValue;
6308
+ const indexAppend = groupIndex2 != null ? groupIndex2 : viewData?.views?.search?.filters_by?.length ?? 0;
6309
+ contexts.push(
6310
+ ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({ group_by: item })) : [context2]
6311
+ );
6312
+ groupValues[indexAppend] = {
6313
+ contexts: [
6314
+ ...Array.isArray(context2?.group_by) ? context2.group_by.map((item) => ({
6315
+ group_by: item
6316
+ })) : [context2]
6317
+ ],
6318
+ strings: isDefault ? [value] : [...groupValues[indexAppend]?.strings ?? [], value]
6319
+ };
6320
+ });
6321
+ const fields = [
6322
+ ...new Set(fieldsList?.map((item) => item?.name))
6323
+ ];
6324
+ const groupByTag = {
6325
+ title,
6326
+ values: groupValues?.filter(
6327
+ (item) => item !== void 0
6328
+ ),
6329
+ type,
6330
+ contexts,
6331
+ fields
6332
+ };
6333
+ dispatch((0, store_exports.setGroupByDomain)(groupByTag));
6334
+ return groupByTag;
6335
+ }
6336
+ }
6337
+ );
6338
+ setSelectedTags(tagsSearch);
6339
+ setSearchString("");
6340
+ },
6341
+ [searchMap]
6342
+ );
6343
+ (0, import_react18.useEffect)(() => {
6344
+ setSelectedTags(null);
6345
+ setTagSearch(searchMap);
6346
+ }, [searchMap]);
6347
+ const formatDomain = () => {
6348
+ if (domainAction) {
6349
+ const domain = [];
6350
+ if (domainAction?.length > 0) {
6351
+ if (Object.keys(searchMap).length > 0) {
6352
+ domain.push("&");
6353
+ }
6354
+ domainAction.forEach((domainItem) => {
6355
+ domain.push(domainItem);
6356
+ });
6357
+ }
6358
+ Object.keys(searchMap).forEach((key, keyIndex, keys) => {
6359
+ if (!key?.includes(import_constants3.SearchType.GROUP)) {
6360
+ if (keys.length > 1 && keyIndex < keys.length - 1) {
6361
+ domain.push("&");
6362
+ }
6363
+ const valuesOfKey = searchMap[key];
6364
+ valuesOfKey.forEach((value, index) => {
6365
+ if (index < valuesOfKey.length - 1) {
6366
+ domain.push("|");
6367
+ }
6368
+ if (value.domain) {
6369
+ domain.push(...value.domain);
6370
+ return;
6371
+ }
6372
+ let valueDomainItem = value?.value;
6373
+ if (value?.modelType === "date") {
6374
+ valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value);
6375
+ } else if (value?.modelType === "datetime") {
6376
+ if (value?.operator === "<=" || value?.operator === "<") {
6377
+ const parsedDate = (0, import_utils6.validateAndParseDate)(value?.value, true);
6378
+ const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
6379
+ valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
6380
+ } else {
6381
+ valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value, true);
6382
+ }
6383
+ }
6384
+ const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
6385
+ domain.push([value.name, operator, valueDomainItem]);
6386
+ });
6387
+ }
6388
+ });
6389
+ return [...domain];
6390
+ }
6391
+ };
6392
+ const handleAddTagSearch = (tag) => {
6393
+ const {
6394
+ domain,
6395
+ groupIndex,
6396
+ value,
6397
+ type,
6398
+ title,
6399
+ context: context2,
6400
+ active,
6401
+ dataIndex
6402
+ } = tag;
6403
+ const domainFormat = new import_utils6.domainHelper.Domain(domain);
6404
+ if (type === import_constants3.SearchType.FILTER) {
6405
+ addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
6406
+ ...tag,
6407
+ domain: domain ? domainFormat.toList(context2) : null
6408
+ });
6409
+ } else if (type === import_constants3.SearchType.SEARCH) {
6410
+ addSearchItems(`${import_constants3.SearchType.SEARCH}_${String(dataIndex)}`, {
6411
+ ...tag,
6412
+ domain: domain ? domainFormat.toList({
6413
+ ...context2,
6414
+ self: value
6415
+ }) : null
6416
+ });
6417
+ } else if (type === import_constants3.SearchType.GROUP) {
6418
+ addSearchItems(`${import_constants3.SearchType.GROUP}`, {
6419
+ ...tag,
6420
+ domain: domain ? domainFormat.toList({
6421
+ context: context2,
6422
+ self: value
6423
+ }) : null
6424
+ });
6425
+ }
6426
+ };
6427
+ (0, import_react18.useEffect)(() => {
6428
+ if (isReadyFormatDomain) {
6429
+ (0, store_exports.setPage)(0);
6430
+ (0, store_exports.setSelectedRowKeys)([]);
6431
+ const containSearchFilter = selectedTags?.length > 0 && selectedTags?.find(
6432
+ (item) => item?.type === import_constants3.SearchType.FILTER || item?.type === import_constants3.SearchType.SEARCH || item?.type === import_constants3.SearchType.GROUP
6433
+ );
6434
+ if (containSearchFilter || Array.isArray(selectedTags) && selectedTags?.length === 0) {
6435
+ setDomain(formatDomain());
6436
+ }
6437
+ }
6438
+ return () => {
6439
+ setDidInit(false);
6440
+ setIsReadyFormatDomain(false);
6441
+ };
6442
+ }, [selectedTags, isReadyFormatDomain]);
6443
+ (0, import_react18.useEffect)(() => {
6444
+ if (didInit || selectedTags?.length > 0 || !fieldsList || fieldsList?.length === 0)
6445
+ return;
6446
+ const searchDefaults = Object.entries(actionContext || {}).filter(
6447
+ ([key]) => key.startsWith("search_default_")
6448
+ );
6449
+ const hasGroupBy = viewData?.views?.search?.filters_by?.length > 0;
6450
+ if (searchDefaults.length === 0 && !hasGroupBy) {
6451
+ setIsReadyFormatDomain(true);
6452
+ setDidInit(true);
6453
+ return;
6454
+ }
6455
+ const updatedFilter = filterBy?.map((item) => {
6456
+ const matched = searchDefaults.find(
6457
+ ([key]) => key.split("search_default_")[1] === item.name
6458
+ );
6459
+ if (matched && !item.active) {
6460
+ handleAddTagSearch?.({
6461
+ name: item?.name,
6462
+ value: item?.string ?? item?.help,
6463
+ domain: item?.domain,
6464
+ groupIndex: item?.group_index,
6465
+ type: import_constants3.SearchType.FILTER
6466
+ });
6467
+ return { ...item, active: true };
6468
+ }
6469
+ return item;
6470
+ });
6471
+ if (updatedFilter) setFilterBy(updatedFilter);
6472
+ if (hasGroupBy) {
6473
+ viewData?.views?.search?.filters_by?.forEach((item, idx) => {
6474
+ const groupCtx = (0, import_utils6.evalJSONContext)(item?.context);
6475
+ handleAddTagSearch?.({
6476
+ name: item?.name,
6477
+ value: item?.display_name,
6478
+ type: import_constants3.SearchType.GROUP,
6479
+ context: groupCtx,
6480
+ groupIndex: idx,
6481
+ isDefault: true
6482
+ });
6483
+ });
6484
+ setDidInit(true);
6485
+ }
6486
+ setIsReadyFormatDomain(true);
6487
+ }, [aid, fieldsList]);
6488
+ return {
6489
+ groupBy,
6490
+ searchBy,
6491
+ filterBy,
6492
+ selectedTags,
6493
+ searchString,
6494
+ setFilterBy,
6495
+ setGroupBy,
6496
+ setSearchBy,
6497
+ clearSearch,
6498
+ setSelectedTags,
6499
+ removeSearchItems,
6500
+ onSearchString: onChangeSearchInput
6501
+ };
6502
+ };
6503
+
6161
6504
  // src/widget/basic/many2many-field/controller.ts
6162
6505
  var import_environment8 = require("@fctc/interface-logic/environment");
6163
- var import_store11 = require("@fctc/interface-logic/store");
6164
- var import_utils6 = require("@fctc/interface-logic/utils");
6506
+ var import_store12 = require("@fctc/interface-logic/store");
6507
+ var import_utils7 = require("@fctc/interface-logic/utils");
6165
6508
  var many2manyFieldController = (props) => {
6166
6509
  const {
6167
6510
  relation,
@@ -6170,7 +6513,7 @@ var many2manyFieldController = (props) => {
6170
6513
  tab,
6171
6514
  model,
6172
6515
  aid,
6173
- setSelectedRowKeys: setSelectedRowKeys4,
6516
+ setSelectedRowKeys: setSelectedRowKeys5,
6174
6517
  fields,
6175
6518
  setFields,
6176
6519
  groupByDomain,
@@ -6178,14 +6521,14 @@ var many2manyFieldController = (props) => {
6178
6521
  options,
6179
6522
  sessionStorageUtils
6180
6523
  } = props;
6181
- const appDispatch = (0, import_store11.useAppDispatch)();
6524
+ const appDispatch = (0, import_store12.useAppDispatch)();
6182
6525
  const actionData = sessionStorageUtils.getActionData();
6183
6526
  const [debouncedPage] = useDebounce(page, 500);
6184
- const [order, setOrder] = (0, import_react18.useState)();
6185
- const [isLoadedData, setIsLoadedData] = (0, import_react18.useState)(false);
6186
- const [domainMany2Many, setDomainMany2Many] = (0, import_react18.useState)(domain);
6527
+ const [order, setOrder] = (0, import_react19.useState)();
6528
+ const [isLoadedData, setIsLoadedData] = (0, import_react19.useState)(false);
6529
+ const [domainMany2Many, setDomainMany2Many] = (0, import_react19.useState)(domain);
6187
6530
  const env = (0, import_environment8.getEnv)();
6188
- const { selectedTags } = (0, import_store11.useAppSelector)(import_store11.selectSearch);
6531
+ const { selectedTags } = (0, import_store12.useAppSelector)(import_store12.selectSearch);
6189
6532
  const viewParams = {
6190
6533
  model: relation,
6191
6534
  views: [
@@ -6198,7 +6541,7 @@ var many2manyFieldController = (props) => {
6198
6541
  viewParams,
6199
6542
  actionData
6200
6543
  );
6201
- const baseModel = (0, import_react18.useMemo)(
6544
+ const baseModel = (0, import_react19.useMemo)(
6202
6545
  () => ({
6203
6546
  name: String(relation),
6204
6547
  view: viewResponse || {},
@@ -6211,25 +6554,25 @@ var many2manyFieldController = (props) => {
6211
6554
  [model, viewResponse]
6212
6555
  );
6213
6556
  const initModel = (0, hooks_exports.useModel)();
6214
- const modelInstance = (0, import_react18.useMemo)(() => {
6557
+ const modelInstance = (0, import_react19.useMemo)(() => {
6215
6558
  if (viewResponse) {
6216
6559
  return initModel.initModel(baseModel);
6217
6560
  }
6218
6561
  return null;
6219
6562
  }, [baseModel, viewResponse]);
6220
- const specification = (0, import_react18.useMemo)(() => {
6563
+ const specification = (0, import_react19.useMemo)(() => {
6221
6564
  if (modelInstance) {
6222
6565
  return modelInstance.getSpecification();
6223
6566
  }
6224
6567
  return null;
6225
6568
  }, [modelInstance]);
6226
6569
  const default_order = viewResponse && viewResponse?.views?.list?.default_order;
6227
- const optionsObject = tab?.options ? (0, import_utils6.evalJSONContext)(tab?.options) : (options ? (0, import_utils6.evalJSONContext)(options) : {}) || {};
6570
+ const optionsObject = tab?.options ? (0, import_utils7.evalJSONContext)(tab?.options) : (options ? (0, import_utils7.evalJSONContext)(options) : {}) || {};
6228
6571
  const fetchData = async () => {
6229
6572
  try {
6230
6573
  setDomainMany2Many(domain);
6231
- appDispatch((0, import_store11.setFirstDomain)(domain));
6232
- appDispatch((0, import_store11.setViewDataStore)(viewResponse));
6574
+ appDispatch((0, import_store12.setFirstDomain)(domain));
6575
+ appDispatch((0, import_store12.setViewDataStore)(viewResponse));
6233
6576
  const modalData = viewResponse?.views?.list?.fields.map((field) => ({
6234
6577
  ...viewResponse?.models?.[String(model)]?.[field?.name],
6235
6578
  ...field
@@ -6240,7 +6583,7 @@ var many2manyFieldController = (props) => {
6240
6583
  [`${aid}_${relation}_popupmany2many`]: modalData
6241
6584
  });
6242
6585
  }
6243
- appDispatch((0, import_store11.setPage)(0));
6586
+ appDispatch((0, import_store12.setPage)(0));
6244
6587
  } catch (err) {
6245
6588
  console.log(err);
6246
6589
  }
@@ -6262,7 +6605,7 @@ var many2manyFieldController = (props) => {
6262
6605
  context,
6263
6606
  fields: groupByDomain?.fields,
6264
6607
  groupby: [groupByDomain?.contexts[0]?.group_by],
6265
- sort: order ? order : default_order ? (0, import_utils6.formatSortingString)(default_order) : ""
6608
+ sort: order ? order : default_order ? (0, import_utils7.formatSortingString)(default_order) : ""
6266
6609
  };
6267
6610
  const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
6268
6611
  const {
@@ -6271,18 +6614,18 @@ var many2manyFieldController = (props) => {
6271
6614
  isFetched: isDataResponseFetched,
6272
6615
  isPlaceholderData
6273
6616
  } = (0, hooks_exports.useGetListData)(data, queryKey, enabled);
6274
- (0, import_react18.useEffect)(() => {
6617
+ (0, import_react19.useEffect)(() => {
6275
6618
  if (viewResponse) {
6276
6619
  fetchData();
6277
6620
  }
6278
6621
  return () => {
6279
- appDispatch((0, import_store11.setGroupByDomain)(null));
6622
+ appDispatch((0, import_store12.setGroupByDomain)(null));
6280
6623
  setFields((prevFields) => ({
6281
6624
  ...prevFields,
6282
6625
  [`${aid}_${relation}_popupmany2many`]: null
6283
6626
  }));
6284
- appDispatch((0, import_store11.setPage)(0));
6285
- setSelectedRowKeys4([]);
6627
+ appDispatch((0, import_store12.setPage)(0));
6628
+ setSelectedRowKeys5([]);
6286
6629
  setDomainMany2Many(null);
6287
6630
  setIsLoadedData(false);
6288
6631
  };
@@ -6310,13 +6653,13 @@ var many2manyFieldController = (props) => {
6310
6653
  queryKey: [`form-view-action-${relation}`],
6311
6654
  enabled: false
6312
6655
  });
6313
- (0, import_react18.useEffect)(() => {
6656
+ (0, import_react19.useEffect)(() => {
6314
6657
  if (isSuccess && dataFormViewResponse) {
6315
6658
  sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
6316
6659
  window.location.href = `/form/menu?model=${relation}`;
6317
6660
  }
6318
6661
  }, [isSuccess]);
6319
- (0, import_react18.useEffect)(() => {
6662
+ (0, import_react19.useEffect)(() => {
6320
6663
  if (domainMany2Many && !isLoadedData) {
6321
6664
  setIsLoadedData(true);
6322
6665
  }
@@ -6332,11 +6675,11 @@ var many2manyFieldController = (props) => {
6332
6675
  };
6333
6676
 
6334
6677
  // src/widget/basic/many2many-tags-field/controller.ts
6335
- var import_react19 = require("react");
6336
- var import_constants3 = require("@fctc/interface-logic/constants");
6678
+ var import_react20 = require("react");
6679
+ var import_constants4 = require("@fctc/interface-logic/constants");
6337
6680
  var import_environment9 = require("@fctc/interface-logic/environment");
6338
6681
  var import_hooks15 = require("@fctc/interface-logic/hooks");
6339
- var import_utils7 = require("@fctc/interface-logic/utils");
6682
+ var import_utils8 = require("@fctc/interface-logic/utils");
6340
6683
  var many2manyTagsController = (props) => {
6341
6684
  const {
6342
6685
  relation,
@@ -6348,9 +6691,9 @@ var many2manyTagsController = (props) => {
6348
6691
  } = props;
6349
6692
  const isUser = relation === "res.users" || relation === "res.partner";
6350
6693
  const env = (0, import_environment9.getEnv)();
6351
- const addtionalFields = optionsFields ? (0, import_utils7.evalJSONContext)(optionsFields) : null;
6352
- const domainObject = (0, import_react19.useMemo)(
6353
- () => (0, import_utils7.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
6694
+ const addtionalFields = optionsFields ? (0, import_utils8.evalJSONContext)(optionsFields) : null;
6695
+ const domainObject = (0, import_react20.useMemo)(
6696
+ () => (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
6354
6697
  [domain, formValues]
6355
6698
  );
6356
6699
  const data = {
@@ -6360,8 +6703,8 @@ var many2manyTagsController = (props) => {
6360
6703
  id: {},
6361
6704
  name: {},
6362
6705
  display_name: {},
6363
- ...widget && import_constants3.WIDGETAVATAR[widget] ? { image_256: {} } : {},
6364
- ...widget && import_constants3.WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
6706
+ ...widget && import_constants4.WIDGETAVATAR[widget] ? { image_256: {} } : {},
6707
+ ...widget && import_constants4.WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
6365
6708
  },
6366
6709
  enabled: true,
6367
6710
  context: env.context
@@ -6392,10 +6735,10 @@ var many2manyTagsController = (props) => {
6392
6735
  };
6393
6736
 
6394
6737
  // src/widget/basic/status-bar-field/controller.ts
6395
- var import_react20 = require("react");
6738
+ var import_react21 = require("react");
6396
6739
  var import_hooks16 = require("@fctc/interface-logic/hooks");
6397
- var import_store12 = require("@fctc/interface-logic/store");
6398
- var import_utils8 = require("@fctc/interface-logic/utils");
6740
+ var import_store13 = require("@fctc/interface-logic/store");
6741
+ var import_utils9 = require("@fctc/interface-logic/utils");
6399
6742
  var durationController = (props) => {
6400
6743
  const {
6401
6744
  relation,
@@ -6412,14 +6755,14 @@ var durationController = (props) => {
6412
6755
  name: "",
6413
6756
  fold: ""
6414
6757
  };
6415
- const [disabled, setDisabled] = (0, import_react20.useState)(false);
6416
- const [modelStatus, setModalStatus] = (0, import_react20.useState)(false);
6417
- const { context } = (0, import_store12.useAppSelector)(import_store12.selectEnv);
6758
+ const [disabled, setDisabled] = (0, import_react21.useState)(false);
6759
+ const [modelStatus, setModalStatus] = (0, import_react21.useState)(false);
6760
+ const { context } = (0, import_store13.useAppSelector)(import_store13.selectEnv);
6418
6761
  const queryKey = [`data-status-duration`, specification];
6419
6762
  const listDataProps = {
6420
6763
  model: relation,
6421
6764
  specification,
6422
- domain: (0, import_utils8.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
6765
+ domain: (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
6423
6766
  limit: 10,
6424
6767
  offset: 0,
6425
6768
  fields: "",
@@ -6467,7 +6810,7 @@ var durationController = (props) => {
6467
6810
 
6468
6811
  // src/widget/basic/priority-field/controller.ts
6469
6812
  var import_hooks17 = require("@fctc/interface-logic/hooks");
6470
- var import_utils9 = require("@fctc/interface-logic/utils");
6813
+ var import_utils10 = require("@fctc/interface-logic/utils");
6471
6814
  var priorityFieldController = (props) => {
6472
6815
  const {
6473
6816
  value,
@@ -6482,7 +6825,7 @@ var priorityFieldController = (props) => {
6482
6825
  viewData,
6483
6826
  context
6484
6827
  } = props;
6485
- const _context = { ...(0, import_utils9.evalJSONContext)(actionData?.context) };
6828
+ const _context = { ...(0, import_utils10.evalJSONContext)(actionData?.context) };
6486
6829
  const contextObject = { ...context, ..._context };
6487
6830
  const defaultPriority = parseInt(value) + 1;
6488
6831
  const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
@@ -6521,8 +6864,8 @@ var priorityFieldController = (props) => {
6521
6864
  };
6522
6865
 
6523
6866
  // src/widget/basic/float-time-field/controller.ts
6524
- var import_react21 = require("react");
6525
- var import_utils10 = require("@fctc/interface-logic/utils");
6867
+ var import_react22 = require("react");
6868
+ var import_utils11 = require("@fctc/interface-logic/utils");
6526
6869
  var floatTimeFiledController = ({
6527
6870
  onChange: fieldOnChange,
6528
6871
  onBlur,
@@ -6531,11 +6874,11 @@ var floatTimeFiledController = ({
6531
6874
  props
6532
6875
  }) => {
6533
6876
  const { name, defaultValue = 0, onChange } = props;
6534
- const [input, setInput] = (0, import_react21.useState)(
6535
- (0, import_utils10.convertFloatToTime)(value ?? defaultValue)
6877
+ const [input, setInput] = (0, import_react22.useState)(
6878
+ (0, import_utils11.convertFloatToTime)(value ?? defaultValue)
6536
6879
  );
6537
- const [formattedTime, setFormattedTime] = (0, import_react21.useState)("");
6538
- const [errors, setErrors] = (0, import_react21.useState)("");
6880
+ const [formattedTime, setFormattedTime] = (0, import_react22.useState)("");
6881
+ const [errors, setErrors] = (0, import_react22.useState)("");
6539
6882
  const handleInputChange = (e) => {
6540
6883
  const raw = e.target.value.replace(/[^\d:]/g, "");
6541
6884
  setInput(raw);
@@ -6565,7 +6908,7 @@ var floatTimeFiledController = ({
6565
6908
  if (!isDirty) return;
6566
6909
  if (formattedTime) {
6567
6910
  setInput(formattedTime);
6568
- const floatVal = (0, import_utils10.convertTimeToFloat)(formattedTime);
6911
+ const floatVal = (0, import_utils11.convertTimeToFloat)(formattedTime);
6569
6912
  fieldOnChange(floatVal);
6570
6913
  if (onChange) {
6571
6914
  onChange(name ?? "", floatVal);
@@ -6608,7 +6951,7 @@ var floatTimeFiledController = ({
6608
6951
  };
6609
6952
 
6610
6953
  // src/widget/basic/float-field/controller.ts
6611
- var import_react22 = require("react");
6954
+ var import_react23 = require("react");
6612
6955
  var floatController = ({
6613
6956
  onChange,
6614
6957
  value,
@@ -6616,10 +6959,10 @@ var floatController = ({
6616
6959
  }) => {
6617
6960
  const { name, required, methods, onChange: handleOnchange, string } = props;
6618
6961
  const { setError, clearErrors } = methods;
6619
- const [inputValue, setInputValue] = (0, import_react22.useState)(
6962
+ const [inputValue, setInputValue] = (0, import_react23.useState)(
6620
6963
  value !== void 0 && value !== null ? useFormatFloatNumber(value) : ""
6621
6964
  );
6622
- (0, import_react22.useEffect)(() => {
6965
+ (0, import_react23.useEffect)(() => {
6623
6966
  if (value !== void 0 && value !== null && value !== parseFloat(inputValue?.replace(/,/g, ""))) {
6624
6967
  setInputValue(useFormatFloatNumber(value));
6625
6968
  clearErrors(name);
@@ -6627,9 +6970,9 @@ var floatController = ({
6627
6970
  setInputValue("");
6628
6971
  }
6629
6972
  }, [value, name, clearErrors]);
6630
- const isDirtyRef = (0, import_react22.useRef)(false);
6631
- const inputRef = (0, import_react22.useRef)(null);
6632
- const lastCommittedValueRef = (0, import_react22.useRef)(null);
6973
+ const isDirtyRef = (0, import_react23.useRef)(false);
6974
+ const inputRef = (0, import_react23.useRef)(null);
6975
+ const lastCommittedValueRef = (0, import_react23.useRef)(null);
6633
6976
  const handleInputChange = (e) => {
6634
6977
  const newValue = e.target.value;
6635
6978
  const valueWithoutCommas = newValue.replace(/,/g, "");
@@ -6730,10 +7073,10 @@ var useFormatFloatNumber = (value) => {
6730
7073
  };
6731
7074
 
6732
7075
  // src/widget/basic/download-file-field/controller.ts
6733
- var import_react23 = require("react");
7076
+ var import_react24 = require("react");
6734
7077
  var downloadFileController = () => {
6735
- const inputId = (0, import_react23.useId)();
6736
- const [file, setFile] = (0, import_react23.useState)(null);
7078
+ const inputId = (0, import_react24.useId)();
7079
+ const [file, setFile] = (0, import_react24.useState)(null);
6737
7080
  const handleFileChange = (e) => {
6738
7081
  setFile(e.target.files[0]);
6739
7082
  };
@@ -6785,7 +7128,7 @@ var downLoadBinaryController = (props) => {
6785
7128
  };
6786
7129
 
6787
7130
  // src/widget/basic/date-field/controller.ts
6788
- var import_moment = __toESM(require_moment());
7131
+ var import_moment2 = __toESM(require_moment());
6789
7132
  var DURATIONS = {
6790
7133
  PAST: "past",
6791
7134
  NOW: "now",
@@ -6812,8 +7155,8 @@ var dateFieldController = (props) => {
6812
7155
  const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
6813
7156
  const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
6814
7157
  const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
6815
- const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
6816
- const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
7158
+ const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment2.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
7159
+ const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment2.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
6817
7160
  const years = range(
6818
7161
  minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
6819
7162
  (/* @__PURE__ */ new Date()).getFullYear() + 4,
@@ -6848,8 +7191,8 @@ var dateFieldController = (props) => {
6848
7191
  "December"
6849
7192
  ];
6850
7193
  const customValidateMinMax = (date) => {
6851
- const selected = (0, import_moment.default)(date, formatDateParse);
6852
- const now = (0, import_moment.default)();
7194
+ const selected = (0, import_moment2.default)(date, formatDateParse);
7195
+ const now = (0, import_moment2.default)();
6853
7196
  const compareSelected = showTime ? selected : selected.clone().startOf("day");
6854
7197
  const compareNow = showTime ? now : now.clone().startOf("day");
6855
7198
  if (minNowValue) {
@@ -6857,7 +7200,7 @@ var dateFieldController = (props) => {
6857
7200
  return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
6858
7201
  "greater_or_equal_now"
6859
7202
  )}`;
6860
- } else if (import_moment.default.isMoment(minNowValue)) {
7203
+ } else if (import_moment2.default.isMoment(minNowValue)) {
6861
7204
  const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
6862
7205
  if (compareSelected.isBefore(compareMin)) {
6863
7206
  const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
@@ -6871,7 +7214,7 @@ var dateFieldController = (props) => {
6871
7214
  return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
6872
7215
  "less_or_equal_now"
6873
7216
  )}`;
6874
- } else if (import_moment.default.isMoment(maxNowValue)) {
7217
+ } else if (import_moment2.default.isMoment(maxNowValue)) {
6875
7218
  const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
6876
7219
  if (compareSelected.isAfter(compareMax)) {
6877
7220
  const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
@@ -6897,13 +7240,13 @@ var dateFieldController = (props) => {
6897
7240
  };
6898
7241
 
6899
7242
  // src/widget/basic/copy-link-button/controller.ts
6900
- var import_react24 = require("react");
6901
- var import_utils11 = require("@fctc/interface-logic/utils");
7243
+ var import_react25 = require("react");
7244
+ var import_utils12 = require("@fctc/interface-logic/utils");
6902
7245
  var copyLinkButtonController = (props) => {
6903
7246
  const { value, defaultValue } = props;
6904
- const [isCopied, setIsCopied] = (0, import_react24.useState)(false);
7247
+ const [isCopied, setIsCopied] = (0, import_react25.useState)(false);
6905
7248
  const handleCopyToClipboard = async (value2) => {
6906
- await (0, import_utils11.copyTextToClipboard)(value2);
7249
+ await (0, import_utils12.copyTextToClipboard)(value2);
6907
7250
  setIsCopied(true);
6908
7251
  setTimeout(() => setIsCopied(false), 2e3);
6909
7252
  };
@@ -6918,11 +7261,11 @@ var copyLinkButtonController = (props) => {
6918
7261
  // src/widget/basic/color-field/color-controller.ts
6919
7262
  var import_environment10 = require("@fctc/interface-logic/environment");
6920
7263
  var import_hooks18 = require("@fctc/interface-logic/hooks");
6921
- var import_utils12 = require("@fctc/interface-logic/utils");
7264
+ var import_utils13 = require("@fctc/interface-logic/utils");
6922
7265
  var colorFieldController = (props) => {
6923
7266
  const { value, isForm, name, formValues, idForm, model, actionData } = props;
6924
7267
  const env = (0, import_environment10.getEnv)();
6925
- const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) || {} };
7268
+ const _context = { ...(0, import_utils13.evalJSONContext)(actionData?.context) || {} };
6926
7269
  const contextObject = { ...env.context, ..._context };
6927
7270
  const idDefault = isForm ? idForm : formValues?.id;
6928
7271
  const { mutate: onSave } = (0, import_hooks18.useSave)();
@@ -6950,16 +7293,16 @@ var colorFieldController = (props) => {
6950
7293
  };
6951
7294
 
6952
7295
  // src/widget/basic/binary-field/controller.ts
6953
- var import_react25 = require("react");
6954
- var import_utils13 = require("@fctc/interface-logic/utils");
7296
+ var import_react26 = require("react");
7297
+ var import_utils14 = require("@fctc/interface-logic/utils");
6955
7298
  var binaryFieldController = (props) => {
6956
7299
  const { name, methods, readonly = false, value } = props;
6957
- const inputId = (0, import_react25.useId)();
6958
- const [selectedImage, setSelectedImage] = (0, import_react25.useState)(null);
6959
- const [initialImage, setInitialImage] = (0, import_react25.useState)(value || null);
6960
- const [isInsideTable, setIsInsideTable] = (0, import_react25.useState)(false);
7300
+ const inputId = (0, import_react26.useId)();
7301
+ const [selectedImage, setSelectedImage] = (0, import_react26.useState)(null);
7302
+ const [initialImage, setInitialImage] = (0, import_react26.useState)(value || null);
7303
+ const [isInsideTable, setIsInsideTable] = (0, import_react26.useState)(false);
6961
7304
  const { setValue } = methods;
6962
- const binaryRef = (0, import_react25.useRef)(null);
7305
+ const binaryRef = (0, import_react26.useRef)(null);
6963
7306
  const convertUrlToBase64 = async (url) => {
6964
7307
  try {
6965
7308
  const response = await fetch(url);
@@ -7008,11 +7351,11 @@ var binaryFieldController = (props) => {
7008
7351
  };
7009
7352
  const checkIsImageLink = (url) => {
7010
7353
  const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
7011
- return imageExtensions.test(url) || (0, import_utils13.isBase64Image)(url) || isBlobUrl(url);
7354
+ return imageExtensions.test(url) || (0, import_utils14.isBase64Image)(url) || isBlobUrl(url);
7012
7355
  };
7013
7356
  const getImageBase64WithMimeType = (base64) => {
7014
7357
  if (typeof base64 !== "string" || base64.length < 10) return null;
7015
- if ((0, import_utils13.isBase64Image)(base64)) return base64;
7358
+ if ((0, import_utils14.isBase64Image)(base64)) return base64;
7016
7359
  let mimeType = null;
7017
7360
  if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
7018
7361
  else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
@@ -7021,14 +7364,14 @@ var binaryFieldController = (props) => {
7021
7364
  else if (base64.startsWith("UklGR")) mimeType = "image/webp";
7022
7365
  return mimeType ? `data:${mimeType};base64,${base64}` : null;
7023
7366
  };
7024
- (0, import_react25.useEffect)(() => {
7367
+ (0, import_react26.useEffect)(() => {
7025
7368
  return () => {
7026
7369
  if (selectedImage) {
7027
7370
  URL.revokeObjectURL(selectedImage);
7028
7371
  }
7029
7372
  };
7030
7373
  }, [selectedImage]);
7031
- (0, import_react25.useEffect)(() => {
7374
+ (0, import_react26.useEffect)(() => {
7032
7375
  if (binaryRef.current) {
7033
7376
  const isInsideTable2 = !!binaryRef.current.closest("table");
7034
7377
  setIsInsideTable(isInsideTable2);
@@ -7062,6 +7405,7 @@ var binaryFieldController = (props) => {
7062
7405
  many2oneButtonController,
7063
7406
  many2oneFieldController,
7064
7407
  priorityFieldController,
7408
+ searchController,
7065
7409
  statusDropdownController,
7066
7410
  tableBodyController,
7067
7411
  tableController,