@fctc/widget-logic 2.8.2 → 2.8.4
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 +20 -7
- package/dist/hooks.d.ts +20 -7
- package/dist/hooks.js +102 -61
- package/dist/hooks.mjs +96 -55
- package/dist/index.js +135 -94
- package/dist/index.mjs +108 -67
- package/dist/widget.js +39 -39
- package/dist/widget.mjs +15 -15
- package/package.json +96 -96
package/dist/index.js
CHANGED
|
@@ -4167,51 +4167,12 @@ var import_react8 = require("react");
|
|
|
4167
4167
|
var import_react3 = require("react");
|
|
4168
4168
|
|
|
4169
4169
|
// src/hooks/core/use-call-action.ts
|
|
4170
|
-
var
|
|
4170
|
+
var import_react2 = require("react");
|
|
4171
4171
|
|
|
4172
4172
|
// src/provider.ts
|
|
4173
4173
|
var provider_exports = {};
|
|
4174
4174
|
__reExport(provider_exports, require("@fctc/interface-logic/provider"));
|
|
4175
4175
|
|
|
4176
|
-
// src/hooks/core/use-call-action.ts
|
|
4177
|
-
var useCallAction = () => {
|
|
4178
|
-
const { env } = (0, provider_exports.useEnv)();
|
|
4179
|
-
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
4180
|
-
const queryLoadAction = useLoadAction2();
|
|
4181
|
-
const queryRunAction = useRunAction2();
|
|
4182
|
-
const [actionData, setActionData] = (0, import_react.useState)(
|
|
4183
|
-
void 0
|
|
4184
|
-
);
|
|
4185
|
-
const callAction = (0, import_react.useCallback)(
|
|
4186
|
-
async ({
|
|
4187
|
-
aid
|
|
4188
|
-
}) => {
|
|
4189
|
-
try {
|
|
4190
|
-
const loadRes = await queryLoadAction.mutateAsync({
|
|
4191
|
-
idAction: aid,
|
|
4192
|
-
context: env.context
|
|
4193
|
-
});
|
|
4194
|
-
if (loadRes?.result?.type === "ir.actions.server") {
|
|
4195
|
-
const runRes = await queryRunAction.mutateAsync({
|
|
4196
|
-
idAction: aid,
|
|
4197
|
-
context: env.context
|
|
4198
|
-
});
|
|
4199
|
-
setActionData(runRes?.result);
|
|
4200
|
-
return runRes?.result;
|
|
4201
|
-
} else {
|
|
4202
|
-
setActionData(loadRes?.result);
|
|
4203
|
-
return loadRes?.result;
|
|
4204
|
-
}
|
|
4205
|
-
} catch (err) {
|
|
4206
|
-
console.error("callAction error:", err);
|
|
4207
|
-
return void 0;
|
|
4208
|
-
}
|
|
4209
|
-
},
|
|
4210
|
-
[env?.context?.lang]
|
|
4211
|
-
);
|
|
4212
|
-
return [actionData, callAction];
|
|
4213
|
-
};
|
|
4214
|
-
|
|
4215
4176
|
// src/utils.ts
|
|
4216
4177
|
var utils_exports = {};
|
|
4217
4178
|
__export(utils_exports, {
|
|
@@ -4233,7 +4194,7 @@ var languages = [
|
|
|
4233
4194
|
];
|
|
4234
4195
|
|
|
4235
4196
|
// src/utils/function.ts
|
|
4236
|
-
var
|
|
4197
|
+
var import_react = require("react");
|
|
4237
4198
|
var countSum = (data, field) => {
|
|
4238
4199
|
if (!data || !field) return 0;
|
|
4239
4200
|
return data.reduce(
|
|
@@ -4354,7 +4315,7 @@ var STORAGES = {
|
|
|
4354
4315
|
USER_INFO: "USER_INFO"
|
|
4355
4316
|
};
|
|
4356
4317
|
function useAsyncState(initialValue = [true, null]) {
|
|
4357
|
-
return (0,
|
|
4318
|
+
return (0, import_react.useReducer)(
|
|
4358
4319
|
(_state, action = null) => [false, action],
|
|
4359
4320
|
initialValue
|
|
4360
4321
|
);
|
|
@@ -4372,7 +4333,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
4372
4333
|
}
|
|
4373
4334
|
function useStorageState(key) {
|
|
4374
4335
|
const [state, setState] = useAsyncState();
|
|
4375
|
-
(0,
|
|
4336
|
+
(0, import_react.useEffect)(() => {
|
|
4376
4337
|
try {
|
|
4377
4338
|
const storedValue = localStorage.getItem(key);
|
|
4378
4339
|
setState(storedValue);
|
|
@@ -4380,7 +4341,7 @@ function useStorageState(key) {
|
|
|
4380
4341
|
console.error("Local storage is unavailable:", e);
|
|
4381
4342
|
}
|
|
4382
4343
|
}, [key]);
|
|
4383
|
-
const setValue = (0,
|
|
4344
|
+
const setValue = (0, import_react.useCallback)(
|
|
4384
4345
|
(value) => {
|
|
4385
4346
|
setState(value);
|
|
4386
4347
|
setStorageItemAsync(key, value);
|
|
@@ -4393,18 +4354,74 @@ function useStorageState(key) {
|
|
|
4393
4354
|
// src/utils.ts
|
|
4394
4355
|
__reExport(utils_exports, require("@fctc/interface-logic/utils"));
|
|
4395
4356
|
|
|
4357
|
+
// src/hooks/core/use-call-action.ts
|
|
4358
|
+
var useCallAction = () => {
|
|
4359
|
+
const { env } = (0, provider_exports.useEnv)();
|
|
4360
|
+
const { useLoadAction: useLoadAction2, useRunAction: useRunAction2 } = (0, provider_exports.useService)();
|
|
4361
|
+
const queryLoadAction = useLoadAction2();
|
|
4362
|
+
const queryRunAction = useRunAction2();
|
|
4363
|
+
const [actionData, setActionData] = (0, import_react2.useState)(
|
|
4364
|
+
void 0
|
|
4365
|
+
);
|
|
4366
|
+
const callAction = (0, import_react2.useCallback)(
|
|
4367
|
+
async ({
|
|
4368
|
+
aid,
|
|
4369
|
+
service,
|
|
4370
|
+
xNode,
|
|
4371
|
+
context
|
|
4372
|
+
}) => {
|
|
4373
|
+
try {
|
|
4374
|
+
const loadRes = await queryLoadAction.mutateAsync({
|
|
4375
|
+
idAction: aid,
|
|
4376
|
+
context: {
|
|
4377
|
+
...env?.context,
|
|
4378
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
4379
|
+
},
|
|
4380
|
+
service,
|
|
4381
|
+
xNode
|
|
4382
|
+
});
|
|
4383
|
+
if (loadRes?.result?.type === "ir.actions.server") {
|
|
4384
|
+
const runRes = await queryRunAction.mutateAsync({
|
|
4385
|
+
idAction: aid,
|
|
4386
|
+
context: {
|
|
4387
|
+
...env?.context,
|
|
4388
|
+
...context ? (0, utils_exports.evalJSONContext)(context, { ...env?.context }) || {} : {}
|
|
4389
|
+
},
|
|
4390
|
+
service,
|
|
4391
|
+
xNode
|
|
4392
|
+
});
|
|
4393
|
+
setActionData(runRes?.result);
|
|
4394
|
+
return runRes?.result;
|
|
4395
|
+
} else {
|
|
4396
|
+
setActionData(loadRes?.result);
|
|
4397
|
+
return loadRes?.result;
|
|
4398
|
+
}
|
|
4399
|
+
} catch (err) {
|
|
4400
|
+
console.error("callAction error:", err);
|
|
4401
|
+
return void 0;
|
|
4402
|
+
}
|
|
4403
|
+
},
|
|
4404
|
+
[env?.context?.lang]
|
|
4405
|
+
);
|
|
4406
|
+
return [actionData, callAction];
|
|
4407
|
+
};
|
|
4408
|
+
|
|
4396
4409
|
// src/hooks/core/use-menu.ts
|
|
4397
4410
|
var useMenu = ({
|
|
4398
4411
|
context,
|
|
4399
|
-
specification
|
|
4412
|
+
specification,
|
|
4413
|
+
domain
|
|
4400
4414
|
}) => {
|
|
4401
4415
|
const { env } = (0, provider_exports.useEnv)();
|
|
4402
4416
|
const { useGetMenu: useGetMenu2 } = (0, provider_exports.useService)();
|
|
4403
4417
|
const [action, callAction] = useCallAction();
|
|
4418
|
+
const [service, setService] = (0, import_react3.useState)("");
|
|
4419
|
+
const [xNode, setXNode] = (0, import_react3.useState)("");
|
|
4404
4420
|
const menuData = useGetMenu2(
|
|
4405
4421
|
context,
|
|
4406
4422
|
specification,
|
|
4407
|
-
!!context && !(0, utils_exports.isObjectEmpty)(context)
|
|
4423
|
+
!!context && !(0, utils_exports.isObjectEmpty)(context),
|
|
4424
|
+
domain
|
|
4408
4425
|
);
|
|
4409
4426
|
const [menuId, setMenuId] = (0, import_react3.useState)(void 0);
|
|
4410
4427
|
const configedIconData = (0, import_react3.useMemo)(() => {
|
|
@@ -4422,20 +4439,30 @@ var useMenu = ({
|
|
|
4422
4439
|
};
|
|
4423
4440
|
});
|
|
4424
4441
|
}, [menuData.data, env?.envFile?.VITE_APP_DOMAIN]);
|
|
4425
|
-
const handleChangeMenu = async ({
|
|
4442
|
+
const handleChangeMenu = async ({
|
|
4443
|
+
menu,
|
|
4444
|
+
service: service2,
|
|
4445
|
+
xNode: xNode2
|
|
4446
|
+
}) => {
|
|
4426
4447
|
const aidMenu = menu?.action?.id?.id;
|
|
4427
4448
|
if (menu) {
|
|
4428
4449
|
setMenuId(menu.id?.toString() ?? "");
|
|
4429
4450
|
}
|
|
4430
4451
|
if (aidMenu) {
|
|
4431
4452
|
const actionResponse = await callAction({
|
|
4432
|
-
aid: Number(aidMenu)
|
|
4453
|
+
aid: Number(aidMenu),
|
|
4454
|
+
service: service2 ?? "",
|
|
4455
|
+
xNode: xNode2
|
|
4433
4456
|
});
|
|
4457
|
+
if (service2 && service2 !== "") setService(service2);
|
|
4458
|
+
if (xNode2 && xNode2 !== "") setXNode(xNode2);
|
|
4434
4459
|
return actionResponse;
|
|
4435
4460
|
}
|
|
4436
4461
|
};
|
|
4437
4462
|
return {
|
|
4438
4463
|
...menuData,
|
|
4464
|
+
service,
|
|
4465
|
+
xNode,
|
|
4439
4466
|
data: configedIconData,
|
|
4440
4467
|
action: { handleChangeMenu },
|
|
4441
4468
|
state: { menuId, action },
|
|
@@ -4527,7 +4554,9 @@ var import_react6 = require("react");
|
|
|
4527
4554
|
var useViewV2 = ({
|
|
4528
4555
|
action,
|
|
4529
4556
|
context,
|
|
4530
|
-
aid
|
|
4557
|
+
aid,
|
|
4558
|
+
service,
|
|
4559
|
+
xNode
|
|
4531
4560
|
}) => {
|
|
4532
4561
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4533
4562
|
const viewParams = (0, import_react6.useMemo)(() => {
|
|
@@ -4547,7 +4576,9 @@ var useViewV2 = ({
|
|
|
4547
4576
|
]
|
|
4548
4577
|
],
|
|
4549
4578
|
context,
|
|
4550
|
-
id: isNaN(Number(aid)) ? action?.id : aid
|
|
4579
|
+
id: isNaN(Number(aid)) ? action?.id : aid,
|
|
4580
|
+
service,
|
|
4581
|
+
xNode
|
|
4551
4582
|
};
|
|
4552
4583
|
}, [action, context, aid]);
|
|
4553
4584
|
const view = useGetView2({
|
|
@@ -4619,7 +4650,7 @@ var AppProviderInitialValue = {
|
|
|
4619
4650
|
var ReactContext = (0, import_react8.createContext)(AppProviderInitialValue);
|
|
4620
4651
|
var AppProvider = ({
|
|
4621
4652
|
children,
|
|
4622
|
-
|
|
4653
|
+
menuParams,
|
|
4623
4654
|
aid
|
|
4624
4655
|
}) => {
|
|
4625
4656
|
const { env } = (0, provider_exports.useEnv)();
|
|
@@ -4629,7 +4660,8 @@ var AppProvider = ({
|
|
|
4629
4660
|
return combineContexts([
|
|
4630
4661
|
{
|
|
4631
4662
|
...user?.context,
|
|
4632
|
-
...!(0, utils_exports.isObjectEmpty)(env?.user) && company?.context?.allowed_company_ids ? { lang: env?.context?.lang } : {}
|
|
4663
|
+
...!(0, utils_exports.isObjectEmpty)(env?.user) && company?.context?.allowed_company_ids ? { lang: env?.context?.lang } : {},
|
|
4664
|
+
...menuParams?.context ?? {}
|
|
4633
4665
|
},
|
|
4634
4666
|
company?.context
|
|
4635
4667
|
]);
|
|
@@ -4638,7 +4670,8 @@ var AppProvider = ({
|
|
|
4638
4670
|
context: {
|
|
4639
4671
|
...menuContext
|
|
4640
4672
|
},
|
|
4641
|
-
specification:
|
|
4673
|
+
specification: menuParams?.specification,
|
|
4674
|
+
domain: menuParams?.domain
|
|
4642
4675
|
});
|
|
4643
4676
|
const action = (0, import_react8.useMemo)(() => {
|
|
4644
4677
|
return menu?.state?.action;
|
|
@@ -4652,7 +4685,9 @@ var AppProvider = ({
|
|
|
4652
4685
|
const view = useViewV2({
|
|
4653
4686
|
action,
|
|
4654
4687
|
context: viewContext,
|
|
4655
|
-
aid
|
|
4688
|
+
aid,
|
|
4689
|
+
service: menu?.service,
|
|
4690
|
+
xNode: menu?.xNode
|
|
4656
4691
|
});
|
|
4657
4692
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
4658
4693
|
ReactContext.Provider,
|
|
@@ -4777,7 +4812,7 @@ var useGetSpecification = ({
|
|
|
4777
4812
|
|
|
4778
4813
|
// src/hooks/core/use-list-data.ts
|
|
4779
4814
|
var import_react14 = require("react");
|
|
4780
|
-
var
|
|
4815
|
+
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
4781
4816
|
|
|
4782
4817
|
// src/hooks/utils/use-click-outside.ts
|
|
4783
4818
|
var import_react11 = require("react");
|
|
@@ -4896,7 +4931,9 @@ var useListData = ({
|
|
|
4896
4931
|
action,
|
|
4897
4932
|
context,
|
|
4898
4933
|
viewData,
|
|
4899
|
-
model
|
|
4934
|
+
model,
|
|
4935
|
+
service,
|
|
4936
|
+
xNode
|
|
4900
4937
|
}) => {
|
|
4901
4938
|
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
4902
4939
|
const [page, setPage] = (0, import_react14.useState)(0);
|
|
@@ -4919,12 +4956,12 @@ var useListData = ({
|
|
|
4919
4956
|
if (!viewData || !action || !context) {
|
|
4920
4957
|
return null;
|
|
4921
4958
|
}
|
|
4922
|
-
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0,
|
|
4959
|
+
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils6.evalJSONDomain)(action?.domain, context) : [];
|
|
4923
4960
|
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
4924
4961
|
const offset = debouncedPage * pageLimit;
|
|
4925
4962
|
const fields = type === "calendar" ? convertFieldsToArray(viewData?.views?.calendar?.fields) || [] : typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
4926
4963
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
4927
|
-
const sort = order ? order : viewData?.views?.list?.default_order ? (0,
|
|
4964
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils6.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
4928
4965
|
return {
|
|
4929
4966
|
model: action.res_model,
|
|
4930
4967
|
specification,
|
|
@@ -4935,7 +4972,9 @@ var useListData = ({
|
|
|
4935
4972
|
groupby,
|
|
4936
4973
|
context,
|
|
4937
4974
|
sort,
|
|
4938
|
-
type
|
|
4975
|
+
type,
|
|
4976
|
+
service,
|
|
4977
|
+
xNode
|
|
4939
4978
|
};
|
|
4940
4979
|
}, [
|
|
4941
4980
|
action,
|
|
@@ -4947,12 +4986,14 @@ var useListData = ({
|
|
|
4947
4986
|
debouncedPage,
|
|
4948
4987
|
pageLimit,
|
|
4949
4988
|
type,
|
|
4950
|
-
debouncedDomain
|
|
4989
|
+
debouncedDomain,
|
|
4990
|
+
service,
|
|
4991
|
+
xNode
|
|
4951
4992
|
]);
|
|
4952
4993
|
const list = useGetListData2(
|
|
4953
4994
|
listDataProps,
|
|
4954
4995
|
[listDataProps],
|
|
4955
|
-
!!listDataProps && !!specification && !(0,
|
|
4996
|
+
!!listDataProps && !!specification && !(0, import_utils6.isObjectEmpty)(specification)
|
|
4956
4997
|
);
|
|
4957
4998
|
return {
|
|
4958
4999
|
...list,
|
|
@@ -5458,18 +5499,18 @@ var many2oneFieldController = (props) => {
|
|
|
5458
5499
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5459
5500
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
5460
5501
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
5461
|
-
var
|
|
5502
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5462
5503
|
var many2oneButtonController = (props) => {
|
|
5463
5504
|
const { domain, methods, relation, service, xNode } = props;
|
|
5464
5505
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5465
5506
|
const env = (0, import_environment2.getEnv)();
|
|
5466
|
-
const domainObject = (0,
|
|
5507
|
+
const domainObject = (0, import_utils9.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5467
5508
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5468
5509
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
5469
5510
|
data: {
|
|
5470
5511
|
model: relation ?? "",
|
|
5471
5512
|
domain: domainObject,
|
|
5472
|
-
context: { ...env.context, ...(0,
|
|
5513
|
+
context: { ...env.context, ...(0, import_utils9.evalJSONContext)(actionData?.context) }
|
|
5473
5514
|
},
|
|
5474
5515
|
queryKey: [`data_${relation}`, domainObject],
|
|
5475
5516
|
service,
|
|
@@ -5486,7 +5527,7 @@ var many2oneButtonController = (props) => {
|
|
|
5486
5527
|
|
|
5487
5528
|
// src/widget/basic/many2many-field/controller.ts
|
|
5488
5529
|
var import_react17 = require("react");
|
|
5489
|
-
var
|
|
5530
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5490
5531
|
var many2manyFieldController = (props) => {
|
|
5491
5532
|
const {
|
|
5492
5533
|
relation,
|
|
@@ -5529,10 +5570,10 @@ var many2manyFieldController = (props) => {
|
|
|
5529
5570
|
]
|
|
5530
5571
|
});
|
|
5531
5572
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5532
|
-
const optionsObject = tab?.options ? (0,
|
|
5573
|
+
const optionsObject = tab?.options ? (0, import_utils10.evalJSONContext)(tab?.options) : (options ? (0, import_utils10.evalJSONContext)(options) : {}) || {};
|
|
5533
5574
|
const fetchData = async () => {
|
|
5534
5575
|
try {
|
|
5535
|
-
const domainParse = typeof domain === "string" ? (0,
|
|
5576
|
+
const domainParse = typeof domain === "string" ? (0, import_utils10.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5536
5577
|
setDomainMany2Many(domainParse);
|
|
5537
5578
|
setPage(0);
|
|
5538
5579
|
} catch (err) {
|
|
@@ -5556,7 +5597,7 @@ var many2manyFieldController = (props) => {
|
|
|
5556
5597
|
context: contextObject,
|
|
5557
5598
|
fields: groupByDomain?.fields,
|
|
5558
5599
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5559
|
-
sort: order ? order : default_order ? (0,
|
|
5600
|
+
sort: order ? order : default_order ? (0, import_utils10.formatSortingString)(default_order) : ""
|
|
5560
5601
|
};
|
|
5561
5602
|
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5562
5603
|
const {
|
|
@@ -5620,7 +5661,7 @@ var many2manyFieldController = (props) => {
|
|
|
5620
5661
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5621
5662
|
var import_react18 = require("react");
|
|
5622
5663
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
5623
|
-
var
|
|
5664
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
5624
5665
|
var many2manyTagsController = (props) => {
|
|
5625
5666
|
const {
|
|
5626
5667
|
relation,
|
|
@@ -5635,9 +5676,9 @@ var many2manyTagsController = (props) => {
|
|
|
5635
5676
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5636
5677
|
const { env } = (0, provider_exports.useEnv)();
|
|
5637
5678
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5638
|
-
const addtionalFields = optionsFields ? (0,
|
|
5679
|
+
const addtionalFields = optionsFields ? (0, import_utils11.evalJSONContext)(optionsFields) : null;
|
|
5639
5680
|
const domainObject = (0, import_react18.useMemo)(
|
|
5640
|
-
() => (0,
|
|
5681
|
+
() => (0, import_utils11.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5641
5682
|
[domain, formValues]
|
|
5642
5683
|
);
|
|
5643
5684
|
const data = {
|
|
@@ -5681,7 +5722,7 @@ var many2manyTagsController = (props) => {
|
|
|
5681
5722
|
|
|
5682
5723
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5683
5724
|
var import_react19 = require("react");
|
|
5684
|
-
var
|
|
5725
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
5685
5726
|
var durationController = (props) => {
|
|
5686
5727
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5687
5728
|
const specification = {
|
|
@@ -5697,7 +5738,7 @@ var durationController = (props) => {
|
|
|
5697
5738
|
const listDataProps = {
|
|
5698
5739
|
model: relation,
|
|
5699
5740
|
specification,
|
|
5700
|
-
domain: (0,
|
|
5741
|
+
domain: (0, import_utils12.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5701
5742
|
limit: 10,
|
|
5702
5743
|
offset: 0,
|
|
5703
5744
|
fields: "",
|
|
@@ -5747,10 +5788,10 @@ var durationController = (props) => {
|
|
|
5747
5788
|
};
|
|
5748
5789
|
|
|
5749
5790
|
// src/widget/basic/priority-field/controller.ts
|
|
5750
|
-
var
|
|
5791
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
5751
5792
|
var priorityFieldController = (props) => {
|
|
5752
5793
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
5753
|
-
const _context = { ...(0,
|
|
5794
|
+
const _context = { ...(0, import_utils13.evalJSONContext)(actionData?.context) };
|
|
5754
5795
|
const contextObject = { ...context, ..._context };
|
|
5755
5796
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5756
5797
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -6718,12 +6759,12 @@ var dateFieldController = (props) => {
|
|
|
6718
6759
|
|
|
6719
6760
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6720
6761
|
var import_react21 = require("react");
|
|
6721
|
-
var
|
|
6762
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6722
6763
|
var copyLinkButtonController = (props) => {
|
|
6723
6764
|
const { value, defaultValue } = props;
|
|
6724
6765
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6725
6766
|
const handleCopyToClipboard = async (value2) => {
|
|
6726
|
-
await (0,
|
|
6767
|
+
await (0, import_utils14.copyTextToClipboard)(value2);
|
|
6727
6768
|
setIsCopied(true);
|
|
6728
6769
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6729
6770
|
};
|
|
@@ -6736,12 +6777,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6736
6777
|
};
|
|
6737
6778
|
|
|
6738
6779
|
// src/widget/basic/color-field/color-controller.ts
|
|
6739
|
-
var
|
|
6780
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6740
6781
|
var colorFieldController = (props) => {
|
|
6741
6782
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6742
6783
|
const { env } = (0, provider_exports.useEnv)();
|
|
6743
6784
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6744
|
-
const _context = { ...(0,
|
|
6785
|
+
const _context = { ...(0, import_utils15.evalJSONContext)(actionData?.context) || {} };
|
|
6745
6786
|
const contextObject = { ...env.context, ..._context };
|
|
6746
6787
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6747
6788
|
const { mutate: onSave } = useSave3();
|
|
@@ -6770,7 +6811,7 @@ var colorFieldController = (props) => {
|
|
|
6770
6811
|
|
|
6771
6812
|
// src/widget/basic/binary-field/controller.ts
|
|
6772
6813
|
var import_react22 = require("react");
|
|
6773
|
-
var
|
|
6814
|
+
var import_utils16 = require("@fctc/interface-logic/utils");
|
|
6774
6815
|
var binaryFieldController = (props) => {
|
|
6775
6816
|
const { name, methods, readonly = false, value } = props;
|
|
6776
6817
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6827,11 +6868,11 @@ var binaryFieldController = (props) => {
|
|
|
6827
6868
|
};
|
|
6828
6869
|
const checkIsImageLink = (url) => {
|
|
6829
6870
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6830
|
-
return imageExtensions.test(url) || (0,
|
|
6871
|
+
return imageExtensions.test(url) || (0, import_utils16.isBase64Image)(url) || isBlobUrl(url);
|
|
6831
6872
|
};
|
|
6832
6873
|
const getImageBase64WithMimeType = (base64) => {
|
|
6833
6874
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6834
|
-
if ((0,
|
|
6875
|
+
if ((0, import_utils16.isBase64Image)(base64)) return base64;
|
|
6835
6876
|
let mimeType = null;
|
|
6836
6877
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6837
6878
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6934,7 +6975,7 @@ var tableHeadController = (props) => {
|
|
|
6934
6975
|
|
|
6935
6976
|
// src/widget/advance/table/table-view/controller.ts
|
|
6936
6977
|
var import_react24 = require("react");
|
|
6937
|
-
var
|
|
6978
|
+
var import_utils18 = require("@fctc/interface-logic/utils");
|
|
6938
6979
|
var tableController = ({ data }) => {
|
|
6939
6980
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6940
6981
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6972,7 +7013,7 @@ var tableController = ({ data }) => {
|
|
|
6972
7013
|
let cols = [];
|
|
6973
7014
|
try {
|
|
6974
7015
|
cols = mergeFields?.filter((item) => {
|
|
6975
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
7016
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils18.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils18.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
6976
7017
|
})?.map((field) => {
|
|
6977
7018
|
return {
|
|
6978
7019
|
name: field?.name,
|
|
@@ -7156,7 +7197,7 @@ var tableGroupController = (props) => {
|
|
|
7156
7197
|
|
|
7157
7198
|
// src/widget/advance/search/controller.ts
|
|
7158
7199
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
7159
|
-
var
|
|
7200
|
+
var import_utils20 = require("@fctc/interface-logic/utils");
|
|
7160
7201
|
var import_moment2 = __toESM(require_moment());
|
|
7161
7202
|
var import_react26 = require("react");
|
|
7162
7203
|
var searchController = ({
|
|
@@ -7173,9 +7214,9 @@ var searchController = ({
|
|
|
7173
7214
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
7174
7215
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
7175
7216
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
7176
|
-
const actionContext = typeof context === "string" ? (0,
|
|
7217
|
+
const actionContext = typeof context === "string" ? (0, import_utils20.evalJSONContext)(context) : context;
|
|
7177
7218
|
const contextSearch = { ...env.context, ...actionContext };
|
|
7178
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
7219
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils20.evalJSONDomain)(domain, contextSearch) : [];
|
|
7179
7220
|
const clearSearch = () => {
|
|
7180
7221
|
setFilterBy([]);
|
|
7181
7222
|
setGroupBy([]);
|
|
@@ -7190,7 +7231,7 @@ var searchController = ({
|
|
|
7190
7231
|
const dataModel = viewData?.models?.[model];
|
|
7191
7232
|
const searchViews = viewData?.views?.search;
|
|
7192
7233
|
const searchByItems = searchViews?.search_by?.filter(
|
|
7193
|
-
(item) => !
|
|
7234
|
+
(item) => !import_utils20.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
7194
7235
|
)?.map(
|
|
7195
7236
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
7196
7237
|
dataIndex: index,
|
|
@@ -7203,10 +7244,10 @@ var searchController = ({
|
|
|
7203
7244
|
})
|
|
7204
7245
|
);
|
|
7205
7246
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
7206
|
-
return !
|
|
7247
|
+
return !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
7207
7248
|
})?.map((item) => ({ ...item, active: false }));
|
|
7208
7249
|
const groupByItems = searchViews?.group_by.filter(
|
|
7209
|
-
(item) => !
|
|
7250
|
+
(item) => !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
7210
7251
|
).map((item) => ({
|
|
7211
7252
|
...item,
|
|
7212
7253
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -7283,14 +7324,14 @@ var searchController = ({
|
|
|
7283
7324
|
}
|
|
7284
7325
|
let valueDomainItem = value?.value;
|
|
7285
7326
|
if (value?.modelType === "date") {
|
|
7286
|
-
valueDomainItem = (0,
|
|
7327
|
+
valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value);
|
|
7287
7328
|
} else if (value?.modelType === "datetime") {
|
|
7288
7329
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7289
|
-
const parsedDate = (0,
|
|
7330
|
+
const parsedDate = (0, import_utils20.validateAndParseDate)(value?.value, true);
|
|
7290
7331
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7291
7332
|
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");
|
|
7292
7333
|
} else {
|
|
7293
|
-
valueDomainItem = (0,
|
|
7334
|
+
valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value, true);
|
|
7294
7335
|
}
|
|
7295
7336
|
}
|
|
7296
7337
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -7369,7 +7410,7 @@ var searchController = ({
|
|
|
7369
7410
|
}, [searchMap]);
|
|
7370
7411
|
const handleAddTagSearch = (tag) => {
|
|
7371
7412
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
7372
|
-
const domainFormat = new
|
|
7413
|
+
const domainFormat = new import_utils20.domainHelper.Domain(domain2);
|
|
7373
7414
|
if (type === import_constants3.SearchType.FILTER) {
|
|
7374
7415
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
7375
7416
|
...tag,
|