@fctc/widget-logic 2.5.8 → 2.5.10
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.js +6 -7
- package/dist/hooks.mjs +4 -5
- package/dist/index.js +43 -44
- package/dist/index.mjs +8 -9
- package/dist/widget.js +38 -38
- package/dist/widget.mjs +5 -5
- package/package.json +2 -2
package/dist/hooks.js
CHANGED
|
@@ -484,7 +484,7 @@ var useViewV2 = ({
|
|
|
484
484
|
}) => {
|
|
485
485
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
486
486
|
const viewParams = (0, import_react6.useMemo)(() => {
|
|
487
|
-
if (!model || !views) return void 0;
|
|
487
|
+
if (!model || !views || views.length === 0) return void 0;
|
|
488
488
|
return {
|
|
489
489
|
model,
|
|
490
490
|
views,
|
|
@@ -494,7 +494,7 @@ var useViewV2 = ({
|
|
|
494
494
|
}, [model, views, context, id]);
|
|
495
495
|
const view = useGetView2(
|
|
496
496
|
viewParams || {},
|
|
497
|
-
!!viewParams &&
|
|
497
|
+
!!viewParams && views?.length > 0
|
|
498
498
|
);
|
|
499
499
|
return {
|
|
500
500
|
...view,
|
|
@@ -605,7 +605,6 @@ var AppProvider = ({
|
|
|
605
605
|
}, [action]);
|
|
606
606
|
const view = useViewV2({
|
|
607
607
|
context: viewContext,
|
|
608
|
-
// cũng nên memo nếu thay đổi liên tục
|
|
609
608
|
views: memoViews,
|
|
610
609
|
model: action?.res_model ? String(action.res_model) : void 0
|
|
611
610
|
});
|
|
@@ -732,7 +731,7 @@ var useGetSpecification = ({
|
|
|
732
731
|
|
|
733
732
|
// src/hooks/core/use-list-data.ts
|
|
734
733
|
var import_react14 = require("react");
|
|
735
|
-
var
|
|
734
|
+
var import_utils4 = require("@fctc/interface-logic/utils");
|
|
736
735
|
|
|
737
736
|
// src/hooks/utils/use-click-outside.ts
|
|
738
737
|
var import_react11 = require("react");
|
|
@@ -874,12 +873,12 @@ var useListData = ({
|
|
|
874
873
|
if (!viewData || !action || !context) {
|
|
875
874
|
return null;
|
|
876
875
|
}
|
|
877
|
-
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0,
|
|
876
|
+
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils4.evalJSONDomain)(action?.domain, context) : [];
|
|
878
877
|
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
879
878
|
const offset = debouncedPage * pageLimit;
|
|
880
879
|
const fields = type === "calendar" ? convertFieldsToArray(viewData?.views?.calendar?.fields) || [] : typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
881
880
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
882
|
-
const sort = order ? order : viewData?.views?.list?.default_order ? (0,
|
|
881
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils4.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
883
882
|
return {
|
|
884
883
|
model: action.res_model,
|
|
885
884
|
specification,
|
|
@@ -907,7 +906,7 @@ var useListData = ({
|
|
|
907
906
|
const list = useGetListData2(
|
|
908
907
|
listDataProps,
|
|
909
908
|
[listDataProps],
|
|
910
|
-
!!listDataProps && !!specification && !(0,
|
|
909
|
+
!!listDataProps && !!specification && !(0, import_utils4.isObjectEmpty)(specification)
|
|
911
910
|
);
|
|
912
911
|
return {
|
|
913
912
|
...list,
|
package/dist/hooks.mjs
CHANGED
|
@@ -465,7 +465,7 @@ var useViewV2 = ({
|
|
|
465
465
|
}) => {
|
|
466
466
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
467
467
|
const viewParams = useMemo3(() => {
|
|
468
|
-
if (!model || !views) return void 0;
|
|
468
|
+
if (!model || !views || views.length === 0) return void 0;
|
|
469
469
|
return {
|
|
470
470
|
model,
|
|
471
471
|
views,
|
|
@@ -475,7 +475,7 @@ var useViewV2 = ({
|
|
|
475
475
|
}, [model, views, context, id]);
|
|
476
476
|
const view = useGetView2(
|
|
477
477
|
viewParams || {},
|
|
478
|
-
!!viewParams &&
|
|
478
|
+
!!viewParams && views?.length > 0
|
|
479
479
|
);
|
|
480
480
|
return {
|
|
481
481
|
...view,
|
|
@@ -586,7 +586,6 @@ var AppProvider = ({
|
|
|
586
586
|
}, [action]);
|
|
587
587
|
const view = useViewV2({
|
|
588
588
|
context: viewContext,
|
|
589
|
-
// cũng nên memo nếu thay đổi liên tục
|
|
590
589
|
views: memoViews,
|
|
591
590
|
model: action?.res_model ? String(action.res_model) : void 0
|
|
592
591
|
});
|
|
@@ -716,7 +715,7 @@ import { useMemo as useMemo7, useState as useState5 } from "react";
|
|
|
716
715
|
import {
|
|
717
716
|
evalJSONDomain,
|
|
718
717
|
formatSortingString,
|
|
719
|
-
isObjectEmpty as
|
|
718
|
+
isObjectEmpty as isObjectEmpty3
|
|
720
719
|
} from "@fctc/interface-logic/utils";
|
|
721
720
|
|
|
722
721
|
// src/hooks/utils/use-click-outside.ts
|
|
@@ -892,7 +891,7 @@ var useListData = ({
|
|
|
892
891
|
const list = useGetListData2(
|
|
893
892
|
listDataProps,
|
|
894
893
|
[listDataProps],
|
|
895
|
-
!!listDataProps && !!specification && !
|
|
894
|
+
!!listDataProps && !!specification && !isObjectEmpty3(specification)
|
|
896
895
|
);
|
|
897
896
|
return {
|
|
898
897
|
...list,
|
package/dist/index.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 isObjectEmpty4(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) && isObjectEmpty4(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) && !isObjectEmpty4(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) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2659
2659
|
"sameDay",
|
|
2660
2660
|
"nextDay",
|
|
2661
2661
|
"lastDay",
|
|
@@ -4534,7 +4534,7 @@ var useViewV2 = ({
|
|
|
4534
4534
|
}) => {
|
|
4535
4535
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4536
4536
|
const viewParams = (0, import_react6.useMemo)(() => {
|
|
4537
|
-
if (!model || !views) return void 0;
|
|
4537
|
+
if (!model || !views || views.length === 0) return void 0;
|
|
4538
4538
|
return {
|
|
4539
4539
|
model,
|
|
4540
4540
|
views,
|
|
@@ -4544,7 +4544,7 @@ var useViewV2 = ({
|
|
|
4544
4544
|
}, [model, views, context, id]);
|
|
4545
4545
|
const view = useGetView2(
|
|
4546
4546
|
viewParams || {},
|
|
4547
|
-
!!viewParams &&
|
|
4547
|
+
!!viewParams && views?.length > 0
|
|
4548
4548
|
);
|
|
4549
4549
|
return {
|
|
4550
4550
|
...view,
|
|
@@ -4655,7 +4655,6 @@ var AppProvider = ({
|
|
|
4655
4655
|
}, [action]);
|
|
4656
4656
|
const view = useViewV2({
|
|
4657
4657
|
context: viewContext,
|
|
4658
|
-
// cũng nên memo nếu thay đổi liên tục
|
|
4659
4658
|
views: memoViews,
|
|
4660
4659
|
model: action?.res_model ? String(action.res_model) : void 0
|
|
4661
4660
|
});
|
|
@@ -4782,7 +4781,7 @@ var useGetSpecification = ({
|
|
|
4782
4781
|
|
|
4783
4782
|
// src/hooks/core/use-list-data.ts
|
|
4784
4783
|
var import_react14 = require("react");
|
|
4785
|
-
var
|
|
4784
|
+
var import_utils4 = require("@fctc/interface-logic/utils");
|
|
4786
4785
|
|
|
4787
4786
|
// src/hooks/utils/use-click-outside.ts
|
|
4788
4787
|
var import_react11 = require("react");
|
|
@@ -4924,12 +4923,12 @@ var useListData = ({
|
|
|
4924
4923
|
if (!viewData || !action || !context) {
|
|
4925
4924
|
return null;
|
|
4926
4925
|
}
|
|
4927
|
-
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0,
|
|
4926
|
+
const domainParse = type === "calendar" ? getDateRange(currentDate, mode) : action?.domain ? Array.isArray(action?.domain) ? [...action?.domain] : (0, import_utils4.evalJSONDomain)(action?.domain, context) : [];
|
|
4928
4927
|
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
4929
4928
|
const offset = debouncedPage * pageLimit;
|
|
4930
4929
|
const fields = type === "calendar" ? convertFieldsToArray(viewData?.views?.calendar?.fields) || [] : typeof groupByList === "object" ? groupByList?.fields : void 0;
|
|
4931
4930
|
const groupby = typeof groupByList === "object" ? [groupByList?.contexts?.[0]?.group_by] : [];
|
|
4932
|
-
const sort = order ? order : viewData?.views?.list?.default_order ? (0,
|
|
4931
|
+
const sort = order ? order : viewData?.views?.list?.default_order ? (0, import_utils4.formatSortingString)(viewData?.views?.list?.default_order) : "";
|
|
4933
4932
|
return {
|
|
4934
4933
|
model: action.res_model,
|
|
4935
4934
|
specification,
|
|
@@ -4957,7 +4956,7 @@ var useListData = ({
|
|
|
4957
4956
|
const list = useGetListData2(
|
|
4958
4957
|
listDataProps,
|
|
4959
4958
|
[listDataProps],
|
|
4960
|
-
!!listDataProps && !!specification && !(0,
|
|
4959
|
+
!!listDataProps && !!specification && !(0, import_utils4.isObjectEmpty)(specification)
|
|
4961
4960
|
);
|
|
4962
4961
|
return {
|
|
4963
4962
|
...list,
|
|
@@ -5464,18 +5463,18 @@ var many2oneFieldController = (props) => {
|
|
|
5464
5463
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
5465
5464
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
5466
5465
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
5467
|
-
var
|
|
5466
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
5468
5467
|
var many2oneButtonController = (props) => {
|
|
5469
5468
|
const { domain, methods, relation, service, xNode } = props;
|
|
5470
5469
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
5471
5470
|
const env = (0, import_environment2.getEnv)();
|
|
5472
|
-
const domainObject = (0,
|
|
5471
|
+
const domainObject = (0, import_utils7.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
5473
5472
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
5474
5473
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
5475
5474
|
data: {
|
|
5476
5475
|
model: relation ?? "",
|
|
5477
5476
|
domain: domainObject,
|
|
5478
|
-
context: { ...env.context, ...(0,
|
|
5477
|
+
context: { ...env.context, ...(0, import_utils7.evalJSONContext)(actionData?.context) }
|
|
5479
5478
|
},
|
|
5480
5479
|
queryKey: [`data_${relation}`, domainObject],
|
|
5481
5480
|
service,
|
|
@@ -5492,7 +5491,7 @@ var many2oneButtonController = (props) => {
|
|
|
5492
5491
|
|
|
5493
5492
|
// src/widget/basic/many2many-field/controller.ts
|
|
5494
5493
|
var import_react17 = require("react");
|
|
5495
|
-
var
|
|
5494
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
5496
5495
|
var many2manyFieldController = (props) => {
|
|
5497
5496
|
const {
|
|
5498
5497
|
relation,
|
|
@@ -5550,10 +5549,10 @@ var many2manyFieldController = (props) => {
|
|
|
5550
5549
|
return null;
|
|
5551
5550
|
}, [modelInstance]);
|
|
5552
5551
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
5553
|
-
const optionsObject = tab?.options ? (0,
|
|
5552
|
+
const optionsObject = tab?.options ? (0, import_utils8.evalJSONContext)(tab?.options) : (options ? (0, import_utils8.evalJSONContext)(options) : {}) || {};
|
|
5554
5553
|
const fetchData = async () => {
|
|
5555
5554
|
try {
|
|
5556
|
-
const domainParse = typeof domain === "string" ? (0,
|
|
5555
|
+
const domainParse = typeof domain === "string" ? (0, import_utils8.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
5557
5556
|
setDomainMany2Many(domainParse);
|
|
5558
5557
|
setPage(0);
|
|
5559
5558
|
} catch (err) {
|
|
@@ -5577,7 +5576,7 @@ var many2manyFieldController = (props) => {
|
|
|
5577
5576
|
context: contextObject,
|
|
5578
5577
|
fields: groupByDomain?.fields,
|
|
5579
5578
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
5580
|
-
sort: order ? order : default_order ? (0,
|
|
5579
|
+
sort: order ? order : default_order ? (0, import_utils8.formatSortingString)(default_order) : ""
|
|
5581
5580
|
};
|
|
5582
5581
|
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
5583
5582
|
const {
|
|
@@ -5641,7 +5640,7 @@ var many2manyFieldController = (props) => {
|
|
|
5641
5640
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
5642
5641
|
var import_react18 = require("react");
|
|
5643
5642
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
5644
|
-
var
|
|
5643
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
5645
5644
|
var many2manyTagsController = (props) => {
|
|
5646
5645
|
const {
|
|
5647
5646
|
relation,
|
|
@@ -5656,9 +5655,9 @@ var many2manyTagsController = (props) => {
|
|
|
5656
5655
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
5657
5656
|
const { env } = (0, provider_exports.useEnv)();
|
|
5658
5657
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
5659
|
-
const addtionalFields = optionsFields ? (0,
|
|
5658
|
+
const addtionalFields = optionsFields ? (0, import_utils9.evalJSONContext)(optionsFields) : null;
|
|
5660
5659
|
const domainObject = (0, import_react18.useMemo)(
|
|
5661
|
-
() => (0,
|
|
5660
|
+
() => (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
5662
5661
|
[domain, formValues]
|
|
5663
5662
|
);
|
|
5664
5663
|
const data = {
|
|
@@ -5703,7 +5702,7 @@ var many2manyTagsController = (props) => {
|
|
|
5703
5702
|
|
|
5704
5703
|
// src/widget/basic/status-bar-field/controller.ts
|
|
5705
5704
|
var import_react19 = require("react");
|
|
5706
|
-
var
|
|
5705
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
5707
5706
|
var durationController = (props) => {
|
|
5708
5707
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
5709
5708
|
const specification = {
|
|
@@ -5719,7 +5718,7 @@ var durationController = (props) => {
|
|
|
5719
5718
|
const listDataProps = {
|
|
5720
5719
|
model: relation,
|
|
5721
5720
|
specification,
|
|
5722
|
-
domain: (0,
|
|
5721
|
+
domain: (0, import_utils10.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
5723
5722
|
limit: 10,
|
|
5724
5723
|
offset: 0,
|
|
5725
5724
|
fields: "",
|
|
@@ -5769,10 +5768,10 @@ var durationController = (props) => {
|
|
|
5769
5768
|
};
|
|
5770
5769
|
|
|
5771
5770
|
// src/widget/basic/priority-field/controller.ts
|
|
5772
|
-
var
|
|
5771
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
5773
5772
|
var priorityFieldController = (props) => {
|
|
5774
5773
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
5775
|
-
const _context = { ...(0,
|
|
5774
|
+
const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) };
|
|
5776
5775
|
const contextObject = { ...context, ..._context };
|
|
5777
5776
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5778
5777
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -6740,12 +6739,12 @@ var dateFieldController = (props) => {
|
|
|
6740
6739
|
|
|
6741
6740
|
// src/widget/basic/copy-link-button/controller.ts
|
|
6742
6741
|
var import_react21 = require("react");
|
|
6743
|
-
var
|
|
6742
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
6744
6743
|
var copyLinkButtonController = (props) => {
|
|
6745
6744
|
const { value, defaultValue } = props;
|
|
6746
6745
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
6747
6746
|
const handleCopyToClipboard = async (value2) => {
|
|
6748
|
-
await (0,
|
|
6747
|
+
await (0, import_utils12.copyTextToClipboard)(value2);
|
|
6749
6748
|
setIsCopied(true);
|
|
6750
6749
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
6751
6750
|
};
|
|
@@ -6758,12 +6757,12 @@ var copyLinkButtonController = (props) => {
|
|
|
6758
6757
|
};
|
|
6759
6758
|
|
|
6760
6759
|
// src/widget/basic/color-field/color-controller.ts
|
|
6761
|
-
var
|
|
6760
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
6762
6761
|
var colorFieldController = (props) => {
|
|
6763
6762
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
6764
6763
|
const { env } = (0, provider_exports.useEnv)();
|
|
6765
6764
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
6766
|
-
const _context = { ...(0,
|
|
6765
|
+
const _context = { ...(0, import_utils13.evalJSONContext)(actionData?.context) || {} };
|
|
6767
6766
|
const contextObject = { ...env.context, ..._context };
|
|
6768
6767
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
6769
6768
|
const { mutate: onSave } = useSave3();
|
|
@@ -6792,7 +6791,7 @@ var colorFieldController = (props) => {
|
|
|
6792
6791
|
|
|
6793
6792
|
// src/widget/basic/binary-field/controller.ts
|
|
6794
6793
|
var import_react22 = require("react");
|
|
6795
|
-
var
|
|
6794
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
6796
6795
|
var binaryFieldController = (props) => {
|
|
6797
6796
|
const { name, methods, readonly = false, value } = props;
|
|
6798
6797
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6849,11 +6848,11 @@ var binaryFieldController = (props) => {
|
|
|
6849
6848
|
};
|
|
6850
6849
|
const checkIsImageLink = (url) => {
|
|
6851
6850
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6852
|
-
return imageExtensions.test(url) || (0,
|
|
6851
|
+
return imageExtensions.test(url) || (0, import_utils14.isBase64Image)(url) || isBlobUrl(url);
|
|
6853
6852
|
};
|
|
6854
6853
|
const getImageBase64WithMimeType = (base64) => {
|
|
6855
6854
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6856
|
-
if ((0,
|
|
6855
|
+
if ((0, import_utils14.isBase64Image)(base64)) return base64;
|
|
6857
6856
|
let mimeType = null;
|
|
6858
6857
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6859
6858
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6956,7 +6955,7 @@ var tableHeadController = (props) => {
|
|
|
6956
6955
|
|
|
6957
6956
|
// src/widget/advance/table/table-view/controller.ts
|
|
6958
6957
|
var import_react24 = require("react");
|
|
6959
|
-
var
|
|
6958
|
+
var import_utils16 = require("@fctc/interface-logic/utils");
|
|
6960
6959
|
var tableController = ({ data }) => {
|
|
6961
6960
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6962
6961
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6994,7 +6993,7 @@ var tableController = ({ data }) => {
|
|
|
6994
6993
|
let cols = [];
|
|
6995
6994
|
try {
|
|
6996
6995
|
cols = mergeFields?.filter((item) => {
|
|
6997
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6996
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils16.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils16.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
6998
6997
|
})?.map((field) => {
|
|
6999
6998
|
return {
|
|
7000
6999
|
name: field?.name,
|
|
@@ -7178,7 +7177,7 @@ var tableGroupController = (props) => {
|
|
|
7178
7177
|
|
|
7179
7178
|
// src/widget/advance/search/controller.ts
|
|
7180
7179
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
7181
|
-
var
|
|
7180
|
+
var import_utils18 = require("@fctc/interface-logic/utils");
|
|
7182
7181
|
var import_moment2 = __toESM(require_moment());
|
|
7183
7182
|
var import_react26 = require("react");
|
|
7184
7183
|
var searchController = ({
|
|
@@ -7195,9 +7194,9 @@ var searchController = ({
|
|
|
7195
7194
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
7196
7195
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
7197
7196
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
7198
|
-
const actionContext = typeof context === "string" ? (0,
|
|
7197
|
+
const actionContext = typeof context === "string" ? (0, import_utils18.evalJSONContext)(context) : context;
|
|
7199
7198
|
const contextSearch = { ...env.context, ...actionContext };
|
|
7200
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
7199
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils18.evalJSONDomain)(domain, contextSearch) : [];
|
|
7201
7200
|
const clearSearch = () => {
|
|
7202
7201
|
setFilterBy([]);
|
|
7203
7202
|
setGroupBy([]);
|
|
@@ -7212,7 +7211,7 @@ var searchController = ({
|
|
|
7212
7211
|
const dataModel = viewData?.models?.[model];
|
|
7213
7212
|
const searchViews = viewData?.views?.search;
|
|
7214
7213
|
const searchByItems = searchViews?.search_by?.filter(
|
|
7215
|
-
(item) => !
|
|
7214
|
+
(item) => !import_utils18.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
7216
7215
|
)?.map(
|
|
7217
7216
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
7218
7217
|
dataIndex: index,
|
|
@@ -7225,10 +7224,10 @@ var searchController = ({
|
|
|
7225
7224
|
})
|
|
7226
7225
|
);
|
|
7227
7226
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
7228
|
-
return !
|
|
7227
|
+
return !import_utils18.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
7229
7228
|
})?.map((item) => ({ ...item, active: false }));
|
|
7230
7229
|
const groupByItems = searchViews?.group_by.filter(
|
|
7231
|
-
(item) => !
|
|
7230
|
+
(item) => !import_utils18.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
7232
7231
|
).map((item) => ({
|
|
7233
7232
|
...item,
|
|
7234
7233
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -7305,14 +7304,14 @@ var searchController = ({
|
|
|
7305
7304
|
}
|
|
7306
7305
|
let valueDomainItem = value?.value;
|
|
7307
7306
|
if (value?.modelType === "date") {
|
|
7308
|
-
valueDomainItem = (0,
|
|
7307
|
+
valueDomainItem = (0, import_utils18.validateAndParseDate)(value?.value);
|
|
7309
7308
|
} else if (value?.modelType === "datetime") {
|
|
7310
7309
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
7311
|
-
const parsedDate = (0,
|
|
7310
|
+
const parsedDate = (0, import_utils18.validateAndParseDate)(value?.value, true);
|
|
7312
7311
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
7313
7312
|
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");
|
|
7314
7313
|
} else {
|
|
7315
|
-
valueDomainItem = (0,
|
|
7314
|
+
valueDomainItem = (0, import_utils18.validateAndParseDate)(value?.value, true);
|
|
7316
7315
|
}
|
|
7317
7316
|
}
|
|
7318
7317
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -7391,7 +7390,7 @@ var searchController = ({
|
|
|
7391
7390
|
}, [searchMap]);
|
|
7392
7391
|
const handleAddTagSearch = (tag) => {
|
|
7393
7392
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
7394
|
-
const domainFormat = new
|
|
7393
|
+
const domainFormat = new import_utils18.domainHelper.Domain(domain2);
|
|
7395
7394
|
if (type === import_constants3.SearchType.FILTER) {
|
|
7396
7395
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
7397
7396
|
...tag,
|
package/dist/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ var require_moment = __commonJS({
|
|
|
59
59
|
function hasOwnProp(a, b) {
|
|
60
60
|
return Object.prototype.hasOwnProperty.call(a, b);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function isObjectEmpty4(obj) {
|
|
63
63
|
if (Object.getOwnPropertyNames) {
|
|
64
64
|
return Object.getOwnPropertyNames(obj).length === 0;
|
|
65
65
|
} else {
|
|
@@ -2198,7 +2198,7 @@ var require_moment = __commonJS({
|
|
|
2198
2198
|
strict = locale2;
|
|
2199
2199
|
locale2 = void 0;
|
|
2200
2200
|
}
|
|
2201
|
-
if (isObject(input) &&
|
|
2201
|
+
if (isObject(input) && isObjectEmpty4(input) || isArray(input) && input.length === 0) {
|
|
2202
2202
|
input = void 0;
|
|
2203
2203
|
}
|
|
2204
2204
|
c._isAMomentObject = true;
|
|
@@ -2617,7 +2617,7 @@ var require_moment = __commonJS({
|
|
|
2617
2617
|
return isMoment(input) || isDate(input) || isString(input) || isNumber(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === void 0;
|
|
2618
2618
|
}
|
|
2619
2619
|
function isMomentInputObject(input) {
|
|
2620
|
-
var objectTest = isObject(input) && !
|
|
2620
|
+
var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2621
2621
|
"years",
|
|
2622
2622
|
"year",
|
|
2623
2623
|
"y",
|
|
@@ -2659,7 +2659,7 @@ var require_moment = __commonJS({
|
|
|
2659
2659
|
return arrayTest && dataTypeTest;
|
|
2660
2660
|
}
|
|
2661
2661
|
function isCalendarSpec(input) {
|
|
2662
|
-
var objectTest = isObject(input) && !
|
|
2662
|
+
var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2663
2663
|
"sameDay",
|
|
2664
2664
|
"nextDay",
|
|
2665
2665
|
"lastDay",
|
|
@@ -4609,7 +4609,7 @@ var useViewV2 = ({
|
|
|
4609
4609
|
}) => {
|
|
4610
4610
|
const { useGetView: useGetView2 } = (0, provider_exports.useService)();
|
|
4611
4611
|
const viewParams = useMemo3(() => {
|
|
4612
|
-
if (!model || !views) return void 0;
|
|
4612
|
+
if (!model || !views || views.length === 0) return void 0;
|
|
4613
4613
|
return {
|
|
4614
4614
|
model,
|
|
4615
4615
|
views,
|
|
@@ -4619,7 +4619,7 @@ var useViewV2 = ({
|
|
|
4619
4619
|
}, [model, views, context, id]);
|
|
4620
4620
|
const view = useGetView2(
|
|
4621
4621
|
viewParams || {},
|
|
4622
|
-
!!viewParams &&
|
|
4622
|
+
!!viewParams && views?.length > 0
|
|
4623
4623
|
);
|
|
4624
4624
|
return {
|
|
4625
4625
|
...view,
|
|
@@ -4730,7 +4730,6 @@ var AppProvider = ({
|
|
|
4730
4730
|
}, [action]);
|
|
4731
4731
|
const view = useViewV2({
|
|
4732
4732
|
context: viewContext,
|
|
4733
|
-
// cũng nên memo nếu thay đổi liên tục
|
|
4734
4733
|
views: memoViews,
|
|
4735
4734
|
model: action?.res_model ? String(action.res_model) : void 0
|
|
4736
4735
|
});
|
|
@@ -4860,7 +4859,7 @@ import { useMemo as useMemo7, useState as useState5 } from "react";
|
|
|
4860
4859
|
import {
|
|
4861
4860
|
evalJSONDomain,
|
|
4862
4861
|
formatSortingString,
|
|
4863
|
-
isObjectEmpty as
|
|
4862
|
+
isObjectEmpty as isObjectEmpty3
|
|
4864
4863
|
} from "@fctc/interface-logic/utils";
|
|
4865
4864
|
|
|
4866
4865
|
// src/hooks/utils/use-click-outside.ts
|
|
@@ -5036,7 +5035,7 @@ var useListData = ({
|
|
|
5036
5035
|
const list = useGetListData2(
|
|
5037
5036
|
listDataProps,
|
|
5038
5037
|
[listDataProps],
|
|
5039
|
-
!!listDataProps && !!specification && !
|
|
5038
|
+
!!listDataProps && !!specification && !isObjectEmpty3(specification)
|
|
5040
5039
|
);
|
|
5041
5040
|
return {
|
|
5042
5041
|
...list,
|
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 isObjectEmpty4(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) && isObjectEmpty4(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) && !isObjectEmpty4(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) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2659
2659
|
"sameDay",
|
|
2660
2660
|
"nextDay",
|
|
2661
2661
|
"lastDay",
|
|
@@ -4344,7 +4344,7 @@ var import_react11 = require("react");
|
|
|
4344
4344
|
|
|
4345
4345
|
// src/hooks/core/use-list-data.ts
|
|
4346
4346
|
var import_react15 = require("react");
|
|
4347
|
-
var
|
|
4347
|
+
var import_utils4 = require("@fctc/interface-logic/utils");
|
|
4348
4348
|
|
|
4349
4349
|
// src/hooks/utils/use-click-outside.ts
|
|
4350
4350
|
var import_react12 = require("react");
|
|
@@ -4615,18 +4615,18 @@ var many2oneFieldController = (props) => {
|
|
|
4615
4615
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
4616
4616
|
var import_environment2 = require("@fctc/interface-logic/environment");
|
|
4617
4617
|
var import_hooks6 = require("@fctc/interface-logic/hooks");
|
|
4618
|
-
var
|
|
4618
|
+
var import_utils7 = require("@fctc/interface-logic/utils");
|
|
4619
4619
|
var many2oneButtonController = (props) => {
|
|
4620
4620
|
const { domain, methods, relation, service, xNode } = props;
|
|
4621
4621
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
4622
4622
|
const env = (0, import_environment2.getEnv)();
|
|
4623
|
-
const domainObject = (0,
|
|
4623
|
+
const domainObject = (0, import_utils7.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
4624
4624
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
4625
4625
|
const { data: dataOfSelection } = (0, import_hooks6.useGetSelection)({
|
|
4626
4626
|
data: {
|
|
4627
4627
|
model: relation ?? "",
|
|
4628
4628
|
domain: domainObject,
|
|
4629
|
-
context: { ...env.context, ...(0,
|
|
4629
|
+
context: { ...env.context, ...(0, import_utils7.evalJSONContext)(actionData?.context) }
|
|
4630
4630
|
},
|
|
4631
4631
|
queryKey: [`data_${relation}`, domainObject],
|
|
4632
4632
|
service,
|
|
@@ -4643,7 +4643,7 @@ var many2oneButtonController = (props) => {
|
|
|
4643
4643
|
|
|
4644
4644
|
// src/widget/basic/many2many-field/controller.ts
|
|
4645
4645
|
var import_react17 = require("react");
|
|
4646
|
-
var
|
|
4646
|
+
var import_utils8 = require("@fctc/interface-logic/utils");
|
|
4647
4647
|
var many2manyFieldController = (props) => {
|
|
4648
4648
|
const {
|
|
4649
4649
|
relation,
|
|
@@ -4701,10 +4701,10 @@ var many2manyFieldController = (props) => {
|
|
|
4701
4701
|
return null;
|
|
4702
4702
|
}, [modelInstance]);
|
|
4703
4703
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4704
|
-
const optionsObject = tab?.options ? (0,
|
|
4704
|
+
const optionsObject = tab?.options ? (0, import_utils8.evalJSONContext)(tab?.options) : (options ? (0, import_utils8.evalJSONContext)(options) : {}) || {};
|
|
4705
4705
|
const fetchData = async () => {
|
|
4706
4706
|
try {
|
|
4707
|
-
const domainParse = typeof domain === "string" ? (0,
|
|
4707
|
+
const domainParse = typeof domain === "string" ? (0, import_utils8.evalJSONDomain)(domain, contextObject) : Array.isArray(domain) ? domain : [];
|
|
4708
4708
|
setDomainMany2Many(domainParse);
|
|
4709
4709
|
setPage(0);
|
|
4710
4710
|
} catch (err) {
|
|
@@ -4728,7 +4728,7 @@ var many2manyFieldController = (props) => {
|
|
|
4728
4728
|
context: contextObject,
|
|
4729
4729
|
fields: groupByDomain?.fields,
|
|
4730
4730
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4731
|
-
sort: order ? order : default_order ? (0,
|
|
4731
|
+
sort: order ? order : default_order ? (0, import_utils8.formatSortingString)(default_order) : ""
|
|
4732
4732
|
};
|
|
4733
4733
|
const enabled = enabledCallAPI && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4734
4734
|
const {
|
|
@@ -4792,7 +4792,7 @@ var many2manyFieldController = (props) => {
|
|
|
4792
4792
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
4793
4793
|
var import_react18 = require("react");
|
|
4794
4794
|
var import_constants2 = require("@fctc/interface-logic/constants");
|
|
4795
|
-
var
|
|
4795
|
+
var import_utils9 = require("@fctc/interface-logic/utils");
|
|
4796
4796
|
var many2manyTagsController = (props) => {
|
|
4797
4797
|
const {
|
|
4798
4798
|
relation,
|
|
@@ -4807,9 +4807,9 @@ var many2manyTagsController = (props) => {
|
|
|
4807
4807
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
4808
4808
|
const { env } = (0, provider_exports.useEnv)();
|
|
4809
4809
|
const { useGetSelection: useGetSelection3 } = (0, provider_exports.useService)();
|
|
4810
|
-
const addtionalFields = optionsFields ? (0,
|
|
4810
|
+
const addtionalFields = optionsFields ? (0, import_utils9.evalJSONContext)(optionsFields) : null;
|
|
4811
4811
|
const domainObject = (0, import_react18.useMemo)(
|
|
4812
|
-
() => (0,
|
|
4812
|
+
() => (0, import_utils9.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
4813
4813
|
[domain, formValues]
|
|
4814
4814
|
);
|
|
4815
4815
|
const data = {
|
|
@@ -4854,7 +4854,7 @@ var many2manyTagsController = (props) => {
|
|
|
4854
4854
|
|
|
4855
4855
|
// src/widget/basic/status-bar-field/controller.ts
|
|
4856
4856
|
var import_react19 = require("react");
|
|
4857
|
-
var
|
|
4857
|
+
var import_utils10 = require("@fctc/interface-logic/utils");
|
|
4858
4858
|
var durationController = (props) => {
|
|
4859
4859
|
const { relation, domain, formValues, name, id, model, onRefetch, enabled } = props;
|
|
4860
4860
|
const specification = {
|
|
@@ -4870,7 +4870,7 @@ var durationController = (props) => {
|
|
|
4870
4870
|
const listDataProps = {
|
|
4871
4871
|
model: relation,
|
|
4872
4872
|
specification,
|
|
4873
|
-
domain: (0,
|
|
4873
|
+
domain: (0, import_utils10.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
4874
4874
|
limit: 10,
|
|
4875
4875
|
offset: 0,
|
|
4876
4876
|
fields: "",
|
|
@@ -4920,10 +4920,10 @@ var durationController = (props) => {
|
|
|
4920
4920
|
};
|
|
4921
4921
|
|
|
4922
4922
|
// src/widget/basic/priority-field/controller.ts
|
|
4923
|
-
var
|
|
4923
|
+
var import_utils11 = require("@fctc/interface-logic/utils");
|
|
4924
4924
|
var priorityFieldController = (props) => {
|
|
4925
4925
|
const { name, model, index, actionData, context, onChange, specification } = props;
|
|
4926
|
-
const _context = { ...(0,
|
|
4926
|
+
const _context = { ...(0, import_utils11.evalJSONContext)(actionData?.context) };
|
|
4927
4927
|
const contextObject = { ...context, ..._context };
|
|
4928
4928
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
4929
4929
|
const { mutateAsync: fetchSave } = useSave3();
|
|
@@ -5891,12 +5891,12 @@ var dateFieldController = (props) => {
|
|
|
5891
5891
|
|
|
5892
5892
|
// src/widget/basic/copy-link-button/controller.ts
|
|
5893
5893
|
var import_react21 = require("react");
|
|
5894
|
-
var
|
|
5894
|
+
var import_utils12 = require("@fctc/interface-logic/utils");
|
|
5895
5895
|
var copyLinkButtonController = (props) => {
|
|
5896
5896
|
const { value, defaultValue } = props;
|
|
5897
5897
|
const [isCopied, setIsCopied] = (0, import_react21.useState)(false);
|
|
5898
5898
|
const handleCopyToClipboard = async (value2) => {
|
|
5899
|
-
await (0,
|
|
5899
|
+
await (0, import_utils12.copyTextToClipboard)(value2);
|
|
5900
5900
|
setIsCopied(true);
|
|
5901
5901
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
5902
5902
|
};
|
|
@@ -5909,12 +5909,12 @@ var copyLinkButtonController = (props) => {
|
|
|
5909
5909
|
};
|
|
5910
5910
|
|
|
5911
5911
|
// src/widget/basic/color-field/color-controller.ts
|
|
5912
|
-
var
|
|
5912
|
+
var import_utils13 = require("@fctc/interface-logic/utils");
|
|
5913
5913
|
var colorFieldController = (props) => {
|
|
5914
5914
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
5915
5915
|
const { env } = (0, provider_exports.useEnv)();
|
|
5916
5916
|
const { useSave: useSave3 } = (0, provider_exports.useService)();
|
|
5917
|
-
const _context = { ...(0,
|
|
5917
|
+
const _context = { ...(0, import_utils13.evalJSONContext)(actionData?.context) || {} };
|
|
5918
5918
|
const contextObject = { ...env.context, ..._context };
|
|
5919
5919
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
5920
5920
|
const { mutate: onSave } = useSave3();
|
|
@@ -5943,7 +5943,7 @@ var colorFieldController = (props) => {
|
|
|
5943
5943
|
|
|
5944
5944
|
// src/widget/basic/binary-field/controller.ts
|
|
5945
5945
|
var import_react22 = require("react");
|
|
5946
|
-
var
|
|
5946
|
+
var import_utils14 = require("@fctc/interface-logic/utils");
|
|
5947
5947
|
var binaryFieldController = (props) => {
|
|
5948
5948
|
const { name, methods, readonly = false, value } = props;
|
|
5949
5949
|
const inputId = (0, import_react22.useId)();
|
|
@@ -6000,11 +6000,11 @@ var binaryFieldController = (props) => {
|
|
|
6000
6000
|
};
|
|
6001
6001
|
const checkIsImageLink = (url) => {
|
|
6002
6002
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
6003
|
-
return imageExtensions.test(url) || (0,
|
|
6003
|
+
return imageExtensions.test(url) || (0, import_utils14.isBase64Image)(url) || isBlobUrl(url);
|
|
6004
6004
|
};
|
|
6005
6005
|
const getImageBase64WithMimeType = (base64) => {
|
|
6006
6006
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
6007
|
-
if ((0,
|
|
6007
|
+
if ((0, import_utils14.isBase64Image)(base64)) return base64;
|
|
6008
6008
|
let mimeType = null;
|
|
6009
6009
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
6010
6010
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -6107,7 +6107,7 @@ var tableHeadController = (props) => {
|
|
|
6107
6107
|
|
|
6108
6108
|
// src/widget/advance/table/table-view/controller.ts
|
|
6109
6109
|
var import_react24 = require("react");
|
|
6110
|
-
var
|
|
6110
|
+
var import_utils16 = require("@fctc/interface-logic/utils");
|
|
6111
6111
|
var tableController = ({ data }) => {
|
|
6112
6112
|
const [rows, setRows] = (0, import_react24.useState)(null);
|
|
6113
6113
|
const [columns, setColumns] = (0, import_react24.useState)(null);
|
|
@@ -6145,7 +6145,7 @@ var tableController = ({ data }) => {
|
|
|
6145
6145
|
let cols = [];
|
|
6146
6146
|
try {
|
|
6147
6147
|
cols = mergeFields?.filter((item) => {
|
|
6148
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
6148
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_utils16.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_utils16.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
6149
6149
|
})?.map((field) => {
|
|
6150
6150
|
return {
|
|
6151
6151
|
name: field?.name,
|
|
@@ -6329,7 +6329,7 @@ var tableGroupController = (props) => {
|
|
|
6329
6329
|
|
|
6330
6330
|
// src/widget/advance/search/controller.ts
|
|
6331
6331
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6332
|
-
var
|
|
6332
|
+
var import_utils18 = require("@fctc/interface-logic/utils");
|
|
6333
6333
|
var import_moment2 = __toESM(require_moment());
|
|
6334
6334
|
var import_react26 = require("react");
|
|
6335
6335
|
var searchController = ({
|
|
@@ -6346,9 +6346,9 @@ var searchController = ({
|
|
|
6346
6346
|
const [selectedTags, setSelectedTags] = (0, import_react26.useState)(null);
|
|
6347
6347
|
const [searchString, setSearchString] = (0, import_react26.useState)("");
|
|
6348
6348
|
const [searchMap, setSearchMap] = (0, import_react26.useState)({});
|
|
6349
|
-
const actionContext = typeof context === "string" ? (0,
|
|
6349
|
+
const actionContext = typeof context === "string" ? (0, import_utils18.evalJSONContext)(context) : context;
|
|
6350
6350
|
const contextSearch = { ...env.context, ...actionContext };
|
|
6351
|
-
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0,
|
|
6351
|
+
const domainAction = domain ? Array.isArray(domain) ? [...domain] : (0, import_utils18.evalJSONDomain)(domain, contextSearch) : [];
|
|
6352
6352
|
const clearSearch = () => {
|
|
6353
6353
|
setFilterBy([]);
|
|
6354
6354
|
setGroupBy([]);
|
|
@@ -6363,7 +6363,7 @@ var searchController = ({
|
|
|
6363
6363
|
const dataModel = viewData?.models?.[model];
|
|
6364
6364
|
const searchViews = viewData?.views?.search;
|
|
6365
6365
|
const searchByItems = searchViews?.search_by?.filter(
|
|
6366
|
-
(item) => !
|
|
6366
|
+
(item) => !import_utils18.domainHelper.matchDomains(contextSearch, item.invisible)
|
|
6367
6367
|
)?.map(
|
|
6368
6368
|
({ string, name, filter_domain, operator, widget }, index) => ({
|
|
6369
6369
|
dataIndex: index,
|
|
@@ -6376,10 +6376,10 @@ var searchController = ({
|
|
|
6376
6376
|
})
|
|
6377
6377
|
);
|
|
6378
6378
|
const filterByItems = searchViews?.filter_by.filter((item) => {
|
|
6379
|
-
return !
|
|
6379
|
+
return !import_utils18.domainHelper.matchDomains(contextSearch, item?.invisible);
|
|
6380
6380
|
})?.map((item) => ({ ...item, active: false }));
|
|
6381
6381
|
const groupByItems = searchViews?.group_by.filter(
|
|
6382
|
-
(item) => !
|
|
6382
|
+
(item) => !import_utils18.domainHelper.matchDomains(contextSearch, item?.invisible)
|
|
6383
6383
|
).map((item) => ({
|
|
6384
6384
|
...item,
|
|
6385
6385
|
string: item.string ?? viewData?.models?.[model]?.[item?.name?.split("group_by_")?.[1]]?.string
|
|
@@ -6456,14 +6456,14 @@ var searchController = ({
|
|
|
6456
6456
|
}
|
|
6457
6457
|
let valueDomainItem = value?.value;
|
|
6458
6458
|
if (value?.modelType === "date") {
|
|
6459
|
-
valueDomainItem = (0,
|
|
6459
|
+
valueDomainItem = (0, import_utils18.validateAndParseDate)(value?.value);
|
|
6460
6460
|
} else if (value?.modelType === "datetime") {
|
|
6461
6461
|
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6462
|
-
const parsedDate = (0,
|
|
6462
|
+
const parsedDate = (0, import_utils18.validateAndParseDate)(value?.value, true);
|
|
6463
6463
|
const hasTime = (0, import_moment2.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6464
6464
|
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");
|
|
6465
6465
|
} else {
|
|
6466
|
-
valueDomainItem = (0,
|
|
6466
|
+
valueDomainItem = (0, import_utils18.validateAndParseDate)(value?.value, true);
|
|
6467
6467
|
}
|
|
6468
6468
|
}
|
|
6469
6469
|
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
@@ -6542,7 +6542,7 @@ var searchController = ({
|
|
|
6542
6542
|
}, [searchMap]);
|
|
6543
6543
|
const handleAddTagSearch = (tag) => {
|
|
6544
6544
|
const { domain: domain2, groupIndex, value, type, context: context2, dataIndex } = tag;
|
|
6545
|
-
const domainFormat = new
|
|
6545
|
+
const domainFormat = new import_utils18.domainHelper.Domain(domain2);
|
|
6546
6546
|
if (type === import_constants3.SearchType.FILTER) {
|
|
6547
6547
|
addSearchItems(`${import_constants3.SearchType.FILTER}_${groupIndex}`, {
|
|
6548
6548
|
...tag,
|
package/dist/widget.mjs
CHANGED
|
@@ -59,7 +59,7 @@ var require_moment = __commonJS({
|
|
|
59
59
|
function hasOwnProp(a, b) {
|
|
60
60
|
return Object.prototype.hasOwnProperty.call(a, b);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function isObjectEmpty4(obj) {
|
|
63
63
|
if (Object.getOwnPropertyNames) {
|
|
64
64
|
return Object.getOwnPropertyNames(obj).length === 0;
|
|
65
65
|
} else {
|
|
@@ -2198,7 +2198,7 @@ var require_moment = __commonJS({
|
|
|
2198
2198
|
strict = locale2;
|
|
2199
2199
|
locale2 = void 0;
|
|
2200
2200
|
}
|
|
2201
|
-
if (isObject(input) &&
|
|
2201
|
+
if (isObject(input) && isObjectEmpty4(input) || isArray(input) && input.length === 0) {
|
|
2202
2202
|
input = void 0;
|
|
2203
2203
|
}
|
|
2204
2204
|
c._isAMomentObject = true;
|
|
@@ -2617,7 +2617,7 @@ var require_moment = __commonJS({
|
|
|
2617
2617
|
return isMoment(input) || isDate(input) || isString(input) || isNumber(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === void 0;
|
|
2618
2618
|
}
|
|
2619
2619
|
function isMomentInputObject(input) {
|
|
2620
|
-
var objectTest = isObject(input) && !
|
|
2620
|
+
var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2621
2621
|
"years",
|
|
2622
2622
|
"year",
|
|
2623
2623
|
"y",
|
|
@@ -2659,7 +2659,7 @@ var require_moment = __commonJS({
|
|
|
2659
2659
|
return arrayTest && dataTypeTest;
|
|
2660
2660
|
}
|
|
2661
2661
|
function isCalendarSpec(input) {
|
|
2662
|
-
var objectTest = isObject(input) && !
|
|
2662
|
+
var objectTest = isObject(input) && !isObjectEmpty4(input), propertyTest = false, properties = [
|
|
2663
2663
|
"sameDay",
|
|
2664
2664
|
"nextDay",
|
|
2665
2665
|
"lastDay",
|
|
@@ -4400,7 +4400,7 @@ import { useMemo as useMemo7, useState as useState6 } from "react";
|
|
|
4400
4400
|
import {
|
|
4401
4401
|
evalJSONDomain,
|
|
4402
4402
|
formatSortingString,
|
|
4403
|
-
isObjectEmpty as
|
|
4403
|
+
isObjectEmpty as isObjectEmpty3
|
|
4404
4404
|
} from "@fctc/interface-logic/utils";
|
|
4405
4405
|
|
|
4406
4406
|
// src/hooks/utils/use-click-outside.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fctc/widget-logic",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.10",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"test": "jest"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@fctc/interface-logic": "^2.4.
|
|
77
|
+
"@fctc/interface-logic": "^2.4.10",
|
|
78
78
|
"@headlessui/react": "^2.2.6",
|
|
79
79
|
"@tanstack/react-query": "^5.84.0",
|
|
80
80
|
"i18next": "^25.3.2",
|