@fctc/widget-logic 1.8.5 → 1.8.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/index.js +56 -8
- package/dist/index.mjs +65 -13
- package/dist/widget.d.mts +1 -0
- package/dist/widget.d.ts +1 -0
- package/dist/widget.js +56 -8
- package/dist/widget.mjs +65 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6533,6 +6533,7 @@ var tableGroupController = (props) => {
|
|
|
6533
6533
|
// src/widget/advance/search/controller.ts
|
|
6534
6534
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6535
6535
|
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
6536
|
+
var import_moment = __toESM(require_moment());
|
|
6536
6537
|
var import_react18 = require("react");
|
|
6537
6538
|
var searchController = ({
|
|
6538
6539
|
viewData,
|
|
@@ -6630,6 +6631,52 @@ var searchController = ({
|
|
|
6630
6631
|
const addSearchItems = (key, newItem) => {
|
|
6631
6632
|
updateSearchMap({ key, item: newItem });
|
|
6632
6633
|
};
|
|
6634
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils6.evalJSONDomain)(actionData?.domain, contextSearch) : [];
|
|
6635
|
+
const formatDomain = () => {
|
|
6636
|
+
if (domainAction) {
|
|
6637
|
+
const domain = [];
|
|
6638
|
+
if (domainAction?.length > 0) {
|
|
6639
|
+
if (Object.keys(searchMap).length > 0) {
|
|
6640
|
+
domain.push("&");
|
|
6641
|
+
}
|
|
6642
|
+
domainAction.forEach((domainItem) => {
|
|
6643
|
+
domain.push(domainItem);
|
|
6644
|
+
});
|
|
6645
|
+
}
|
|
6646
|
+
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
6647
|
+
if (!key?.includes(import_constants3.SearchType.GROUP)) {
|
|
6648
|
+
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
6649
|
+
domain.push("&");
|
|
6650
|
+
}
|
|
6651
|
+
const valuesOfKey = searchMap[key];
|
|
6652
|
+
valuesOfKey.forEach((value, index) => {
|
|
6653
|
+
if (index < valuesOfKey.length - 1) {
|
|
6654
|
+
domain.push("|");
|
|
6655
|
+
}
|
|
6656
|
+
if (value.domain) {
|
|
6657
|
+
domain.push(...value.domain);
|
|
6658
|
+
return;
|
|
6659
|
+
}
|
|
6660
|
+
let valueDomainItem = value?.value;
|
|
6661
|
+
if (value?.modelType === "date") {
|
|
6662
|
+
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value);
|
|
6663
|
+
} else if (value?.modelType === "datetime") {
|
|
6664
|
+
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6665
|
+
const parsedDate = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6666
|
+
const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6667
|
+
valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
6668
|
+
} else {
|
|
6669
|
+
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
6673
|
+
domain.push([value.name, operator, valueDomainItem]);
|
|
6674
|
+
});
|
|
6675
|
+
}
|
|
6676
|
+
});
|
|
6677
|
+
return [...domain];
|
|
6678
|
+
}
|
|
6679
|
+
};
|
|
6633
6680
|
const setTagSearch = (0, import_react18.useCallback)(
|
|
6634
6681
|
(updatedMap) => {
|
|
6635
6682
|
if (!updatedMap) return;
|
|
@@ -6745,7 +6792,8 @@ var searchController = ({
|
|
|
6745
6792
|
setSelectedTags,
|
|
6746
6793
|
removeSearchItems,
|
|
6747
6794
|
onSearchString: onChangeSearchInput,
|
|
6748
|
-
handleAddTagSearch
|
|
6795
|
+
handleAddTagSearch,
|
|
6796
|
+
domain: formatDomain()
|
|
6749
6797
|
};
|
|
6750
6798
|
};
|
|
6751
6799
|
|
|
@@ -7376,7 +7424,7 @@ var downLoadBinaryController = (props) => {
|
|
|
7376
7424
|
};
|
|
7377
7425
|
|
|
7378
7426
|
// src/widget/basic/date-field/controller.ts
|
|
7379
|
-
var
|
|
7427
|
+
var import_moment2 = __toESM(require_moment());
|
|
7380
7428
|
var DURATIONS = {
|
|
7381
7429
|
PAST: "past",
|
|
7382
7430
|
NOW: "now",
|
|
@@ -7403,8 +7451,8 @@ var dateFieldController = (props) => {
|
|
|
7403
7451
|
const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
|
|
7404
7452
|
const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
7405
7453
|
const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
|
|
7406
|
-
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0,
|
|
7407
|
-
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0,
|
|
7454
|
+
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment2.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
|
|
7455
|
+
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment2.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
|
|
7408
7456
|
const years = range(
|
|
7409
7457
|
minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
|
|
7410
7458
|
(/* @__PURE__ */ new Date()).getFullYear() + 4,
|
|
@@ -7439,8 +7487,8 @@ var dateFieldController = (props) => {
|
|
|
7439
7487
|
"December"
|
|
7440
7488
|
];
|
|
7441
7489
|
const customValidateMinMax = (date) => {
|
|
7442
|
-
const selected = (0,
|
|
7443
|
-
const now = (0,
|
|
7490
|
+
const selected = (0, import_moment2.default)(date, formatDateParse);
|
|
7491
|
+
const now = (0, import_moment2.default)();
|
|
7444
7492
|
const compareSelected = showTime ? selected : selected.clone().startOf("day");
|
|
7445
7493
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
7446
7494
|
if (minNowValue) {
|
|
@@ -7448,7 +7496,7 @@ var dateFieldController = (props) => {
|
|
|
7448
7496
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7449
7497
|
"greater_or_equal_now"
|
|
7450
7498
|
)}`;
|
|
7451
|
-
} else if (
|
|
7499
|
+
} else if (import_moment2.default.isMoment(minNowValue)) {
|
|
7452
7500
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
7453
7501
|
if (compareSelected.isBefore(compareMin)) {
|
|
7454
7502
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
@@ -7462,7 +7510,7 @@ var dateFieldController = (props) => {
|
|
|
7462
7510
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7463
7511
|
"less_or_equal_now"
|
|
7464
7512
|
)}`;
|
|
7465
|
-
} else if (
|
|
7513
|
+
} else if (import_moment2.default.isMoment(maxNowValue)) {
|
|
7466
7514
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
7467
7515
|
if (compareSelected.isAfter(compareMax)) {
|
|
7468
7516
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|
package/dist/index.mjs
CHANGED
|
@@ -6583,8 +6583,13 @@ var tableGroupController = (props) => {
|
|
|
6583
6583
|
};
|
|
6584
6584
|
|
|
6585
6585
|
// src/widget/advance/search/controller.ts
|
|
6586
|
+
var import_moment = __toESM(require_moment());
|
|
6586
6587
|
import { SearchType } from "@fctc/interface-logic/constants";
|
|
6587
|
-
import {
|
|
6588
|
+
import {
|
|
6589
|
+
domainHelper as domainHelper2,
|
|
6590
|
+
evalJSONDomain as evalJSONDomain4,
|
|
6591
|
+
validateAndParseDate
|
|
6592
|
+
} from "@fctc/interface-logic/utils";
|
|
6588
6593
|
import { useCallback as useCallback3, useEffect as useEffect14, useState as useState10 } from "react";
|
|
6589
6594
|
var searchController = ({
|
|
6590
6595
|
viewData,
|
|
@@ -6682,6 +6687,52 @@ var searchController = ({
|
|
|
6682
6687
|
const addSearchItems = (key, newItem) => {
|
|
6683
6688
|
updateSearchMap({ key, item: newItem });
|
|
6684
6689
|
};
|
|
6690
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : evalJSONDomain4(actionData?.domain, contextSearch) : [];
|
|
6691
|
+
const formatDomain = () => {
|
|
6692
|
+
if (domainAction) {
|
|
6693
|
+
const domain = [];
|
|
6694
|
+
if (domainAction?.length > 0) {
|
|
6695
|
+
if (Object.keys(searchMap).length > 0) {
|
|
6696
|
+
domain.push("&");
|
|
6697
|
+
}
|
|
6698
|
+
domainAction.forEach((domainItem) => {
|
|
6699
|
+
domain.push(domainItem);
|
|
6700
|
+
});
|
|
6701
|
+
}
|
|
6702
|
+
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
6703
|
+
if (!key?.includes(SearchType.GROUP)) {
|
|
6704
|
+
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
6705
|
+
domain.push("&");
|
|
6706
|
+
}
|
|
6707
|
+
const valuesOfKey = searchMap[key];
|
|
6708
|
+
valuesOfKey.forEach((value, index) => {
|
|
6709
|
+
if (index < valuesOfKey.length - 1) {
|
|
6710
|
+
domain.push("|");
|
|
6711
|
+
}
|
|
6712
|
+
if (value.domain) {
|
|
6713
|
+
domain.push(...value.domain);
|
|
6714
|
+
return;
|
|
6715
|
+
}
|
|
6716
|
+
let valueDomainItem = value?.value;
|
|
6717
|
+
if (value?.modelType === "date") {
|
|
6718
|
+
valueDomainItem = validateAndParseDate(value?.value);
|
|
6719
|
+
} else if (value?.modelType === "datetime") {
|
|
6720
|
+
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6721
|
+
const parsedDate = validateAndParseDate(value?.value, true);
|
|
6722
|
+
const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6723
|
+
valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
6724
|
+
} else {
|
|
6725
|
+
valueDomainItem = validateAndParseDate(value?.value, true);
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6728
|
+
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
6729
|
+
domain.push([value.name, operator, valueDomainItem]);
|
|
6730
|
+
});
|
|
6731
|
+
}
|
|
6732
|
+
});
|
|
6733
|
+
return [...domain];
|
|
6734
|
+
}
|
|
6735
|
+
};
|
|
6685
6736
|
const setTagSearch = useCallback3(
|
|
6686
6737
|
(updatedMap) => {
|
|
6687
6738
|
if (!updatedMap) return;
|
|
@@ -6797,7 +6848,8 @@ var searchController = ({
|
|
|
6797
6848
|
setSelectedTags,
|
|
6798
6849
|
removeSearchItems,
|
|
6799
6850
|
onSearchString: onChangeSearchInput,
|
|
6800
|
-
handleAddTagSearch
|
|
6851
|
+
handleAddTagSearch,
|
|
6852
|
+
domain: formatDomain()
|
|
6801
6853
|
};
|
|
6802
6854
|
};
|
|
6803
6855
|
|
|
@@ -6990,7 +7042,7 @@ import { useMemo as useMemo14 } from "react";
|
|
|
6990
7042
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
6991
7043
|
import { getEnv as getEnv9 } from "@fctc/interface-logic/environment";
|
|
6992
7044
|
import { useGetSelection as useGetSelection3 } from "@fctc/interface-logic/hooks";
|
|
6993
|
-
import { evalJSONContext as evalJSONContext5, evalJSONDomain as
|
|
7045
|
+
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
6994
7046
|
var many2manyTagsController = (props) => {
|
|
6995
7047
|
const {
|
|
6996
7048
|
relation,
|
|
@@ -7004,7 +7056,7 @@ var many2manyTagsController = (props) => {
|
|
|
7004
7056
|
const env = getEnv9();
|
|
7005
7057
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
7006
7058
|
const domainObject = useMemo14(
|
|
7007
|
-
() =>
|
|
7059
|
+
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
7008
7060
|
[domain, formValues]
|
|
7009
7061
|
);
|
|
7010
7062
|
const data = {
|
|
@@ -7049,7 +7101,7 @@ var many2manyTagsController = (props) => {
|
|
|
7049
7101
|
import { useState as useState12 } from "react";
|
|
7050
7102
|
import { useGetListData as useGetListData4, useChangeStatus } from "@fctc/interface-logic/hooks";
|
|
7051
7103
|
import { useAppSelector as useAppSelector8, selectEnv as selectEnv2 } from "@fctc/interface-logic/store";
|
|
7052
|
-
import { evalJSONDomain as
|
|
7104
|
+
import { evalJSONDomain as evalJSONDomain6 } from "@fctc/interface-logic/utils";
|
|
7053
7105
|
var durationController = (props) => {
|
|
7054
7106
|
const {
|
|
7055
7107
|
relation,
|
|
@@ -7073,7 +7125,7 @@ var durationController = (props) => {
|
|
|
7073
7125
|
const listDataProps = {
|
|
7074
7126
|
model: relation,
|
|
7075
7127
|
specification,
|
|
7076
|
-
domain:
|
|
7128
|
+
domain: evalJSONDomain6(domain, JSON.parse(JSON.stringify(formValues))),
|
|
7077
7129
|
limit: 10,
|
|
7078
7130
|
offset: 0,
|
|
7079
7131
|
fields: "",
|
|
@@ -7442,7 +7494,7 @@ var downLoadBinaryController = (props) => {
|
|
|
7442
7494
|
};
|
|
7443
7495
|
|
|
7444
7496
|
// src/widget/basic/date-field/controller.ts
|
|
7445
|
-
var
|
|
7497
|
+
var import_moment2 = __toESM(require_moment());
|
|
7446
7498
|
var DURATIONS = {
|
|
7447
7499
|
PAST: "past",
|
|
7448
7500
|
NOW: "now",
|
|
@@ -7469,8 +7521,8 @@ var dateFieldController = (props) => {
|
|
|
7469
7521
|
const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
|
|
7470
7522
|
const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
7471
7523
|
const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
|
|
7472
|
-
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0,
|
|
7473
|
-
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0,
|
|
7524
|
+
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment2.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
|
|
7525
|
+
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment2.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
|
|
7474
7526
|
const years = range(
|
|
7475
7527
|
minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
|
|
7476
7528
|
(/* @__PURE__ */ new Date()).getFullYear() + 4,
|
|
@@ -7505,8 +7557,8 @@ var dateFieldController = (props) => {
|
|
|
7505
7557
|
"December"
|
|
7506
7558
|
];
|
|
7507
7559
|
const customValidateMinMax = (date) => {
|
|
7508
|
-
const selected = (0,
|
|
7509
|
-
const now = (0,
|
|
7560
|
+
const selected = (0, import_moment2.default)(date, formatDateParse);
|
|
7561
|
+
const now = (0, import_moment2.default)();
|
|
7510
7562
|
const compareSelected = showTime ? selected : selected.clone().startOf("day");
|
|
7511
7563
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
7512
7564
|
if (minNowValue) {
|
|
@@ -7514,7 +7566,7 @@ var dateFieldController = (props) => {
|
|
|
7514
7566
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7515
7567
|
"greater_or_equal_now"
|
|
7516
7568
|
)}`;
|
|
7517
|
-
} else if (
|
|
7569
|
+
} else if (import_moment2.default.isMoment(minNowValue)) {
|
|
7518
7570
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
7519
7571
|
if (compareSelected.isBefore(compareMin)) {
|
|
7520
7572
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
@@ -7528,7 +7580,7 @@ var dateFieldController = (props) => {
|
|
|
7528
7580
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7529
7581
|
"less_or_equal_now"
|
|
7530
7582
|
)}`;
|
|
7531
|
-
} else if (
|
|
7583
|
+
} else if (import_moment2.default.isMoment(maxNowValue)) {
|
|
7532
7584
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
7533
7585
|
if (compareSelected.isAfter(compareMax)) {
|
|
7534
7586
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|
package/dist/widget.d.mts
CHANGED
|
@@ -312,6 +312,7 @@ declare const searchController: ({ viewData, actionData, fieldsList, contextSear
|
|
|
312
312
|
removeSearchItems: (key: string, item: any) => void;
|
|
313
313
|
onSearchString: (search_string: string) => void;
|
|
314
314
|
handleAddTagSearch: (tag: any) => void;
|
|
315
|
+
domain: any[] | undefined;
|
|
315
316
|
};
|
|
316
317
|
|
|
317
318
|
export { type ISelctionStateProps, type ITableBodyProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController };
|
package/dist/widget.d.ts
CHANGED
|
@@ -312,6 +312,7 @@ declare const searchController: ({ viewData, actionData, fieldsList, contextSear
|
|
|
312
312
|
removeSearchItems: (key: string, item: any) => void;
|
|
313
313
|
onSearchString: (search_string: string) => void;
|
|
314
314
|
handleAddTagSearch: (tag: any) => void;
|
|
315
|
+
domain: any[] | undefined;
|
|
315
316
|
};
|
|
316
317
|
|
|
317
318
|
export { type ISelctionStateProps, type ITableBodyProps, type ITableHeadProps, type ITableProps, binaryFieldController, colorFieldController, copyLinkButtonController, dateFieldController, downLoadBinaryController, downloadFileController, durationController, floatController, floatTimeFiledController, many2manyFieldController, many2manyTagsController, many2oneButtonController, many2oneFieldController, priorityFieldController, searchController, statusDropdownController, tableBodyController, tableController, tableGroupController, tableHeadController };
|
package/dist/widget.js
CHANGED
|
@@ -6167,6 +6167,7 @@ var tableGroupController = (props) => {
|
|
|
6167
6167
|
// src/widget/advance/search/controller.ts
|
|
6168
6168
|
var import_constants3 = require("@fctc/interface-logic/constants");
|
|
6169
6169
|
var import_utils6 = require("@fctc/interface-logic/utils");
|
|
6170
|
+
var import_moment = __toESM(require_moment());
|
|
6170
6171
|
var import_react18 = require("react");
|
|
6171
6172
|
var searchController = ({
|
|
6172
6173
|
viewData,
|
|
@@ -6264,6 +6265,52 @@ var searchController = ({
|
|
|
6264
6265
|
const addSearchItems = (key, newItem) => {
|
|
6265
6266
|
updateSearchMap({ key, item: newItem });
|
|
6266
6267
|
};
|
|
6268
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : (0, import_utils6.evalJSONDomain)(actionData?.domain, contextSearch) : [];
|
|
6269
|
+
const formatDomain = () => {
|
|
6270
|
+
if (domainAction) {
|
|
6271
|
+
const domain = [];
|
|
6272
|
+
if (domainAction?.length > 0) {
|
|
6273
|
+
if (Object.keys(searchMap).length > 0) {
|
|
6274
|
+
domain.push("&");
|
|
6275
|
+
}
|
|
6276
|
+
domainAction.forEach((domainItem) => {
|
|
6277
|
+
domain.push(domainItem);
|
|
6278
|
+
});
|
|
6279
|
+
}
|
|
6280
|
+
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
6281
|
+
if (!key?.includes(import_constants3.SearchType.GROUP)) {
|
|
6282
|
+
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
6283
|
+
domain.push("&");
|
|
6284
|
+
}
|
|
6285
|
+
const valuesOfKey = searchMap[key];
|
|
6286
|
+
valuesOfKey.forEach((value, index) => {
|
|
6287
|
+
if (index < valuesOfKey.length - 1) {
|
|
6288
|
+
domain.push("|");
|
|
6289
|
+
}
|
|
6290
|
+
if (value.domain) {
|
|
6291
|
+
domain.push(...value.domain);
|
|
6292
|
+
return;
|
|
6293
|
+
}
|
|
6294
|
+
let valueDomainItem = value?.value;
|
|
6295
|
+
if (value?.modelType === "date") {
|
|
6296
|
+
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value);
|
|
6297
|
+
} else if (value?.modelType === "datetime") {
|
|
6298
|
+
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6299
|
+
const parsedDate = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6300
|
+
const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6301
|
+
valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
6302
|
+
} else {
|
|
6303
|
+
valueDomainItem = (0, import_utils6.validateAndParseDate)(value?.value, true);
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
6307
|
+
domain.push([value.name, operator, valueDomainItem]);
|
|
6308
|
+
});
|
|
6309
|
+
}
|
|
6310
|
+
});
|
|
6311
|
+
return [...domain];
|
|
6312
|
+
}
|
|
6313
|
+
};
|
|
6267
6314
|
const setTagSearch = (0, import_react18.useCallback)(
|
|
6268
6315
|
(updatedMap) => {
|
|
6269
6316
|
if (!updatedMap) return;
|
|
@@ -6379,7 +6426,8 @@ var searchController = ({
|
|
|
6379
6426
|
setSelectedTags,
|
|
6380
6427
|
removeSearchItems,
|
|
6381
6428
|
onSearchString: onChangeSearchInput,
|
|
6382
|
-
handleAddTagSearch
|
|
6429
|
+
handleAddTagSearch,
|
|
6430
|
+
domain: formatDomain()
|
|
6383
6431
|
};
|
|
6384
6432
|
};
|
|
6385
6433
|
|
|
@@ -7010,7 +7058,7 @@ var downLoadBinaryController = (props) => {
|
|
|
7010
7058
|
};
|
|
7011
7059
|
|
|
7012
7060
|
// src/widget/basic/date-field/controller.ts
|
|
7013
|
-
var
|
|
7061
|
+
var import_moment2 = __toESM(require_moment());
|
|
7014
7062
|
var DURATIONS = {
|
|
7015
7063
|
PAST: "past",
|
|
7016
7064
|
NOW: "now",
|
|
@@ -7037,8 +7085,8 @@ var dateFieldController = (props) => {
|
|
|
7037
7085
|
const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
|
|
7038
7086
|
const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
7039
7087
|
const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
|
|
7040
|
-
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0,
|
|
7041
|
-
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0,
|
|
7088
|
+
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment2.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
|
|
7089
|
+
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment2.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
|
|
7042
7090
|
const years = range(
|
|
7043
7091
|
minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
|
|
7044
7092
|
(/* @__PURE__ */ new Date()).getFullYear() + 4,
|
|
@@ -7073,8 +7121,8 @@ var dateFieldController = (props) => {
|
|
|
7073
7121
|
"December"
|
|
7074
7122
|
];
|
|
7075
7123
|
const customValidateMinMax = (date) => {
|
|
7076
|
-
const selected = (0,
|
|
7077
|
-
const now = (0,
|
|
7124
|
+
const selected = (0, import_moment2.default)(date, formatDateParse);
|
|
7125
|
+
const now = (0, import_moment2.default)();
|
|
7078
7126
|
const compareSelected = showTime ? selected : selected.clone().startOf("day");
|
|
7079
7127
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
7080
7128
|
if (minNowValue) {
|
|
@@ -7082,7 +7130,7 @@ var dateFieldController = (props) => {
|
|
|
7082
7130
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7083
7131
|
"greater_or_equal_now"
|
|
7084
7132
|
)}`;
|
|
7085
|
-
} else if (
|
|
7133
|
+
} else if (import_moment2.default.isMoment(minNowValue)) {
|
|
7086
7134
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
7087
7135
|
if (compareSelected.isBefore(compareMin)) {
|
|
7088
7136
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
@@ -7096,7 +7144,7 @@ var dateFieldController = (props) => {
|
|
|
7096
7144
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7097
7145
|
"less_or_equal_now"
|
|
7098
7146
|
)}`;
|
|
7099
|
-
} else if (
|
|
7147
|
+
} else if (import_moment2.default.isMoment(maxNowValue)) {
|
|
7100
7148
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
7101
7149
|
if (compareSelected.isAfter(compareMax)) {
|
|
7102
7150
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|
package/dist/widget.mjs
CHANGED
|
@@ -6191,8 +6191,13 @@ var tableGroupController = (props) => {
|
|
|
6191
6191
|
};
|
|
6192
6192
|
|
|
6193
6193
|
// src/widget/advance/search/controller.ts
|
|
6194
|
+
var import_moment = __toESM(require_moment());
|
|
6194
6195
|
import { SearchType } from "@fctc/interface-logic/constants";
|
|
6195
|
-
import {
|
|
6196
|
+
import {
|
|
6197
|
+
domainHelper as domainHelper2,
|
|
6198
|
+
evalJSONDomain as evalJSONDomain4,
|
|
6199
|
+
validateAndParseDate
|
|
6200
|
+
} from "@fctc/interface-logic/utils";
|
|
6196
6201
|
import { useCallback as useCallback3, useEffect as useEffect14, useState as useState10 } from "react";
|
|
6197
6202
|
var searchController = ({
|
|
6198
6203
|
viewData,
|
|
@@ -6290,6 +6295,52 @@ var searchController = ({
|
|
|
6290
6295
|
const addSearchItems = (key, newItem) => {
|
|
6291
6296
|
updateSearchMap({ key, item: newItem });
|
|
6292
6297
|
};
|
|
6298
|
+
const domainAction = actionData?.domain ? Array.isArray(actionData?.domain) ? [...actionData?.domain] : evalJSONDomain4(actionData?.domain, contextSearch) : [];
|
|
6299
|
+
const formatDomain = () => {
|
|
6300
|
+
if (domainAction) {
|
|
6301
|
+
const domain = [];
|
|
6302
|
+
if (domainAction?.length > 0) {
|
|
6303
|
+
if (Object.keys(searchMap).length > 0) {
|
|
6304
|
+
domain.push("&");
|
|
6305
|
+
}
|
|
6306
|
+
domainAction.forEach((domainItem) => {
|
|
6307
|
+
domain.push(domainItem);
|
|
6308
|
+
});
|
|
6309
|
+
}
|
|
6310
|
+
Object.keys(searchMap).forEach((key, keyIndex, keys) => {
|
|
6311
|
+
if (!key?.includes(SearchType.GROUP)) {
|
|
6312
|
+
if (keys.length > 1 && keyIndex < keys.length - 1) {
|
|
6313
|
+
domain.push("&");
|
|
6314
|
+
}
|
|
6315
|
+
const valuesOfKey = searchMap[key];
|
|
6316
|
+
valuesOfKey.forEach((value, index) => {
|
|
6317
|
+
if (index < valuesOfKey.length - 1) {
|
|
6318
|
+
domain.push("|");
|
|
6319
|
+
}
|
|
6320
|
+
if (value.domain) {
|
|
6321
|
+
domain.push(...value.domain);
|
|
6322
|
+
return;
|
|
6323
|
+
}
|
|
6324
|
+
let valueDomainItem = value?.value;
|
|
6325
|
+
if (value?.modelType === "date") {
|
|
6326
|
+
valueDomainItem = validateAndParseDate(value?.value);
|
|
6327
|
+
} else if (value?.modelType === "datetime") {
|
|
6328
|
+
if (value?.operator === "<=" || value?.operator === "<") {
|
|
6329
|
+
const parsedDate = validateAndParseDate(value?.value, true);
|
|
6330
|
+
const hasTime = (0, import_moment.default)(value?.value).format("HH:mm:ss") !== "00:00:00";
|
|
6331
|
+
valueDomainItem = hasTime ? (0, import_moment.default)(parsedDate).format("YYYY-MM-DD HH:mm:ss") : (0, import_moment.default)(parsedDate).add(1, "day").subtract(1, "second").format("YYYY-MM-DD HH:mm:ss");
|
|
6332
|
+
} else {
|
|
6333
|
+
valueDomainItem = validateAndParseDate(value?.value, true);
|
|
6334
|
+
}
|
|
6335
|
+
}
|
|
6336
|
+
const operator = value?.modelType === "date" || value?.modelType === "datetime" || value?.modelType === "boolean" || value?.modelType === "integer" ? value?.operator ?? "=" : value.operator ?? "ilike";
|
|
6337
|
+
domain.push([value.name, operator, valueDomainItem]);
|
|
6338
|
+
});
|
|
6339
|
+
}
|
|
6340
|
+
});
|
|
6341
|
+
return [...domain];
|
|
6342
|
+
}
|
|
6343
|
+
};
|
|
6293
6344
|
const setTagSearch = useCallback3(
|
|
6294
6345
|
(updatedMap) => {
|
|
6295
6346
|
if (!updatedMap) return;
|
|
@@ -6405,7 +6456,8 @@ var searchController = ({
|
|
|
6405
6456
|
setSelectedTags,
|
|
6406
6457
|
removeSearchItems,
|
|
6407
6458
|
onSearchString: onChangeSearchInput,
|
|
6408
|
-
handleAddTagSearch
|
|
6459
|
+
handleAddTagSearch,
|
|
6460
|
+
domain: formatDomain()
|
|
6409
6461
|
};
|
|
6410
6462
|
};
|
|
6411
6463
|
|
|
@@ -6598,7 +6650,7 @@ import { useMemo as useMemo14 } from "react";
|
|
|
6598
6650
|
import { WIDGETAVATAR, WIDGETCOLOR } from "@fctc/interface-logic/constants";
|
|
6599
6651
|
import { getEnv as getEnv9 } from "@fctc/interface-logic/environment";
|
|
6600
6652
|
import { useGetSelection as useGetSelection3 } from "@fctc/interface-logic/hooks";
|
|
6601
|
-
import { evalJSONContext as evalJSONContext5, evalJSONDomain as
|
|
6653
|
+
import { evalJSONContext as evalJSONContext5, evalJSONDomain as evalJSONDomain5 } from "@fctc/interface-logic/utils";
|
|
6602
6654
|
var many2manyTagsController = (props) => {
|
|
6603
6655
|
const {
|
|
6604
6656
|
relation,
|
|
@@ -6612,7 +6664,7 @@ var many2manyTagsController = (props) => {
|
|
|
6612
6664
|
const env = getEnv9();
|
|
6613
6665
|
const addtionalFields = optionsFields ? evalJSONContext5(optionsFields) : null;
|
|
6614
6666
|
const domainObject = useMemo14(
|
|
6615
|
-
() =>
|
|
6667
|
+
() => evalJSONDomain5(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
6616
6668
|
[domain, formValues]
|
|
6617
6669
|
);
|
|
6618
6670
|
const data = {
|
|
@@ -6657,7 +6709,7 @@ var many2manyTagsController = (props) => {
|
|
|
6657
6709
|
import { useState as useState12 } from "react";
|
|
6658
6710
|
import { useGetListData as useGetListData4, useChangeStatus } from "@fctc/interface-logic/hooks";
|
|
6659
6711
|
import { useAppSelector as useAppSelector8, selectEnv as selectEnv2 } from "@fctc/interface-logic/store";
|
|
6660
|
-
import { evalJSONDomain as
|
|
6712
|
+
import { evalJSONDomain as evalJSONDomain6 } from "@fctc/interface-logic/utils";
|
|
6661
6713
|
var durationController = (props) => {
|
|
6662
6714
|
const {
|
|
6663
6715
|
relation,
|
|
@@ -6681,7 +6733,7 @@ var durationController = (props) => {
|
|
|
6681
6733
|
const listDataProps = {
|
|
6682
6734
|
model: relation,
|
|
6683
6735
|
specification,
|
|
6684
|
-
domain:
|
|
6736
|
+
domain: evalJSONDomain6(domain, JSON.parse(JSON.stringify(formValues))),
|
|
6685
6737
|
limit: 10,
|
|
6686
6738
|
offset: 0,
|
|
6687
6739
|
fields: "",
|
|
@@ -7050,7 +7102,7 @@ var downLoadBinaryController = (props) => {
|
|
|
7050
7102
|
};
|
|
7051
7103
|
|
|
7052
7104
|
// src/widget/basic/date-field/controller.ts
|
|
7053
|
-
var
|
|
7105
|
+
var import_moment2 = __toESM(require_moment());
|
|
7054
7106
|
var DURATIONS = {
|
|
7055
7107
|
PAST: "past",
|
|
7056
7108
|
NOW: "now",
|
|
@@ -7077,8 +7129,8 @@ var dateFieldController = (props) => {
|
|
|
7077
7129
|
const formatDate = showTime ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY";
|
|
7078
7130
|
const formatDateParse = showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
7079
7131
|
const fieldForCustom = widget === "datetime_custom" || widget === "date_custom";
|
|
7080
|
-
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0,
|
|
7081
|
-
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0,
|
|
7132
|
+
const minNowValue = fieldForCustom && (min === DURATIONS.NOW ? true : typeof min === "string" && Object.keys(formValues)?.includes(min) && formValues?.[min] ? (0, import_moment2.default)(formValues?.[min], formatDateParse).add(7, "hours") : null);
|
|
7133
|
+
const maxNowValue = fieldForCustom && (max === DURATIONS.NOW ? true : typeof max === "string" && Object.keys(formValues)?.includes(max) && formValues?.[max] ? (0, import_moment2.default)(formValues?.[max], formatDateParse).add(7, "hours") : null);
|
|
7082
7134
|
const years = range(
|
|
7083
7135
|
minNowValue ? (/* @__PURE__ */ new Date()).getFullYear() : 1990,
|
|
7084
7136
|
(/* @__PURE__ */ new Date()).getFullYear() + 4,
|
|
@@ -7113,8 +7165,8 @@ var dateFieldController = (props) => {
|
|
|
7113
7165
|
"December"
|
|
7114
7166
|
];
|
|
7115
7167
|
const customValidateMinMax = (date) => {
|
|
7116
|
-
const selected = (0,
|
|
7117
|
-
const now = (0,
|
|
7168
|
+
const selected = (0, import_moment2.default)(date, formatDateParse);
|
|
7169
|
+
const now = (0, import_moment2.default)();
|
|
7118
7170
|
const compareSelected = showTime ? selected : selected.clone().startOf("day");
|
|
7119
7171
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
7120
7172
|
if (minNowValue) {
|
|
@@ -7122,7 +7174,7 @@ var dateFieldController = (props) => {
|
|
|
7122
7174
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7123
7175
|
"greater_or_equal_now"
|
|
7124
7176
|
)}`;
|
|
7125
|
-
} else if (
|
|
7177
|
+
} else if (import_moment2.default.isMoment(minNowValue)) {
|
|
7126
7178
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
7127
7179
|
if (compareSelected.isBefore(compareMin)) {
|
|
7128
7180
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
@@ -7136,7 +7188,7 @@ var dateFieldController = (props) => {
|
|
|
7136
7188
|
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
7137
7189
|
"less_or_equal_now"
|
|
7138
7190
|
)}`;
|
|
7139
|
-
} else if (
|
|
7191
|
+
} else if (import_moment2.default.isMoment(maxNowValue)) {
|
|
7140
7192
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
7141
7193
|
if (compareSelected.isAfter(compareMax)) {
|
|
7142
7194
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|