@fctc/widget-logic 2.8.9 → 2.9.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/hooks.d.mts +23 -8
- package/dist/hooks.d.ts +23 -8
- package/dist/hooks.js +98 -59
- package/dist/hooks.mjs +93 -54
- package/dist/index.js +131 -92
- package/dist/index.mjs +105 -66
- package/dist/widget.js +39 -39
- package/dist/widget.mjs +15 -15
- package/package.json +2 -2
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
|
+
setService(service2 ?? "");
|
|
4458
|
+
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,
|
|
@@ -4952,7 +4989,9 @@ var useListData = ({
|
|
|
4952
4989
|
const list = useGetListData2(
|
|
4953
4990
|
listDataProps,
|
|
4954
4991
|
[listDataProps],
|
|
4955
|
-
!!listDataProps && !!specification && !(0,
|
|
4992
|
+
!!listDataProps && !!specification && !(0, import_utils6.isObjectEmpty)(specification),
|
|
4993
|
+
service,
|
|
4994
|
+
xNode
|
|
4956
4995
|
);
|
|
4957
4996
|
return {
|
|
4958
4997
|
...list,
|
|
@@ -5458,18 +5497,18 @@ var many2oneFieldController = (props) => {
|
|
|
5458
5497
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5459
5498
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
5460
5499
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
5461
|
-
var
|
|
5500
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5462
5501
|
var many2oneButtonController = (props) => {
|
|
5463
5502
|
const { domain, methods, relation, service, xNode } = props;
|
|
5464
5503
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5465
5504
|
const env = (0, import_environment2.getEnv)();
|
|
5466
|
-
const domainObject = (0,
|
|
5505
|
+
const domainObject = (0, import_utils9.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5467
5506
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5468
5507
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
5469
5508
|
data: {
|
|
5470
5509
|
model: relation ?? "",
|
|
5471
5510
|
domain: domainObject,
|
|
5472
|
-
context: { ...env.context, ...(0,
|
|
5511
|
+
context: { ...env.context, ...(0, import_utils9.evalJSONContext)(actionData?.context) }
|
|
5473
5512
|
},
|
|
5474
5513
|
queryKey: [`data_${relation}`, domainObject],
|
|
5475
5514
|
service,
|
|
@@ -5486,7 +5525,7 @@ var many2oneButtonController = (props) => {
|
|
|
5486
5525
|
|
|
5487
5526
|
// src/widget/basic/many2many-field/controller.ts
|
|
5488
5527
|
var import_react17 = require("react");
|
|
5489
|
-
var
|
|
5528
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5490
5529
|
var many2manyFieldController = (props) => {
|
|
5491
5530
|
const {
|
|
5492
5531
|
relation,
|
|
@@ -5529,10 +5568,10 @@ var many2manyFieldController = (props) => {
|
|
|
5529
5568
|
]
|
|
5530
5569
|
});
|
|
5531
5570
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5532
|
-
const optionsObject = tab?.options ? (0,
|
|
5571
|
+
const optionsObject = tab?.options ? (0, import_utils10.evalJSONContext)(tab?.options) : (options ? (0, import_utils10.evalJSONContext)(options) : {}) || {};
|
|
5533
5572
|
const fetchData = async () => {
|
|
5534
5573
|
try {
|
|
5535
|
-
const domainParse = typeof domain === "string" ? (0,
|
|
5574
|
+
const domainParse = typeof domain === "string" ? (0, import_utils10.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5536
5575
|
setDomainMany2Many(domainParse);
|
|
5537
5576
|
setPage(0);
|
|
5538
5577
|
} catch (err) {
|
|
@@ -5556,7 +5595,7 @@ var many2manyFieldController = (props) => {
|
|
|
5556
5595
|
context: contextObject,
|
|
5557
5596
|
fields: groupByDomain?.fields,
|
|
5558
5597
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5559
|
-
sort: order ? order : default_order ? (0,
|
|
5598
|
+
sort: order ? order : default_order ? (0, import_utils10.formatSortingString)(default_order) : ""
|
|
5560
5599
|
};
|
|
5561
5600
|
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5562
5601
|
const {
|
|
@@ -5620,7 +5659,7 @@ var many2manyFieldController = (props) => {
|
|
|
5620
5659
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5621
5660
|
var import_react18 = require("react");
|
|
5622
5661
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
5623
|
-
var
|
|
5662
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
5624
5663
|
var many2manyTagsController = (props) => {
|
|
5625
5664
|
const {
|
|
5626
5665
|
relation,
|
|
@@ -5635,9 +5674,9 @@ var many2manyTagsController = (props) => {
|
|
|
5635
5674
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5636
5675
|
const { env } = (0, provider_exports.useEnv)();
|
|
5637
5676
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5638
|
-
const addtionalFields = optionsFields ? (0,
|
|
5677
|
+
const addtionalFields = optionsFields ? (0, import_utils11.evalJSONContext)(optionsFields) : null;
|
|
5639
5678
|
const domainObject = (0, import_react18.useMemo)(
|
|
5640
|
-
() => (0,
|
|
5679
|
+
() => (0, import_utils11.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5641
5680
|
[domain, formValues]
|
|
5642
5681
|
);
|
|
5643
5682
|
const data = {
|
|
@@ -5681,7 +5720,7 @@ var many2manyTagsController = (props) => {
|
|
|
5681
5720
|
|
|
5682
5721
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5683
5722
|
var import_react19 = require("react");
|
|
5684
|
-
var
|
|
5723
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
5685
5724
|
var durationController = (props) => {
|
|
5686
5725
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5687
5726
|
const specification = {
|
|
@@ -5697,7 +5736,7 @@ var durationController = (props) => {
|
|
|
5697
5736
|
const listDataProps = {
|
|
5698
5737
|
model: relation,
|
|
5699
5738
|
specification,
|
|
5700
|
-
domain: (0,
|
|
5739
|
+
domain: (0, import_utils12.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5701
5740
|
limit: 10,
|
|
5702
5741
|
offset: 0,
|
|
5703
5742
|
fields: "",
|
|
@@ -5747,10 +5786,10 @@ var durationController = (props) => {
|
|
|
5747
5786
|
};
|
|
5748
5787
|
|
|
5749
5788
|
// src/widget/basic/priority-field/controller.ts
|
|
5750
|
-
var
|
|
5789
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
5751
5790
|
var priorityFieldController = (props) => {
|
|
5752
5791
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
5753
|
-
const _context = { ...(0,
|
|
5792
|
+
const _context = { ...(0, import_utils13.evalJSONContext)(actionData?.context) };
|
|
5754
5793
|
const contextObject = { ...context, ..._context };
|
|
5755
5794
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5756
5795
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -6718,12 +6757,12 @@ var dateFieldController = (props) => {
|
|
|
6718
6757
|
|
|
6719
6758
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6720
6759
|
var import_react21 = require("react");
|
|
6721
|
-
var
|
|
6760
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6722
6761
|
var copyLinkButtonController = (props) => {
|
|
6723
6762
|
const { value, defaultValue } = props;
|
|
6724
6763
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6725
6764
|
const handleCopyToClipboard = async (value2) => {
|
|
6726
|
-
await (0,
|
|
6765
|
+
await (0, import_utils14.copyTextToClipboard)(value2);
|
|
6727
6766
|
setIsCopied(true);
|
|
6728
6767
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6729
6768
|
};
|
|
@@ -6736,12 +6775,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6736
6775
|
};
|
|
6737
6776
|
|
|
6738
6777
|
// src/widget/basic/color-field/color-controller.ts
|
|
6739
|
-
var
|
|
6778
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
6740
6779
|
var colorFieldController = (props) => {
|
|
6741
6780
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6742
6781
|
const { env } = (0, provider_exports.useEnv)();
|
|
6743
6782
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6744
|
-
const _context = { ...(0,
|
|
6783
|
+
const _context = { ...(0, import_utils15.evalJSONContext)(actionData?.context) || {} };
|
|
6745
6784
|
const contextObject = { ...env.context, ..._context };
|
|
6746
6785
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6747
6786
|
const { mutate: onSave } = useSave3();
|
|
@@ -6770,7 +6809,7 @@ var colorFieldController = (props) => {
|
|
|
6770
6809
|
|
|
6771
6810
|
// src/widget/basic/binary-field/controller.ts
|
|
6772
6811
|
var import_react22 = require("react");
|
|
6773
|
-
var
|
|
6812
|
+
var import_utils16 = require("@fctc/interface-logic/utils");
|
|
6774
6813
|
var binaryFieldController = (props) => {
|
|
6775
6814
|
const { name, methods, readonly = false, value } = props;
|
|
6776
6815
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6827,11 +6866,11 @@ var binaryFieldController = (props) => {
|
|
|
6827
6866
|
};
|
|
6828
6867
|
const checkIsImageLink = (url) => {
|
|
6829
6868
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6830
|
-
return imageExtensions.test(url) || (0,
|
|
6869
|
+
return imageExtensions.test(url) || (0, import_utils16.isBase64Image)(url) || isBlobUrl(url);
|
|
6831
6870
|
};
|
|
6832
6871
|
const getImageBase64WithMimeType = (base64) => {
|
|
6833
6872
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6834
|
-
if ((0,
|
|
6873
|
+
if ((0, import_utils16.isBase64Image)(base64)) return base64;
|
|
6835
6874
|
let mimeType = null;
|
|
6836
6875
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6837
6876
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6934,7 +6973,7 @@ var tableHeadController = (props) => {
|
|
|
6934
6973
|
|
|
6935
6974
|
// src/widget/advance/table/table-view/controller.ts
|
|
6936
6975
|
var import_react24 = require("react");
|
|
6937
|
-
var
|
|
6976
|
+
var import_utils18 = require("@fctc/interface-logic/utils");
|
|
6938
6977
|
var tableController = ({ data }) => {
|
|
6939
6978
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6940
6979
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6972,7 +7011,7 @@ var tableController = ({ data }) => {
|
|
|
6972
7011
|
let cols = [];
|
|
6973
7012
|
try {
|
|
6974
7013
|
cols = mergeFields?.filter((item) => {
|
|
6975
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
7014
|
+
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
7015
|
})?.map((field) => {
|
|
6977
7016
|
return {
|
|
6978
7017
|
name: field?.name,
|
|
@@ -7156,7 +7195,7 @@ var tableGroupController = (props) => {
|
|
|
7156
7195
|
|
|
7157
7196
|
// src/widget/advance/search/controller.ts
|
|
7158
7197
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
7159
|
-
var
|
|
7198
|
+
var import_utils20 = require("@fctc/interface-logic/utils");
|
|
7160
7199
|
var import_moment2 = __toESM(require_moment());
|
|
7161
7200
|
var import_react26 = require("react");
|
|
7162
7201
|
var searchController = ({
|
|
@@ -7173,9 +7212,9 @@ var searchController = ({
|
|
|
7173
7212
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
7174
7213
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
7175
7214
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
7176
|
-
const actionContext = typeof context === "string" ? (0,
|
|
7215
|
+
const actionContext = typeof context === "string" ? (0, import_utils20.evalJSONContext)(context) : context;
|
|
7177
7216
|
const contextSearch = { ...env.context, ...actionContext };
|
|
7178
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
7217
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils20.evalJSONDomain)(domain, contextSearch) : [];
|
|
7179
7218
|
const clearSearch = () => {
|
|
7180
7219
|
setFilterBy([]);
|
|
7181
7220
|
setGroupBy([]);
|
|
@@ -7190,7 +7229,7 @@ var searchController = ({
|
|
|
7190
7229
|
const dataModel = viewData?.models?.[model];
|
|
7191
7230
|
const searchViews = viewData?.views?.search;
|
|
7192
7231
|
const searchByItems = searchViews?.search_by?.filter(
|
|
7193
|
-
(item) => !
|
|
7232
|
+
(item) => !import_utils20.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
7194
7233
|
)?.map(
|
|
7195
7234
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
7196
7235
|
dataIndex: index,
|
|
@@ -7203,10 +7242,10 @@ var searchController = ({
|
|
|
7203
7242
|
})
|
|
7204
7243
|
);
|
|
7205
7244
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
7206
|
-
return !
|
|
7245
|
+
return !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
7207
7246
|
})?.map((item) => ({ ...item, active: false }));
|
|
7208
7247
|
const groupByItems = searchViews?.group_by.filter(
|
|
7209
|
-
(item) => !
|
|
7248
|
+
(item) => !import_utils20.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
7210
7249
|
).map((item) => ({
|
|
7211
7250
|
...item,
|
|
7212
7251
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -7283,14 +7322,14 @@ var searchController = ({
|
|
|
7283
7322
|
}
|
|
7284
7323
|
let valueDomainItem = value?.value;
|
|
7285
7324
|
if (value?.modelType === "date") {
|
|
7286
|
-
valueDomainItem = (0,
|
|
7325
|
+
valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value);
|
|
7287
7326
|
} else if (value?.modelType === "datetime") {
|
|
7288
7327
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7289
|
-
const parsedDate = (0,
|
|
7328
|
+
const parsedDate = (0, import_utils20.validateAndParseDate)(value?.value, true);
|
|
7290
7329
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7291
7330
|
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
7331
|
} else {
|
|
7293
|
-
valueDomainItem = (0,
|
|
7332
|
+
valueDomainItem = (0, import_utils20.validateAndParseDate)(value?.value, true);
|
|
7294
7333
|
}
|
|
7295
7334
|
}
|
|
7296
7335
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -7369,7 +7408,7 @@ var searchController = ({
|
|
|
7369
7408
|
}, [searchMap]);
|
|
7370
7409
|
const handleAddTagSearch = (tag) => {
|
|
7371
7410
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
7372
|
-
const domainFormat = new
|
|
7411
|
+
const domainFormat = new import_utils20.domainHelper.Domain(domain2);
|
|
7373
7412
|
if (type === import_constants3.SearchType.FILTER) {
|
|
7374
7413
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
7375
7414
|
...tag,
|