@fctc/widget-logic 3.0.4 → 3.0.6
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 -1
- package/dist/hooks.d.ts +3 -1
- package/dist/hooks.js +63 -63
- package/dist/hooks.mjs +57 -57
- package/dist/index.js +144 -157
- package/dist/index.mjs +150 -167
- package/dist/widget.d.mts +17 -11
- package/dist/widget.d.ts +17 -11
- package/dist/widget.js +172 -100
- package/dist/widget.mjs +181 -113
- package/package.json +96 -96
package/dist/widget.js
CHANGED
|
@@ -4122,7 +4122,7 @@ var import_react9 = require("react");
|
|
|
4122
4122
|
var import_react4 = require("react");
|
|
4123
4123
|
|
|
4124
4124
|
// src/hooks/core/use-call-action.ts
|
|
4125
|
-
var
|
|
4125
|
+
var import_react2 = require("react");
|
|
4126
4126
|
|
|
4127
4127
|
// src/provider.ts
|
|
4128
4128
|
var provider_exports = {};
|
|
@@ -4149,7 +4149,7 @@ var languages = [
|
|
|
4149
4149
|
];
|
|
4150
4150
|
|
|
4151
4151
|
// src/utils/function.ts
|
|
4152
|
-
var
|
|
4152
|
+
var import_react3 = require("react");
|
|
4153
4153
|
var countSum = (data, field) => {
|
|
4154
4154
|
if (!data || !field) return 0;
|
|
4155
4155
|
return data.reduce(
|
|
@@ -4270,7 +4270,7 @@ var STORAGES = {
|
|
|
4270
4270
|
USER_INFO: "USER_INFO"
|
|
4271
4271
|
};
|
|
4272
4272
|
function useAsyncState(initialValue = [true, null]) {
|
|
4273
|
-
return (0,
|
|
4273
|
+
return (0, import_react3.useReducer)(
|
|
4274
4274
|
(_state, action = null) => [false, action],
|
|
4275
4275
|
initialValue
|
|
4276
4276
|
);
|
|
@@ -4288,7 +4288,7 @@ async function setStorageItemAsync(key, value) {
|
|
|
4288
4288
|
}
|
|
4289
4289
|
function useStorageState(key) {
|
|
4290
4290
|
const [state, setState] = useAsyncState();
|
|
4291
|
-
(0,
|
|
4291
|
+
(0, import_react3.useEffect)(() => {
|
|
4292
4292
|
try {
|
|
4293
4293
|
const storedValue = localStorage.getItem(key);
|
|
4294
4294
|
setState(storedValue);
|
|
@@ -4296,7 +4296,7 @@ function useStorageState(key) {
|
|
|
4296
4296
|
console.error("Local storage is unavailable:", e);
|
|
4297
4297
|
}
|
|
4298
4298
|
}, [key]);
|
|
4299
|
-
const setValue = (0,
|
|
4299
|
+
const setValue = (0, import_react3.useCallback)(
|
|
4300
4300
|
(value) => {
|
|
4301
4301
|
setState(value);
|
|
4302
4302
|
setStorageItemAsync(key, value);
|
|
@@ -4335,6 +4335,13 @@ var AppProviderInitialValue = {
|
|
|
4335
4335
|
view: {}
|
|
4336
4336
|
};
|
|
4337
4337
|
var ReactContext = (0, import_react9.createContext)(AppProviderInitialValue);
|
|
4338
|
+
var useAppProvider = () => {
|
|
4339
|
+
const context = (0, import_react9.useContext)(ReactContext);
|
|
4340
|
+
if (!context) {
|
|
4341
|
+
return AppProviderInitialValue;
|
|
4342
|
+
}
|
|
4343
|
+
return context;
|
|
4344
|
+
};
|
|
4338
4345
|
|
|
4339
4346
|
// src/hooks/core/use-config.ts
|
|
4340
4347
|
var import_react10 = require("react");
|
|
@@ -4372,7 +4379,7 @@ var useGetSpecification = ({
|
|
|
4372
4379
|
|
|
4373
4380
|
// src/hooks/core/use-list-data.ts
|
|
4374
4381
|
var import_react15 = require("react");
|
|
4375
|
-
var
|
|
4382
|
+
var import_utils5 = require("@fctc/interface-logic/utils");
|
|
4376
4383
|
|
|
4377
4384
|
// src/hooks/utils/use-click-outside.ts
|
|
4378
4385
|
var import_react12 = require("react");
|
|
@@ -4458,6 +4465,84 @@ var useGetRowIds = (tableRef) => {
|
|
|
4458
4465
|
return { rowIds, refresh: updateVisibleRowIds };
|
|
4459
4466
|
};
|
|
4460
4467
|
|
|
4468
|
+
// src/hooks/core/use-list-data.ts
|
|
4469
|
+
var useListData = ({
|
|
4470
|
+
action,
|
|
4471
|
+
context,
|
|
4472
|
+
viewData,
|
|
4473
|
+
model,
|
|
4474
|
+
service,
|
|
4475
|
+
xNode
|
|
4476
|
+
}) => {
|
|
4477
|
+
const { useGetListData: useGetListData2 } = (0, provider_exports.useService)();
|
|
4478
|
+
const [page, setPage] = (0, import_react15.useState)(0);
|
|
4479
|
+
const [pageLimit, setPageLimit] = (0, import_react15.useState)(10);
|
|
4480
|
+
const [groupByList, setGroupByList] = (0, import_react15.useState)(null);
|
|
4481
|
+
const [domain, setDomain] = (0, import_react15.useState)(null);
|
|
4482
|
+
const [order, setOrder] = (0, import_react15.useState)("");
|
|
4483
|
+
const [selectedRowKeys, setSelectedRowKeys] = (0, import_react15.useState)([]);
|
|
4484
|
+
const [debouncedPage] = useDebounce(page, 500);
|
|
4485
|
+
const [debouncedDomain] = useDebounce(domain, 500);
|
|
4486
|
+
const { specification } = useGetSpecification({
|
|
4487
|
+
model,
|
|
4488
|
+
viewData,
|
|
4489
|
+
fields: viewData?.views?.list?.fields
|
|
4490
|
+
});
|
|
4491
|
+
const listDataProps = (0, import_react15.useMemo)(() => {
|
|
4492
|
+
if (!viewData || !action || !context) {
|
|
4493
|
+
return null;
|
|
4494
|
+
}
|
|
4495
|
+
const domainParse = domain ? [...domain] : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils5.evalJSONDomain)(action?.domain, context) : [];
|
|
4496
|
+
const limit = pageLimit;
|
|
4497
|
+
const offset = debouncedPage * pageLimit;
|
|
4498
|
+
const fields = typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
4499
|
+
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
4500
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils5.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
4501
|
+
return {
|
|
4502
|
+
model: action?.res_model,
|
|
4503
|
+
specification,
|
|
4504
|
+
domain: domainParse,
|
|
4505
|
+
limit,
|
|
4506
|
+
offset,
|
|
4507
|
+
fields,
|
|
4508
|
+
groupby,
|
|
4509
|
+
context,
|
|
4510
|
+
sort
|
|
4511
|
+
};
|
|
4512
|
+
}, [action, groupByList, order, debouncedPage, pageLimit, debouncedDomain]);
|
|
4513
|
+
const list = useGetListData2(
|
|
4514
|
+
{ ...listDataProps },
|
|
4515
|
+
[
|
|
4516
|
+
listDataProps?.domain,
|
|
4517
|
+
listDataProps?.groupby,
|
|
4518
|
+
listDataProps?.limit,
|
|
4519
|
+
listDataProps?.offset,
|
|
4520
|
+
listDataProps?.sort
|
|
4521
|
+
],
|
|
4522
|
+
!!listDataProps && !!specification && !(0, import_utils5.isObjectEmpty)(specification) && !!domain,
|
|
4523
|
+
service,
|
|
4524
|
+
xNode
|
|
4525
|
+
);
|
|
4526
|
+
return {
|
|
4527
|
+
...list,
|
|
4528
|
+
state: {
|
|
4529
|
+
specification,
|
|
4530
|
+
page,
|
|
4531
|
+
order,
|
|
4532
|
+
domain: listDataProps?.domain,
|
|
4533
|
+
pageLimit,
|
|
4534
|
+
groupByList,
|
|
4535
|
+
selectedRowKeys,
|
|
4536
|
+
setPage,
|
|
4537
|
+
setOrder,
|
|
4538
|
+
setDomain,
|
|
4539
|
+
setPageLimit,
|
|
4540
|
+
setGroupByList,
|
|
4541
|
+
setSelectedRowKeys
|
|
4542
|
+
}
|
|
4543
|
+
};
|
|
4544
|
+
};
|
|
4545
|
+
|
|
4461
4546
|
// src/store.ts
|
|
4462
4547
|
var store_exports = {};
|
|
4463
4548
|
__reExport(store_exports, require("@fctc/interface-logic/store"));
|
|
@@ -4642,18 +4727,18 @@ var many2oneFieldController = (props) => {
|
|
|
4642
4727
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
4643
4728
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
4644
4729
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
4645
|
-
var
|
|
4730
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
4646
4731
|
var many2oneButtonController = (props) => {
|
|
4647
4732
|
const { domain, methods, relation, service, xNode } = props;
|
|
4648
4733
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
4649
4734
|
const env = (0, import_environment2.getEnv)();
|
|
4650
|
-
const domainObject = (0,
|
|
4735
|
+
const domainObject = (0, import_utils8.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
4651
4736
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
4652
4737
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
4653
4738
|
data: {
|
|
4654
4739
|
model: relation ?? "",
|
|
4655
4740
|
domain: domainObject,
|
|
4656
|
-
context: { ...env.context, ...(0,
|
|
4741
|
+
context: { ...env.context, ...(0, import_utils8.evalJSONContext)(actionData?.context) }
|
|
4657
4742
|
},
|
|
4658
4743
|
queryKey: [`data_${relation}`, domainObject],
|
|
4659
4744
|
service,
|
|
@@ -4670,24 +4755,20 @@ var many2oneButtonController = (props) => {
|
|
|
4670
4755
|
|
|
4671
4756
|
// src/widget/basic/many2many-field/controller.ts
|
|
4672
4757
|
var import_react17 = require("react");
|
|
4673
|
-
var
|
|
4758
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
4674
4759
|
var many2manyFieldController = (props) => {
|
|
4675
4760
|
const {
|
|
4676
4761
|
relation,
|
|
4677
4762
|
domain,
|
|
4678
4763
|
context,
|
|
4679
4764
|
options,
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
groupByDomain,
|
|
4683
|
-
enabled: enabledCallAPI
|
|
4765
|
+
enabled: enabledCallAPI,
|
|
4766
|
+
service
|
|
4684
4767
|
} = props;
|
|
4685
4768
|
const { env } = (0, provider_exports.useEnv)();
|
|
4686
|
-
const {
|
|
4687
|
-
const
|
|
4688
|
-
const
|
|
4689
|
-
const [domainMany2Many, setDomainMany2Many] = (0, import_react17.useState)(null);
|
|
4690
|
-
const [debouncedPage] = useDebounce(page, 500);
|
|
4769
|
+
const { user } = useAppProvider();
|
|
4770
|
+
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4771
|
+
const dataUser = user?.userProfile?.data;
|
|
4691
4772
|
const contextObject = {
|
|
4692
4773
|
...env.context,
|
|
4693
4774
|
...context || {}
|
|
@@ -4704,61 +4785,46 @@ var many2manyFieldController = (props) => {
|
|
|
4704
4785
|
viewParams,
|
|
4705
4786
|
enabled: enabledCallAPI
|
|
4706
4787
|
});
|
|
4707
|
-
const { specification } = useGetSpecification({
|
|
4708
|
-
model: String(relation),
|
|
4709
|
-
viewData: viewResponse || {},
|
|
4710
|
-
fields: [
|
|
4711
|
-
...Object.values(viewResponse?.views?.list?.fields ?? {}),
|
|
4712
|
-
...tab?.fields ? tab.fields : []
|
|
4713
|
-
]
|
|
4714
|
-
});
|
|
4715
4788
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4716
|
-
const optionsObject =
|
|
4717
|
-
const fetchData = async () => {
|
|
4718
|
-
try {
|
|
4719
|
-
const domainParse = typeof domain === "string" ? (0, import_utils10.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
4720
|
-
setDomainMany2Many(domainParse);
|
|
4721
|
-
setPage(0);
|
|
4722
|
-
} catch (err) {
|
|
4723
|
-
console.log(err);
|
|
4724
|
-
}
|
|
4725
|
-
};
|
|
4726
|
-
const queryKey = [
|
|
4727
|
-
`view-${relation}`,
|
|
4728
|
-
specification,
|
|
4729
|
-
domainMany2Many,
|
|
4730
|
-
debouncedPage,
|
|
4731
|
-
groupByDomain,
|
|
4732
|
-
order
|
|
4733
|
-
];
|
|
4734
|
-
const data = {
|
|
4735
|
-
model: relation,
|
|
4736
|
-
specification,
|
|
4737
|
-
domain: domainMany2Many,
|
|
4738
|
-
offset: debouncedPage * 10,
|
|
4739
|
-
limit: 10,
|
|
4740
|
-
context: contextObject,
|
|
4741
|
-
fields: groupByDomain?.fields,
|
|
4742
|
-
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4743
|
-
sort: order ? order : default_order ? (0, import_utils10.formatSortingString)(default_order) : ""
|
|
4744
|
-
};
|
|
4745
|
-
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4789
|
+
const optionsObject = (options && typeof options === "string" ? (0, import_utils9.evalJSONContext)(options) : options) || {};
|
|
4746
4790
|
const {
|
|
4747
4791
|
data: dataResponse,
|
|
4748
|
-
isLoading,
|
|
4749
4792
|
isFetched,
|
|
4793
|
+
isLoading,
|
|
4794
|
+
state,
|
|
4750
4795
|
isPlaceholderData
|
|
4751
|
-
} =
|
|
4796
|
+
} = useListData({
|
|
4797
|
+
action: {
|
|
4798
|
+
domain,
|
|
4799
|
+
res_model: relation
|
|
4800
|
+
},
|
|
4801
|
+
context: contextObject,
|
|
4802
|
+
model: relation ?? "",
|
|
4803
|
+
viewData: viewResponse,
|
|
4804
|
+
service,
|
|
4805
|
+
xNode: service == "wesap" && dataUser.x_node
|
|
4806
|
+
});
|
|
4807
|
+
const {
|
|
4808
|
+
selectedRowKeys,
|
|
4809
|
+
groupByList,
|
|
4810
|
+
domain: domainList,
|
|
4811
|
+
page,
|
|
4812
|
+
pageLimit,
|
|
4813
|
+
setDomain,
|
|
4814
|
+
setOrder,
|
|
4815
|
+
setPage,
|
|
4816
|
+
setSelectedRowKeys,
|
|
4817
|
+
setGroupByList,
|
|
4818
|
+
setPageLimit
|
|
4819
|
+
} = state;
|
|
4752
4820
|
(0, import_react17.useEffect)(() => {
|
|
4753
|
-
if (viewResponse) {
|
|
4754
|
-
fetchData();
|
|
4755
|
-
}
|
|
4756
4821
|
return () => {
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4822
|
+
setDomain(null);
|
|
4823
|
+
setOrder("");
|
|
4824
|
+
setGroupByList(null);
|
|
4825
|
+
setPageLimit(10);
|
|
4760
4826
|
};
|
|
4761
|
-
}, [
|
|
4827
|
+
}, []);
|
|
4762
4828
|
const { rows, columns, typeTable, onToggleColumnOptional } = tableController({
|
|
4763
4829
|
data: {
|
|
4764
4830
|
fields: viewResponse?.views?.list?.fields,
|
|
@@ -4782,29 +4848,35 @@ var many2manyFieldController = (props) => {
|
|
|
4782
4848
|
const handleCreateNewOnPage = async () => {
|
|
4783
4849
|
};
|
|
4784
4850
|
return {
|
|
4785
|
-
handleCreateNewOnPage,
|
|
4786
|
-
optionsObject,
|
|
4787
|
-
totalRows: dataResponse?.length ?? 0,
|
|
4788
4851
|
rows,
|
|
4789
4852
|
columns,
|
|
4853
|
+
optionsObject,
|
|
4854
|
+
viewData: viewResponse,
|
|
4855
|
+
totalRows: dataResponse?.length ?? 0,
|
|
4790
4856
|
onToggleColumnOptional,
|
|
4791
4857
|
typeTable,
|
|
4792
4858
|
isLoading,
|
|
4793
4859
|
isFetched,
|
|
4794
4860
|
isPlaceholderData,
|
|
4795
|
-
setPage,
|
|
4796
4861
|
page,
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4862
|
+
pageLimit,
|
|
4863
|
+
groupByList,
|
|
4864
|
+
selectedRowKeys,
|
|
4865
|
+
domain: domainList,
|
|
4866
|
+
setPage,
|
|
4867
|
+
setDomain,
|
|
4868
|
+
setPageLimit,
|
|
4869
|
+
setGroupByList,
|
|
4870
|
+
setSelectedRowKeys,
|
|
4871
|
+
searchController: searchControllers,
|
|
4872
|
+
handleCreateNewOnPage
|
|
4801
4873
|
};
|
|
4802
4874
|
};
|
|
4803
4875
|
|
|
4804
4876
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
4805
4877
|
var import_react18 = require("react");
|
|
4806
4878
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
4807
|
-
var
|
|
4879
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
4808
4880
|
var many2manyTagsController = (props) => {
|
|
4809
4881
|
const {
|
|
4810
4882
|
relation,
|
|
@@ -4819,9 +4891,9 @@ var many2manyTagsController = (props) => {
|
|
|
4819
4891
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
4820
4892
|
const { env } = (0, provider_exports.useEnv)();
|
|
4821
4893
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
4822
|
-
const addtionalFields = optionsFields ? (0,
|
|
4894
|
+
const addtionalFields = optionsFields ? (0, import_utils10.evalJSONContext)(optionsFields) : null;
|
|
4823
4895
|
const domainObject = (0, import_react18.useMemo)(
|
|
4824
|
-
() => (0,
|
|
4896
|
+
() => (0, import_utils10.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
4825
4897
|
[domain, formValues]
|
|
4826
4898
|
);
|
|
4827
4899
|
const data = {
|
|
@@ -4865,7 +4937,7 @@ var many2manyTagsController = (props) => {
|
|
|
4865
4937
|
|
|
4866
4938
|
// src/widget/basic/status-bar-field/controller.ts
|
|
4867
4939
|
var import_react19 = require("react");
|
|
4868
|
-
var
|
|
4940
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
4869
4941
|
var durationController = (props) => {
|
|
4870
4942
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
4871
4943
|
const specification = {
|
|
@@ -4881,7 +4953,7 @@ var durationController = (props) => {
|
|
|
4881
4953
|
const listDataProps = {
|
|
4882
4954
|
model: relation,
|
|
4883
4955
|
specification,
|
|
4884
|
-
domain: (0,
|
|
4956
|
+
domain: (0, import_utils11.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
4885
4957
|
limit: 10,
|
|
4886
4958
|
offset: 0,
|
|
4887
4959
|
fields: "",
|
|
@@ -4931,10 +5003,10 @@ var durationController = (props) => {
|
|
|
4931
5003
|
};
|
|
4932
5004
|
|
|
4933
5005
|
// src/widget/basic/priority-field/controller.ts
|
|
4934
|
-
var
|
|
5006
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
4935
5007
|
var priorityFieldController = (props) => {
|
|
4936
5008
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
4937
|
-
const _context = { ...(0,
|
|
5009
|
+
const _context = { ...(0, import_utils12.evalJSONContext)(actionData?.context) };
|
|
4938
5010
|
const contextObject = { ...context, ..._context };
|
|
4939
5011
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
4940
5012
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -5902,12 +5974,12 @@ var dateFieldController = (props) => {
|
|
|
5902
5974
|
|
|
5903
5975
|
// src/widget/basic/copy-link-button/controller.ts
|
|
5904
5976
|
var import_react21 = require("react");
|
|
5905
|
-
var
|
|
5977
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
5906
5978
|
var copyLinkButtonController = (props) => {
|
|
5907
5979
|
const { value, defaultValue } = props;
|
|
5908
5980
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
5909
5981
|
const handleCopyToClipboard = async (value2) => {
|
|
5910
|
-
await (0,
|
|
5982
|
+
await (0, import_utils13.copyTextToClipboard)(value2);
|
|
5911
5983
|
setIsCopied(true);
|
|
5912
5984
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
5913
5985
|
};
|
|
@@ -5920,12 +5992,12 @@ var copyLinkButtonController = (props) => {
|
|
|
5920
5992
|
};
|
|
5921
5993
|
|
|
5922
5994
|
// src/widget/basic/color-field/color-controller.ts
|
|
5923
|
-
var
|
|
5995
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
5924
5996
|
var colorFieldController = (props) => {
|
|
5925
5997
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
5926
5998
|
const { env } = (0, provider_exports.useEnv)();
|
|
5927
5999
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5928
|
-
const _context = { ...(0,
|
|
6000
|
+
const _context = { ...(0, import_utils14.evalJSONContext)(actionData?.context) || {} };
|
|
5929
6001
|
const contextObject = { ...env.context, ..._context };
|
|
5930
6002
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
5931
6003
|
const { mutate: onSave } = useSave3();
|
|
@@ -5954,7 +6026,7 @@ var colorFieldController = (props) => {
|
|
|
5954
6026
|
|
|
5955
6027
|
// src/widget/basic/binary-field/controller.ts
|
|
5956
6028
|
var import_react22 = require("react");
|
|
5957
|
-
var
|
|
6029
|
+
var import_utils15 = require("@fctc/interface-logic/utils");
|
|
5958
6030
|
var binaryFieldController = (props) => {
|
|
5959
6031
|
const { name, methods, readonly = false, value } = props;
|
|
5960
6032
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6011,11 +6083,11 @@ var binaryFieldController = (props) => {
|
|
|
6011
6083
|
};
|
|
6012
6084
|
const checkIsImageLink = (url) => {
|
|
6013
6085
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6014
|
-
return imageExtensions.test(url) || (0,
|
|
6086
|
+
return imageExtensions.test(url) || (0, import_utils15.isBase64Image)(url) || isBlobUrl(url);
|
|
6015
6087
|
};
|
|
6016
6088
|
const getImageBase64WithMimeType = (base64) => {
|
|
6017
6089
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6018
|
-
if ((0,
|
|
6090
|
+
if ((0, import_utils15.isBase64Image)(base64)) return base64;
|
|
6019
6091
|
let mimeType = null;
|
|
6020
6092
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6021
6093
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6118,7 +6190,7 @@ var tableHeadController = (props) => {
|
|
|
6118
6190
|
|
|
6119
6191
|
// src/widget/advance/table/table-view/controller.ts
|
|
6120
6192
|
var import_react24 = require("react");
|
|
6121
|
-
var
|
|
6193
|
+
var import_utils17 = require("@fctc/interface-logic/utils");
|
|
6122
6194
|
var tableController = ({ data }) => {
|
|
6123
6195
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6124
6196
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6156,7 +6228,7 @@ var tableController = ({ data }) => {
|
|
|
6156
6228
|
let cols = [];
|
|
6157
6229
|
try {
|
|
6158
6230
|
cols = mergeFields?.filter((item) => {
|
|
6159
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6231
|
+
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);
|
|
6160
6232
|
})?.map((field) => {
|
|
6161
6233
|
return {
|
|
6162
6234
|
name: field?.name,
|
|
@@ -6341,7 +6413,7 @@ var tableGroupController = (props) => {
|
|
|
6341
6413
|
|
|
6342
6414
|
// src/widget/advance/search/controller.ts
|
|
6343
6415
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6344
|
-
var
|
|
6416
|
+
var import_utils19 = require("@fctc/interface-logic/utils");
|
|
6345
6417
|
var import_moment2 = __toESM(require_moment());
|
|
6346
6418
|
var import_react26 = require("react");
|
|
6347
6419
|
var searchController = ({
|
|
@@ -6358,9 +6430,9 @@ var searchController = ({
|
|
|
6358
6430
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
6359
6431
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
6360
6432
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
6361
|
-
const actionContext = typeof context === "string" ? (0,
|
|
6433
|
+
const actionContext = typeof context === "string" ? (0, import_utils19.evalJSONContext)(context) : context;
|
|
6362
6434
|
const contextSearch = { ...env.context, ...actionContext };
|
|
6363
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
6435
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils19.evalJSONDomain)(domain, contextSearch) : [];
|
|
6364
6436
|
const clearSearch = () => {
|
|
6365
6437
|
setFilterBy([]);
|
|
6366
6438
|
setGroupBy([]);
|
|
@@ -6375,7 +6447,7 @@ var searchController = ({
|
|
|
6375
6447
|
const dataModel = viewData?.models?.[model];
|
|
6376
6448
|
const searchViews = viewData?.views?.search;
|
|
6377
6449
|
const searchByItems = searchViews?.search_by?.filter(
|
|
6378
|
-
(item) => !
|
|
6450
|
+
(item) => !import_utils19.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
6379
6451
|
)?.map(
|
|
6380
6452
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
6381
6453
|
dataIndex: index,
|
|
@@ -6388,10 +6460,10 @@ var searchController = ({
|
|
|
6388
6460
|
})
|
|
6389
6461
|
);
|
|
6390
6462
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
6391
|
-
return !
|
|
6463
|
+
return !import_utils19.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
6392
6464
|
})?.map((item) => ({ ...item, active: false }));
|
|
6393
6465
|
const groupByItems = searchViews?.group_by.filter(
|
|
6394
|
-
(item) => !
|
|
6466
|
+
(item) => !import_utils19.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
6395
6467
|
).map((item) => ({
|
|
6396
6468
|
...item,
|
|
6397
6469
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -6468,14 +6540,14 @@ var searchController = ({
|
|
|
6468
6540
|
}
|
|
6469
6541
|
let valueDomainItem = value?.value;
|
|
6470
6542
|
if (value?.modelType === "date") {
|
|
6471
|
-
valueDomainItem = (0,
|
|
6543
|
+
valueDomainItem = (0, import_utils19.validateAndParseDate)(value?.value);
|
|
6472
6544
|
} else if (value?.modelType === "datetime") {
|
|
6473
6545
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6474
|
-
const parsedDate = (0,
|
|
6546
|
+
const parsedDate = (0, import_utils19.validateAndParseDate)(value?.value, true);
|
|
6475
6547
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6476
6548
|
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");
|
|
6477
6549
|
} else {
|
|
6478
|
-
valueDomainItem = (0,
|
|
6550
|
+
valueDomainItem = (0, import_utils19.validateAndParseDate)(value?.value, true);
|
|
6479
6551
|
}
|
|
6480
6552
|
}
|
|
6481
6553
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -6554,7 +6626,7 @@ var searchController = ({
|
|
|
6554
6626
|
}, [searchMap]);
|
|
6555
6627
|
const handleAddTagSearch = (tag) => {
|
|
6556
6628
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
6557
|
-
const domainFormat = new
|
|
6629
|
+
const domainFormat = new import_utils19.domainHelper.Domain(domain2);
|
|
6558
6630
|
if (type === import_constants3.SearchType.FILTER) {
|
|
6559
6631
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
6560
6632
|
...tag,
|