@fctc/widget-logic 2.7.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.mts +3 -4
- package/dist/hooks.d.ts +3 -4
- package/dist/hooks.js +113 -117
- package/dist/hooks.mjs +108 -112
- package/dist/index.js +159 -181
- package/dist/index.mjs +131 -153
- package/dist/widget.d.mts +0 -1
- package/dist/widget.d.ts +0 -1
- package/dist/widget.js +89 -79
- package/dist/widget.mjs +63 -53
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -55,7 +55,7 @@ var require_moment = __commonJS({
|
|
|
55
55
|
function hasOwnProp(a, b) {
|
|
56
56
|
return Object.prototype.hasOwnProperty.call(a, b);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function isObjectEmpty5(obj) {
|
|
59
59
|
if (Object.getOwnPropertyNames) {
|
|
60
60
|
return Object.getOwnPropertyNames(obj).length === 0;
|
|
61
61
|
} else {
|
|
@@ -2194,7 +2194,7 @@ var require_moment = __commonJS({
|
|
|
2194
2194
|
strict = locale2;
|
|
2195
2195
|
locale2 = void 0;
|
|
2196
2196
|
}
|
|
2197
|
-
if (isObject(input) &&
|
|
2197
|
+
if (isObject(input) && isObjectEmpty5(input) || isArray(input) && input.length === 0) {
|
|
2198
2198
|
input = void 0;
|
|
2199
2199
|
}
|
|
2200
2200
|
c._isAMomentObject = true;
|
|
@@ -2613,7 +2613,7 @@ var require_moment = __commonJS({
|
|
|
2613
2613
|
return isMoment(input) || isDate(input) || isString(input) || isNumber(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === void 0;
|
|
2614
2614
|
}
|
|
2615
2615
|
function isMomentInputObject(input) {
|
|
2616
|
-
var objectTest = isObject(input) && !
|
|
2616
|
+
var objectTest = isObject(input) && !isObjectEmpty5(input), propertyTest = false, properties = [
|
|
2617
2617
|
"years",
|
|
2618
2618
|
"year",
|
|
2619
2619
|
"y",
|
|
@@ -2655,7 +2655,7 @@ var require_moment = __commonJS({
|
|
|
2655
2655
|
return arrayTest && dataTypeTest;
|
|
2656
2656
|
}
|
|
2657
2657
|
function isCalendarSpec(input) {
|
|
2658
|
-
var objectTest = isObject(input) && !
|
|
2658
|
+
var objectTest = isObject(input) && !isObjectEmpty5(input), propertyTest = false, properties = [
|
|
2659
2659
|
"sameDay",
|
|
2660
2660
|
"nextDay",
|
|
2661
2661
|
"lastDay",
|
|
@@ -4119,7 +4119,7 @@ var import_hooks3 = require("@fctc/interface-logic/hooks");
|
|
|
4119
4119
|
var import_react9 = require("react");
|
|
4120
4120
|
|
|
4121
4121
|
// src/hooks/core/use-menu.ts
|
|
4122
|
-
var
|
|
4122
|
+
var import_react4 = require("react");
|
|
4123
4123
|
|
|
4124
4124
|
// src/hooks/core/use-call-action.ts
|
|
4125
4125
|
var import_react2 = require("react");
|
|
@@ -4128,15 +4128,6 @@ var import_react2 = require("react");
|
|
|
4128
4128
|
var provider_exports = {};
|
|
4129
4129
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
4130
4130
|
|
|
4131
|
-
// src/hooks/core/use-detail.ts
|
|
4132
|
-
var import_react_query = require("@tanstack/react-query");
|
|
4133
|
-
var import_react4 = require("react");
|
|
4134
|
-
|
|
4135
|
-
// src/hooks/core/use-profile.ts
|
|
4136
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
4137
|
-
var import_react6 = require("react");
|
|
4138
|
-
var import_react_i18next = require("react-i18next");
|
|
4139
|
-
|
|
4140
4131
|
// src/utils.ts
|
|
4141
4132
|
var utils_exports = {};
|
|
4142
4133
|
__export(utils_exports, {
|
|
@@ -4158,7 +4149,7 @@ var languages = [
|
|
|
4158
4149
|
];
|
|
4159
4150
|
|
|
4160
4151
|
// src/utils/function.ts
|
|
4161
|
-
var
|
|
4152
|
+
var import_react3 = require("react");
|
|
4162
4153
|
var countSum = (data, field) => {
|
|
4163
4154
|
if (!data || !field) return 0;
|
|
4164
4155
|
return data.reduce(
|
|
@@ -4279,7 +4270,7 @@ var STORAGES = {
|
|
|
4279
4270
|
USER_INFO: "USER_INFO"
|
|
4280
4271
|
};
|
|
4281
4272
|
function useAsyncState(initialValue = [true, null]) {
|
|
4282
|
-
return (0,
|
|
4273
|
+
return (0, import_react3.useReducer)(
|
|
4283
4274
|
(_state, action = null) => [false, action],
|
|
4284
4275
|
initialValue
|
|
4285
4276
|
);
|
|
@@ -4297,7 +4288,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
4297
4288
|
}
|
|
4298
4289
|
function useStorageState(key) {
|
|
4299
4290
|
const [state, setState] = useAsyncState();
|
|
4300
|
-
(0,
|
|
4291
|
+
(0, import_react3.useEffect)(() => {
|
|
4301
4292
|
try {
|
|
4302
4293
|
const storedValue = localStorage.getItem(key);
|
|
4303
4294
|
setState(storedValue);
|
|
@@ -4305,7 +4296,7 @@ function useStorageState(key) {
|
|
|
4305
4296
|
console.error("Local storage is unavailable:", e);
|
|
4306
4297
|
}
|
|
4307
4298
|
}, [key]);
|
|
4308
|
-
const setValue = (0,
|
|
4299
|
+
const setValue = (0, import_react3.useCallback)(
|
|
4309
4300
|
(value) => {
|
|
4310
4301
|
setState(value);
|
|
4311
4302
|
setStorageItemAsync(key, value);
|
|
@@ -4318,6 +4309,15 @@ function useStorageState(key) {
|
|
|
4318
4309
|
// src/utils.ts
|
|
4319
4310
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4320
4311
|
|
|
4312
|
+
// src/hooks/core/use-detail.ts
|
|
4313
|
+
var import_react_query = require("@tanstack/react-query");
|
|
4314
|
+
var import_react5 = require("react");
|
|
4315
|
+
|
|
4316
|
+
// src/hooks/core/use-profile.ts
|
|
4317
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
4318
|
+
var import_react6 = require("react");
|
|
4319
|
+
var import_react_i18next = require("react-i18next");
|
|
4320
|
+
|
|
4321
4321
|
// src/hooks/core/use-view-v2.ts
|
|
4322
4322
|
var import_react7 = require("react");
|
|
4323
4323
|
|
|
@@ -4341,10 +4341,38 @@ var import_react10 = require("react");
|
|
|
4341
4341
|
|
|
4342
4342
|
// src/hooks/core/use-get-specification.ts
|
|
4343
4343
|
var import_react11 = require("react");
|
|
4344
|
+
var useGetSpecification = ({
|
|
4345
|
+
model,
|
|
4346
|
+
viewData,
|
|
4347
|
+
fields
|
|
4348
|
+
}) => {
|
|
4349
|
+
const baseModel = (0, import_react11.useMemo)(
|
|
4350
|
+
() => ({
|
|
4351
|
+
name: String(model),
|
|
4352
|
+
view: viewData || {},
|
|
4353
|
+
fields
|
|
4354
|
+
}),
|
|
4355
|
+
[model, viewData]
|
|
4356
|
+
);
|
|
4357
|
+
const initModel = (0, import_hooks3.useModel)();
|
|
4358
|
+
const modelInstance = (0, import_react11.useMemo)(() => {
|
|
4359
|
+
if (viewData) {
|
|
4360
|
+
return initModel.initModel(baseModel);
|
|
4361
|
+
}
|
|
4362
|
+
return null;
|
|
4363
|
+
}, [baseModel, viewData]);
|
|
4364
|
+
const specification = (0, import_react11.useMemo)(() => {
|
|
4365
|
+
if (modelInstance) {
|
|
4366
|
+
return modelInstance.getSpecification();
|
|
4367
|
+
}
|
|
4368
|
+
return null;
|
|
4369
|
+
}, [modelInstance]);
|
|
4370
|
+
return { specification };
|
|
4371
|
+
};
|
|
4344
4372
|
|
|
4345
4373
|
// src/hooks/core/use-list-data.ts
|
|
4346
4374
|
var import_react15 = require("react");
|
|
4347
|
-
var
|
|
4375
|
+
var import_utils5 = require("@fctc/interface-logic/utils");
|
|
4348
4376
|
|
|
4349
4377
|
// src/hooks/utils/use-click-outside.ts
|
|
4350
4378
|
var import_react12 = require("react");
|
|
@@ -4615,18 +4643,18 @@ var many2oneFieldController = (props) => {
|
|
|
4615
4643
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
4616
4644
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
4617
4645
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
4618
|
-
var
|
|
4646
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
4619
4647
|
var many2oneButtonController = (props) => {
|
|
4620
4648
|
const { domain, methods, relation, service, xNode } = props;
|
|
4621
4649
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
4622
4650
|
const env = (0, import_environment2.getEnv)();
|
|
4623
|
-
const domainObject = (0,
|
|
4651
|
+
const domainObject = (0, import_utils8.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
4624
4652
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
4625
4653
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
4626
4654
|
data: {
|
|
4627
4655
|
model: relation ?? "",
|
|
4628
4656
|
domain: domainObject,
|
|
4629
|
-
context: { ...env.context, ...(0,
|
|
4657
|
+
context: { ...env.context, ...(0, import_utils8.evalJSONContext)(actionData?.context) }
|
|
4630
4658
|
},
|
|
4631
4659
|
queryKey: [`data_${relation}`, domainObject],
|
|
4632
4660
|
service,
|
|
@@ -4643,7 +4671,7 @@ var many2oneButtonController = (props) => {
|
|
|
4643
4671
|
|
|
4644
4672
|
// src/widget/basic/many2many-field/controller.ts
|
|
4645
4673
|
var import_react17 = require("react");
|
|
4646
|
-
var
|
|
4674
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
4647
4675
|
var many2manyFieldController = (props) => {
|
|
4648
4676
|
const {
|
|
4649
4677
|
relation,
|
|
@@ -4653,8 +4681,7 @@ var many2manyFieldController = (props) => {
|
|
|
4653
4681
|
tab,
|
|
4654
4682
|
setSelectedRowKeys: setSelectedRowKeys2,
|
|
4655
4683
|
groupByDomain,
|
|
4656
|
-
enabled: enabledCallAPI
|
|
4657
|
-
actionData
|
|
4684
|
+
enabled: enabledCallAPI
|
|
4658
4685
|
} = props;
|
|
4659
4686
|
const { env } = (0, provider_exports.useEnv)();
|
|
4660
4687
|
const { useGetView: useGetView2, useGetListData: useGetListData2, useGetFormView: useGetFormView2 } = (0, provider_exports.useService)();
|
|
@@ -4678,36 +4705,19 @@ var many2manyFieldController = (props) => {
|
|
|
4678
4705
|
viewParams,
|
|
4679
4706
|
enabled: enabledCallAPI
|
|
4680
4707
|
});
|
|
4681
|
-
const
|
|
4682
|
-
()
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
fields: [
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
]
|
|
4690
|
-
}),
|
|
4691
|
-
[relation, viewResponse]
|
|
4692
|
-
);
|
|
4693
|
-
const initModel = (0, import_hooks3.useModel)();
|
|
4694
|
-
const modelInstance = (0, import_react17.useMemo)(() => {
|
|
4695
|
-
if (viewResponse) {
|
|
4696
|
-
return initModel.initModel(baseModel);
|
|
4697
|
-
}
|
|
4698
|
-
return null;
|
|
4699
|
-
}, [baseModel, viewResponse]);
|
|
4700
|
-
const specification = (0, import_react17.useMemo)(() => {
|
|
4701
|
-
if (modelInstance) {
|
|
4702
|
-
return modelInstance.getSpecification();
|
|
4703
|
-
}
|
|
4704
|
-
return null;
|
|
4705
|
-
}, [modelInstance]);
|
|
4708
|
+
const { specification } = useGetSpecification({
|
|
4709
|
+
model: String(relation),
|
|
4710
|
+
viewData: viewResponse || {},
|
|
4711
|
+
fields: [
|
|
4712
|
+
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
4713
|
+
...tab?.fields ? tab.fields : []
|
|
4714
|
+
]
|
|
4715
|
+
});
|
|
4706
4716
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4707
|
-
const optionsObject = tab?.options ? (0,
|
|
4717
|
+
const optionsObject = tab?.options ? (0, import_utils9.evalJSONContext)(tab?.options) : (options ? (0, import_utils9.evalJSONContext)(options) : {}) || {};
|
|
4708
4718
|
const fetchData = async () => {
|
|
4709
4719
|
try {
|
|
4710
|
-
const domainParse = typeof domain === "string" ? (0,
|
|
4720
|
+
const domainParse = typeof domain === "string" ? (0, import_utils9.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
4711
4721
|
setDomainMany2Many(domainParse);
|
|
4712
4722
|
setPage(0);
|
|
4713
4723
|
} catch (err) {
|
|
@@ -4731,7 +4741,7 @@ var many2manyFieldController = (props) => {
|
|
|
4731
4741
|
context: contextObject,
|
|
4732
4742
|
fields: groupByDomain?.fields,
|
|
4733
4743
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4734
|
-
sort: order ? order : default_order ? (0,
|
|
4744
|
+
sort: order ? order : default_order ? (0, import_utils9.formatSortingString)(default_order) : ""
|
|
4735
4745
|
};
|
|
4736
4746
|
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4737
4747
|
const {
|
|
@@ -4795,7 +4805,7 @@ var many2manyFieldController = (props) => {
|
|
|
4795
4805
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
4796
4806
|
var import_react18 = require("react");
|
|
4797
4807
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
4798
|
-
var
|
|
4808
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
4799
4809
|
var many2manyTagsController = (props) => {
|
|
4800
4810
|
const {
|
|
4801
4811
|
relation,
|
|
@@ -4810,9 +4820,9 @@ var many2manyTagsController = (props) => {
|
|
|
4810
4820
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
4811
4821
|
const { env } = (0, provider_exports.useEnv)();
|
|
4812
4822
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
4813
|
-
const addtionalFields = optionsFields ? (0,
|
|
4823
|
+
const addtionalFields = optionsFields ? (0, import_utils10.evalJSONContext)(optionsFields) : null;
|
|
4814
4824
|
const domainObject = (0, import_react18.useMemo)(
|
|
4815
|
-
() => (0,
|
|
4825
|
+
() => (0, import_utils10.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
4816
4826
|
[domain, formValues]
|
|
4817
4827
|
);
|
|
4818
4828
|
const data = {
|
|
@@ -4857,7 +4867,7 @@ var many2manyTagsController = (props) => {
|
|
|
4857
4867
|
|
|
4858
4868
|
// src/widget/basic/status-bar-field/controller.ts
|
|
4859
4869
|
var import_react19 = require("react");
|
|
4860
|
-
var
|
|
4870
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
4861
4871
|
var durationController = (props) => {
|
|
4862
4872
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
4863
4873
|
const specification = {
|
|
@@ -4873,7 +4883,7 @@ var durationController = (props) => {
|
|
|
4873
4883
|
const listDataProps = {
|
|
4874
4884
|
model: relation,
|
|
4875
4885
|
specification,
|
|
4876
|
-
domain: (0,
|
|
4886
|
+
domain: (0, import_utils11.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
4877
4887
|
limit: 10,
|
|
4878
4888
|
offset: 0,
|
|
4879
4889
|
fields: "",
|
|
@@ -4923,10 +4933,10 @@ var durationController = (props) => {
|
|
|
4923
4933
|
};
|
|
4924
4934
|
|
|
4925
4935
|
// src/widget/basic/priority-field/controller.ts
|
|
4926
|
-
var
|
|
4936
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
4927
4937
|
var priorityFieldController = (props) => {
|
|
4928
4938
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
4929
|
-
const _context = { ...(0,
|
|
4939
|
+
const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) };
|
|
4930
4940
|
const contextObject = { ...context, ..._context };
|
|
4931
4941
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
4932
4942
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -5894,12 +5904,12 @@ var dateFieldController = (props) => {
|
|
|
5894
5904
|
|
|
5895
5905
|
// src/widget/basic/copy-link-button/controller.ts
|
|
5896
5906
|
var import_react21 = require("react");
|
|
5897
|
-
var
|
|
5907
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
5898
5908
|
var copyLinkButtonController = (props) => {
|
|
5899
5909
|
const { value, defaultValue } = props;
|
|
5900
5910
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
5901
5911
|
const handleCopyToClipboard = async (value2) => {
|
|
5902
|
-
await (0,
|
|
5912
|
+
await (0, import_utils13.copyTextToClipboard)(value2);
|
|
5903
5913
|
setIsCopied(true);
|
|
5904
5914
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
5905
5915
|
};
|
|
@@ -5912,12 +5922,12 @@ var copyLinkButtonController = (props) => {
|
|
|
5912
5922
|
};
|
|
5913
5923
|
|
|
5914
5924
|
// src/widget/basic/color-field/color-controller.ts
|
|
5915
|
-
var
|
|
5925
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
5916
5926
|
var colorFieldController = (props) => {
|
|
5917
5927
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
5918
5928
|
const { env } = (0, provider_exports.useEnv)();
|
|
5919
5929
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5920
|
-
const _context = { ...(0,
|
|
5930
|
+
const _context = { ...(0, import_utils14.evalJSONContext)(actionData?.context) || {} };
|
|
5921
5931
|
const contextObject = { ...env.context, ..._context };
|
|
5922
5932
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
5923
5933
|
const { mutate: onSave } = useSave3();
|
|
@@ -5946,7 +5956,7 @@ var colorFieldController = (props) => {
|
|
|
5946
5956
|
|
|
5947
5957
|
// src/widget/basic/binary-field/controller.ts
|
|
5948
5958
|
var import_react22 = require("react");
|
|
5949
|
-
var
|
|
5959
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
5950
5960
|
var binaryFieldController = (props) => {
|
|
5951
5961
|
const { name, methods, readonly = false, value } = props;
|
|
5952
5962
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6003,11 +6013,11 @@ var binaryFieldController = (props) => {
|
|
|
6003
6013
|
};
|
|
6004
6014
|
const checkIsImageLink = (url) => {
|
|
6005
6015
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6006
|
-
return imageExtensions.test(url) || (0,
|
|
6016
|
+
return imageExtensions.test(url) || (0, import_utils15.isBase64Image)(url) || isBlobUrl(url);
|
|
6007
6017
|
};
|
|
6008
6018
|
const getImageBase64WithMimeType = (base64) => {
|
|
6009
6019
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6010
|
-
if ((0,
|
|
6020
|
+
if ((0, import_utils15.isBase64Image)(base64)) return base64;
|
|
6011
6021
|
let mimeType = null;
|
|
6012
6022
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6013
6023
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6110,7 +6120,7 @@ var tableHeadController = (props) => {
|
|
|
6110
6120
|
|
|
6111
6121
|
// src/widget/advance/table/table-view/controller.ts
|
|
6112
6122
|
var import_react24 = require("react");
|
|
6113
|
-
var
|
|
6123
|
+
var import_utils17 = require("@fctc/interface-logic/utils");
|
|
6114
6124
|
var tableController = ({ data }) => {
|
|
6115
6125
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6116
6126
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6148,7 +6158,7 @@ var tableController = ({ data }) => {
|
|
|
6148
6158
|
let cols = [];
|
|
6149
6159
|
try {
|
|
6150
6160
|
cols = mergeFields?.filter((item) => {
|
|
6151
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6161
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils17.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils17.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
6152
6162
|
})?.map((field) => {
|
|
6153
6163
|
return {
|
|
6154
6164
|
name: field?.name,
|
|
@@ -6332,7 +6342,7 @@ var tableGroupController = (props) => {
|
|
|
6332
6342
|
|
|
6333
6343
|
// src/widget/advance/search/controller.ts
|
|
6334
6344
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6335
|
-
var
|
|
6345
|
+
var import_utils19 = require("@fctc/interface-logic/utils");
|
|
6336
6346
|
var import_moment2 = __toESM(require_moment());
|
|
6337
6347
|
var import_react26 = require("react");
|
|
6338
6348
|
var searchController = ({
|
|
@@ -6349,9 +6359,9 @@ var searchController = ({
|
|
|
6349
6359
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
6350
6360
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
6351
6361
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
6352
|
-
const actionContext = typeof context === "string" ? (0,
|
|
6362
|
+
const actionContext = typeof context === "string" ? (0, import_utils19.evalJSONContext)(context) : context;
|
|
6353
6363
|
const contextSearch = { ...env.context, ...actionContext };
|
|
6354
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
6364
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils19.evalJSONDomain)(domain, contextSearch) : [];
|
|
6355
6365
|
const clearSearch = () => {
|
|
6356
6366
|
setFilterBy([]);
|
|
6357
6367
|
setGroupBy([]);
|
|
@@ -6366,7 +6376,7 @@ var searchController = ({
|
|
|
6366
6376
|
const dataModel = viewData?.models?.[model];
|
|
6367
6377
|
const searchViews = viewData?.views?.search;
|
|
6368
6378
|
const searchByItems = searchViews?.search_by?.filter(
|
|
6369
|
-
(item) => !
|
|
6379
|
+
(item) => !import_utils19.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
6370
6380
|
)?.map(
|
|
6371
6381
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
6372
6382
|
dataIndex: index,
|
|
@@ -6379,10 +6389,10 @@ var searchController = ({
|
|
|
6379
6389
|
})
|
|
6380
6390
|
);
|
|
6381
6391
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
6382
|
-
return !
|
|
6392
|
+
return !import_utils19.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
6383
6393
|
})?.map((item) => ({ ...item, active: false }));
|
|
6384
6394
|
const groupByItems = searchViews?.group_by.filter(
|
|
6385
|
-
(item) => !
|
|
6395
|
+
(item) => !import_utils19.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
6386
6396
|
).map((item) => ({
|
|
6387
6397
|
...item,
|
|
6388
6398
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -6459,14 +6469,14 @@ var searchController = ({
|
|
|
6459
6469
|
}
|
|
6460
6470
|
let valueDomainItem = value?.value;
|
|
6461
6471
|
if (value?.modelType === "date") {
|
|
6462
|
-
valueDomainItem = (0,
|
|
6472
|
+
valueDomainItem = (0, import_utils19.validateAndParseDate)(value?.value);
|
|
6463
6473
|
} else if (value?.modelType === "datetime") {
|
|
6464
6474
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6465
|
-
const parsedDate = (0,
|
|
6475
|
+
const parsedDate = (0, import_utils19.validateAndParseDate)(value?.value, true);
|
|
6466
6476
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6467
6477
|
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");
|
|
6468
6478
|
} else {
|
|
6469
|
-
valueDomainItem = (0,
|
|
6479
|
+
valueDomainItem = (0, import_utils19.validateAndParseDate)(value?.value, true);
|
|
6470
6480
|
}
|
|
6471
6481
|
}
|
|
6472
6482
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -6545,7 +6555,7 @@ var searchController = ({
|
|
|
6545
6555
|
}, [searchMap]);
|
|
6546
6556
|
const handleAddTagSearch = (tag) => {
|
|
6547
6557
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
6548
|
-
const domainFormat = new
|
|
6558
|
+
const domainFormat = new import_utils19.domainHelper.Domain(domain2);
|
|
6549
6559
|
if (type === import_constants3.SearchType.FILTER) {
|
|
6550
6560
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
6551
6561
|
...tag,
|