datastake-daf 0.6.261 → 0.6.262
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/.env +8 -0
- package/.vscode/settings.json +13 -0
- package/dist/components/index.js +43 -43
- package/dist/utils/index.js +34 -34
- package/package.json +1 -1
- package/src/@daf/core/components/EditForm/storyConfig1.js +155 -249
- package/src/@daf/core/components/EditForm/storyConfig2.js +127 -21
- package/src/helpers/Forms.js +522 -443
package/.env
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": ["cukura"],
|
|
3
|
+
"files.autoSave": "afterDelay",
|
|
4
|
+
"editor.wordWrap": "on",
|
|
5
|
+
"editor.autoClosingBrackets": "always",
|
|
6
|
+
"editor.autoClosingComments": "always",
|
|
7
|
+
"editor.autoClosingQuotes": "always",
|
|
8
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
9
|
+
"editor.formatOnPaste": true,
|
|
10
|
+
"editor.formatOnSave": true,
|
|
11
|
+
"notebook.defaultFormatter": "esbenp.prettier-vscode",
|
|
12
|
+
"javascript.format.semicolons": "insert"
|
|
13
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -9451,36 +9451,36 @@ function _checkValue$1(wantedValue, match, fieldValue) {
|
|
|
9451
9451
|
if (!match) {
|
|
9452
9452
|
return propHasValue$1(fieldValue) || Array.isArray(fieldValue) && fieldValue.length > 0 ? true : false;
|
|
9453
9453
|
} else {
|
|
9454
|
-
const values = wantedValue.split(
|
|
9455
|
-
if (match ===
|
|
9454
|
+
const values = wantedValue.split(",");
|
|
9455
|
+
if (match === "is") {
|
|
9456
9456
|
if (values.length === 1) {
|
|
9457
9457
|
return Array.isArray(fieldValue) ? fieldValue.includes(values[0]) : String(fieldValue) === values[0];
|
|
9458
9458
|
} else {
|
|
9459
9459
|
return false;
|
|
9460
9460
|
}
|
|
9461
9461
|
}
|
|
9462
|
-
if (match ===
|
|
9462
|
+
if (match === "includes") {
|
|
9463
9463
|
if (values.length) {
|
|
9464
9464
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length > 0 : values.includes(String(fieldValue));
|
|
9465
9465
|
} else {
|
|
9466
9466
|
return false;
|
|
9467
9467
|
}
|
|
9468
9468
|
}
|
|
9469
|
-
if (match ===
|
|
9469
|
+
if (match === "not") {
|
|
9470
9470
|
if (values.length && propHasValue$1(fieldValue)) {
|
|
9471
9471
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
9472
9472
|
} else {
|
|
9473
9473
|
return false;
|
|
9474
9474
|
}
|
|
9475
9475
|
}
|
|
9476
|
-
if (match ===
|
|
9476
|
+
if (match === "notOnly") {
|
|
9477
9477
|
if (values.length) {
|
|
9478
9478
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
9479
9479
|
} else {
|
|
9480
9480
|
return false;
|
|
9481
9481
|
}
|
|
9482
9482
|
}
|
|
9483
|
-
if (match ===
|
|
9483
|
+
if (match === "notEmpty") {
|
|
9484
9484
|
return fieldValue && Object.keys(fieldValue).includes(wantedValue) && (!Array.isArray(fieldValue[wantedValue]) || Array.isArray(fieldValue[wantedValue]) && fieldValue[wantedValue].length > 0);
|
|
9485
9485
|
}
|
|
9486
9486
|
}
|
|
@@ -9500,7 +9500,7 @@ function _checkValue$1(wantedValue, match, fieldValue) {
|
|
|
9500
9500
|
*/
|
|
9501
9501
|
function showHideInput$4(input, data, repeatIndex, repeatValues) {
|
|
9502
9502
|
var _input$meta, _data$meta;
|
|
9503
|
-
if (typeof (input === null || input === void 0 || (_input$meta = input.meta) === null || _input$meta === void 0 ? void 0 : _input$meta.excludeFromEdit) ===
|
|
9503
|
+
if (typeof (input === null || input === void 0 || (_input$meta = input.meta) === null || _input$meta === void 0 ? void 0 : _input$meta.excludeFromEdit) === "boolean") {
|
|
9504
9504
|
var _input$meta2;
|
|
9505
9505
|
return !(input !== null && input !== void 0 && (_input$meta2 = input.meta) !== null && _input$meta2 !== void 0 && _input$meta2.excludeFromEdit);
|
|
9506
9506
|
}
|
|
@@ -9514,16 +9514,16 @@ function showHideInput$4(input, data, repeatIndex, repeatValues) {
|
|
|
9514
9514
|
}
|
|
9515
9515
|
});
|
|
9516
9516
|
if (input.showIf) {
|
|
9517
|
-
const isOrCond = input.showIf.indexOf(
|
|
9518
|
-
const allParts = input.showIf.split(/( OR | && )/
|
|
9517
|
+
const isOrCond = input.showIf.indexOf("OR") >= 0;
|
|
9518
|
+
const allParts = input.showIf.split(/( OR | && )/gim).filter(c => !["OR", "&&"].includes(c.trim()));
|
|
9519
9519
|
const parts = allParts.map(condition => {
|
|
9520
|
-
let [field, match, wantedValue] = condition.split(/( is | includes | not | notEmpty | notOnly | gte | gt | lte | lt )/
|
|
9520
|
+
let [field, match, wantedValue] = condition.split(/( is | includes | not | notEmpty | notOnly | gte | gt | lte | lt )/gim);
|
|
9521
9521
|
match = match ? match.trim() : null;
|
|
9522
|
-
const isRepeatable = field.split(
|
|
9523
|
-
const isNotEmpty = match ===
|
|
9522
|
+
const isRepeatable = field.split("./").length > 1;
|
|
9523
|
+
const isNotEmpty = match === "notEmpty";
|
|
9524
9524
|
const formValue = isRepeatable ? repeatValues : formsValue;
|
|
9525
|
-
field = isRepeatable ? field.split(
|
|
9526
|
-
if (match && field.split(
|
|
9525
|
+
field = isRepeatable ? field.split("./")[1] : field;
|
|
9526
|
+
if (match && field.split(".").length > 1) {
|
|
9527
9527
|
if (input.inputs) {
|
|
9528
9528
|
const value = deepFind(formValue, field);
|
|
9529
9529
|
const isShown = _checkValue$1(isNotEmpty ? field : wantedValue, match, isNotEmpty ? formValue : value);
|
|
@@ -9539,16 +9539,16 @@ function showHideInput$4(input, data, repeatIndex, repeatValues) {
|
|
|
9539
9539
|
}
|
|
9540
9540
|
} else {
|
|
9541
9541
|
const value = deepFind(formValue, field);
|
|
9542
|
-
if (match ===
|
|
9542
|
+
if (match === "gte") {
|
|
9543
9543
|
return Number(formValue[field]) >= Number(wantedValue);
|
|
9544
9544
|
}
|
|
9545
|
-
if (match ===
|
|
9545
|
+
if (match === "gt") {
|
|
9546
9546
|
return Number(formValue[field]) > Number(wantedValue);
|
|
9547
9547
|
}
|
|
9548
|
-
if (match ===
|
|
9548
|
+
if (match === "lte") {
|
|
9549
9549
|
return Number(formValue[field]) <= Number(wantedValue);
|
|
9550
9550
|
}
|
|
9551
|
-
if (match ===
|
|
9551
|
+
if (match === "lt") {
|
|
9552
9552
|
return Number(formValue[field]) < Number(wantedValue);
|
|
9553
9553
|
}
|
|
9554
9554
|
const isShown = _checkValue$1(isNotEmpty ? field : wantedValue, match, isNotEmpty ? formValue : value);
|
|
@@ -9578,8 +9578,8 @@ function showHideInput$4(input, data, repeatIndex, repeatValues) {
|
|
|
9578
9578
|
* filterString('h ll ', 'll') // true
|
|
9579
9579
|
*/
|
|
9580
9580
|
const filterString = (str1, str2) => {
|
|
9581
|
-
str1 = typeof str1 ===
|
|
9582
|
-
str2 = typeof str2 ===
|
|
9581
|
+
str1 = typeof str1 === "string" ? str1.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
9582
|
+
str2 = typeof str2 === "string" ? str2.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
9583
9583
|
return str1.toLowerCase().indexOf(str2.toLowerCase()) >= 0;
|
|
9584
9584
|
};
|
|
9585
9585
|
|
|
@@ -9597,7 +9597,7 @@ const filterString = (str1, str2) => {
|
|
|
9597
9597
|
* filterSelectOptions('hello', { label: 'goodbye world' }) // false
|
|
9598
9598
|
*/
|
|
9599
9599
|
const filterSelectOptions = (inputValue, option) => {
|
|
9600
|
-
return filterString(typeof option.children ===
|
|
9600
|
+
return filterString(typeof option.children === "string" ? option.children : typeof option.label === "string" ? option.label : "", inputValue);
|
|
9601
9601
|
};
|
|
9602
9602
|
|
|
9603
9603
|
/**
|
|
@@ -9611,7 +9611,7 @@ const filterSelectOptions = (inputValue, option) => {
|
|
|
9611
9611
|
const createYearArray = i => {
|
|
9612
9612
|
const years = [];
|
|
9613
9613
|
for (let j = 0; j < i; j++) {
|
|
9614
|
-
years.push(moment__default["default"]().add(j * -1,
|
|
9614
|
+
years.push(moment__default["default"]().add(j * -1, "years").format("YYYY"));
|
|
9615
9615
|
}
|
|
9616
9616
|
return years;
|
|
9617
9617
|
};
|
|
@@ -9631,10 +9631,10 @@ const createNumberArray = i => {
|
|
|
9631
9631
|
}
|
|
9632
9632
|
return numbers;
|
|
9633
9633
|
};
|
|
9634
|
-
const tooltipInputs = [
|
|
9634
|
+
const tooltipInputs = ["text", "phoneNumber", "textarea", "percentage", "number", "select", "ajaxSelect", "switch", "multiselect", "radioGroup", "date", "year"];
|
|
9635
9635
|
const formPaths = {
|
|
9636
|
-
edit: (mod, getRedirectLink) => typeof getRedirectLink ===
|
|
9637
|
-
view: (mod, getRedirectLink) => typeof getRedirectLink ===
|
|
9636
|
+
edit: (mod, getRedirectLink) => typeof getRedirectLink === "function" ? getRedirectLink("/app/edit/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?") : "/app/".concat(mod, "/edit/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?"),
|
|
9637
|
+
view: (mod, getRedirectLink) => typeof getRedirectLink === "function" ? getRedirectLink("/app/view/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?") : "/app/".concat(mod, "/view/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?"),
|
|
9638
9638
|
viewDD: mod => "/app/".concat(mod, "/viewdd/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?"),
|
|
9639
9639
|
editDD: mod => "/app/".concat(mod, "/editdd/:namespace/:id/:group?/:subsection?/:subgroup?/:formid?")
|
|
9640
9640
|
};
|
|
@@ -9646,18 +9646,18 @@ const MAX_TEXT_INPUT_LENGTH = 60;
|
|
|
9646
9646
|
/************* ✨ Codeium Command ⭐ *************/
|
|
9647
9647
|
/**
|
|
9648
9648
|
* Returns a translated placeholder message based on the input metadata.
|
|
9649
|
-
*
|
|
9649
|
+
*
|
|
9650
9650
|
* @param {Object} inputMeta - Metadata about the input.
|
|
9651
9651
|
* @param {Function} t - Translation function.
|
|
9652
9652
|
* @returns {string|undefined} - Translated string indicating the input is not applicable or no information is available, or undefined if neither condition is met.
|
|
9653
9653
|
*/
|
|
9654
9654
|
|
|
9655
9655
|
/****** 8ec9ef5f-b701-4986-bbd5-34fbf3fbc2fb *******/
|
|
9656
|
-
const getMetaPlaceholer = (inputMeta, t) => inputMeta.notApplicable ? t(
|
|
9656
|
+
const getMetaPlaceholer = (inputMeta, t) => inputMeta.notApplicable ? t("Not applicable") : inputMeta.notAvailable ? t("No available information") : undefined;
|
|
9657
9657
|
|
|
9658
9658
|
/**
|
|
9659
9659
|
* Filters select options based on the given filters. Used in filterOptions of ant select
|
|
9660
|
-
*
|
|
9660
|
+
*
|
|
9661
9661
|
* @param {Object[]} options - Options to filter.
|
|
9662
9662
|
* @param {string[]} filters - Filters to apply.
|
|
9663
9663
|
* @param {Object} [formsValue={}] - Form values.
|
|
@@ -9669,17 +9669,17 @@ function filterOptions$2(options, filters) {
|
|
|
9669
9669
|
let formsValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9670
9670
|
let repeatValues = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
9671
9671
|
let filterCond = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
9672
|
-
const isOrCond = filterCond !==
|
|
9672
|
+
const isOrCond = filterCond !== "and";
|
|
9673
9673
|
const objFilter = {};
|
|
9674
9674
|
filters.forEach(f => {
|
|
9675
|
-
const [name, p] = f.split(
|
|
9676
|
-
const [path, delimeter] = p.split(/( as )/
|
|
9675
|
+
const [name, p] = f.split("|");
|
|
9676
|
+
const [path, delimeter] = p.split(/( as )/gim);
|
|
9677
9677
|
let value;
|
|
9678
9678
|
let isRepeatable = false;
|
|
9679
|
-
if (delimeter && delimeter.trim() ===
|
|
9679
|
+
if (delimeter && delimeter.trim() === "as") {
|
|
9680
9680
|
value = path;
|
|
9681
9681
|
} else {
|
|
9682
|
-
const pathInsideRepeatValues = path.split(
|
|
9682
|
+
const pathInsideRepeatValues = path.split("./");
|
|
9683
9683
|
isRepeatable = pathInsideRepeatValues.length > 1;
|
|
9684
9684
|
value = deepFind(isRepeatable ? repeatValues : formsValue, pathInsideRepeatValues[pathInsideRepeatValues.length - 1]);
|
|
9685
9685
|
}
|
|
@@ -9699,7 +9699,7 @@ function filterOptions$2(options, filters) {
|
|
|
9699
9699
|
const parts = opFilters.map(fi => {
|
|
9700
9700
|
const filter = objFilter[fi.name];
|
|
9701
9701
|
const value = Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
9702
|
-
return _checkValue$1(value.join(
|
|
9702
|
+
return _checkValue$1(value.join(","), fi.condition, fi.value);
|
|
9703
9703
|
});
|
|
9704
9704
|
return parts.length > 0 && (isOrCond && parts.filter(p => p).length >= 1 || parts.filter(p => !p).length === 0);
|
|
9705
9705
|
// if (!filter) {
|
|
@@ -9744,7 +9744,7 @@ function filterOptions$2(options, filters) {
|
|
|
9744
9744
|
* const normalizedValue = getImageUploadEditValue(value); // ['http://example.com/image1.jpg', 'http://example.com/image2.jpg']
|
|
9745
9745
|
*/
|
|
9746
9746
|
const getImageUploadEditValue = value => {
|
|
9747
|
-
return (Array.isArray(value) ? value : value && typeof value ===
|
|
9747
|
+
return (Array.isArray(value) ? value : value && typeof value === "object" && value.fileList && Array.isArray(value.fileList) ? value.fileList.map(f => f.response).filter(f => f) : []) || [];
|
|
9748
9748
|
};
|
|
9749
9749
|
|
|
9750
9750
|
/**
|
|
@@ -9756,7 +9756,7 @@ const getImageUploadEditValue = value => {
|
|
|
9756
9756
|
*/
|
|
9757
9757
|
|
|
9758
9758
|
const getLabel$1 = (label, allData) => {
|
|
9759
|
-
if (label && typeof label ===
|
|
9759
|
+
if (label && typeof label === "object") {
|
|
9760
9760
|
let toReturn = label;
|
|
9761
9761
|
Object.keys(label).forEach(k => {
|
|
9762
9762
|
const show = showHideInput$4({
|
|
@@ -9770,9 +9770,9 @@ const getLabel$1 = (label, allData) => {
|
|
|
9770
9770
|
}
|
|
9771
9771
|
return label;
|
|
9772
9772
|
};
|
|
9773
|
-
const noActionsInputs = [
|
|
9773
|
+
const noActionsInputs = ["groupExpandable", "groupCheckbox", "smartHelp"];
|
|
9774
9774
|
const isObjectEmpty = obj => {
|
|
9775
|
-
if (obj === null || typeof obj !==
|
|
9775
|
+
if (obj === null || typeof obj !== "object") {
|
|
9776
9776
|
return false;
|
|
9777
9777
|
}
|
|
9778
9778
|
if (Object.keys(obj).length === 0) {
|
|
@@ -9818,9 +9818,9 @@ const filterCreateData = data => {
|
|
|
9818
9818
|
*/
|
|
9819
9819
|
|
|
9820
9820
|
const renderDateFormatted = function (value) {
|
|
9821
|
-
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
9822
|
-
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
9823
|
-
return dayjs__default["default"].utc(value,
|
|
9821
|
+
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "DD MMM YYYY";
|
|
9822
|
+
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "en";
|
|
9823
|
+
return dayjs__default["default"].utc(value, "YYYY-MM-DD").locale(locale).format(format);
|
|
9824
9824
|
};
|
|
9825
9825
|
/**
|
|
9826
9826
|
* Sorts a form object by its inputs' positions.
|
|
@@ -9834,7 +9834,7 @@ const sortForm = _ref4 => {
|
|
|
9834
9834
|
} = _ref4;
|
|
9835
9835
|
const _form = Object.keys(form).reduce((all, key) => {
|
|
9836
9836
|
const _this = Object.keys(form[key]).sort((a, b) => form[key][a].position - form[key][b].position).reduce((all, k) => {
|
|
9837
|
-
if (k ===
|
|
9837
|
+
if (k === "scope") {
|
|
9838
9838
|
return all;
|
|
9839
9839
|
}
|
|
9840
9840
|
all[k] = form[key][k];
|
|
@@ -9861,7 +9861,7 @@ const sortForm = _ref4 => {
|
|
|
9861
9861
|
*/
|
|
9862
9862
|
|
|
9863
9863
|
const getLabelFromScopeForDataLink = (labelObj, formScope) => {
|
|
9864
|
-
if (typeof labelObj !==
|
|
9864
|
+
if (typeof labelObj !== "object" || !formScope) return labelObj;
|
|
9865
9865
|
const matchKey = Object.keys(labelObj).find(k => k.includes("scope is ".concat(formScope)));
|
|
9866
9866
|
if (matchKey) return labelObj[matchKey];
|
|
9867
9867
|
const fallbackKey = Object.keys(labelObj).find(k => k.startsWith("scope not"));
|
package/dist/utils/index.js
CHANGED
|
@@ -4007,36 +4007,36 @@ function _checkValue(wantedValue, match, fieldValue) {
|
|
|
4007
4007
|
if (!match) {
|
|
4008
4008
|
return propHasValue(fieldValue) || Array.isArray(fieldValue) && fieldValue.length > 0 ? true : false;
|
|
4009
4009
|
} else {
|
|
4010
|
-
const values = wantedValue.split(
|
|
4011
|
-
if (match ===
|
|
4010
|
+
const values = wantedValue.split(",");
|
|
4011
|
+
if (match === "is") {
|
|
4012
4012
|
if (values.length === 1) {
|
|
4013
4013
|
return Array.isArray(fieldValue) ? fieldValue.includes(values[0]) : String(fieldValue) === values[0];
|
|
4014
4014
|
} else {
|
|
4015
4015
|
return false;
|
|
4016
4016
|
}
|
|
4017
4017
|
}
|
|
4018
|
-
if (match ===
|
|
4018
|
+
if (match === "includes") {
|
|
4019
4019
|
if (values.length) {
|
|
4020
4020
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length > 0 : values.includes(String(fieldValue));
|
|
4021
4021
|
} else {
|
|
4022
4022
|
return false;
|
|
4023
4023
|
}
|
|
4024
4024
|
}
|
|
4025
|
-
if (match ===
|
|
4025
|
+
if (match === "not") {
|
|
4026
4026
|
if (values.length && propHasValue(fieldValue)) {
|
|
4027
4027
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
4028
4028
|
} else {
|
|
4029
4029
|
return false;
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
|
-
if (match ===
|
|
4032
|
+
if (match === "notOnly") {
|
|
4033
4033
|
if (values.length) {
|
|
4034
4034
|
return Array.isArray(fieldValue) ? values.filter(v => fieldValue.includes(v)).length === 0 : !values.includes(String(fieldValue));
|
|
4035
4035
|
} else {
|
|
4036
4036
|
return false;
|
|
4037
4037
|
}
|
|
4038
4038
|
}
|
|
4039
|
-
if (match ===
|
|
4039
|
+
if (match === "notEmpty") {
|
|
4040
4040
|
return fieldValue && Object.keys(fieldValue).includes(wantedValue) && (!Array.isArray(fieldValue[wantedValue]) || Array.isArray(fieldValue[wantedValue]) && fieldValue[wantedValue].length > 0);
|
|
4041
4041
|
}
|
|
4042
4042
|
}
|
|
@@ -4057,8 +4057,8 @@ function _checkValue(wantedValue, match, fieldValue) {
|
|
|
4057
4057
|
* filterString('h ll ', 'll') // true
|
|
4058
4058
|
*/
|
|
4059
4059
|
const filterString = (str1, str2) => {
|
|
4060
|
-
str1 = typeof str1 ===
|
|
4061
|
-
str2 = typeof str2 ===
|
|
4060
|
+
str1 = typeof str1 === "string" ? str1.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
4061
|
+
str2 = typeof str2 === "string" ? str2.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
|
|
4062
4062
|
return str1.toLowerCase().indexOf(str2.toLowerCase()) >= 0;
|
|
4063
4063
|
};
|
|
4064
4064
|
|
|
@@ -4076,12 +4076,12 @@ const filterString = (str1, str2) => {
|
|
|
4076
4076
|
* filterSelectOptions('hello', { label: 'goodbye world' }) // false
|
|
4077
4077
|
*/
|
|
4078
4078
|
const filterSelectOptions = (inputValue, option) => {
|
|
4079
|
-
return filterString(typeof option.children ===
|
|
4079
|
+
return filterString(typeof option.children === "string" ? option.children : typeof option.label === "string" ? option.label : "", inputValue);
|
|
4080
4080
|
};
|
|
4081
4081
|
|
|
4082
4082
|
/**
|
|
4083
4083
|
* Filters select options based on the given filters. Used in filterOptions of ant select
|
|
4084
|
-
*
|
|
4084
|
+
*
|
|
4085
4085
|
* @param {Object[]} options - Options to filter.
|
|
4086
4086
|
* @param {string[]} filters - Filters to apply.
|
|
4087
4087
|
* @param {Object} [formsValue={}] - Form values.
|
|
@@ -4090,17 +4090,17 @@ const filterSelectOptions = (inputValue, option) => {
|
|
|
4090
4090
|
* @returns {Object[]} - Filtered options.
|
|
4091
4091
|
*/
|
|
4092
4092
|
function filterOptions(options, filters, formsValue = {}, repeatValues = {}, filterCond = null) {
|
|
4093
|
-
const isOrCond = filterCond !==
|
|
4093
|
+
const isOrCond = filterCond !== "and";
|
|
4094
4094
|
const objFilter = {};
|
|
4095
4095
|
filters.forEach(f => {
|
|
4096
|
-
const [name, p] = f.split(
|
|
4097
|
-
const [path, delimeter] = p.split(/( as )/
|
|
4096
|
+
const [name, p] = f.split("|");
|
|
4097
|
+
const [path, delimeter] = p.split(/( as )/gim);
|
|
4098
4098
|
let value;
|
|
4099
4099
|
let isRepeatable = false;
|
|
4100
|
-
if (delimeter && delimeter.trim() ===
|
|
4100
|
+
if (delimeter && delimeter.trim() === "as") {
|
|
4101
4101
|
value = path;
|
|
4102
4102
|
} else {
|
|
4103
|
-
const pathInsideRepeatValues = path.split(
|
|
4103
|
+
const pathInsideRepeatValues = path.split("./");
|
|
4104
4104
|
isRepeatable = pathInsideRepeatValues.length > 1;
|
|
4105
4105
|
value = deepFind(isRepeatable ? repeatValues : formsValue, pathInsideRepeatValues[pathInsideRepeatValues.length - 1]);
|
|
4106
4106
|
}
|
|
@@ -4120,7 +4120,7 @@ function filterOptions(options, filters, formsValue = {}, repeatValues = {}, fil
|
|
|
4120
4120
|
const parts = opFilters.map(fi => {
|
|
4121
4121
|
const filter = objFilter[fi.name];
|
|
4122
4122
|
const value = Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
4123
|
-
return _checkValue(value.join(
|
|
4123
|
+
return _checkValue(value.join(","), fi.condition, fi.value);
|
|
4124
4124
|
});
|
|
4125
4125
|
return parts.length > 0 && (isOrCond && parts.filter(p => p).length >= 1 || parts.filter(p => !p).length === 0);
|
|
4126
4126
|
// if (!filter) {
|
|
@@ -4157,15 +4157,15 @@ function filterOptions(options, filters, formsValue = {}, repeatValues = {}, fil
|
|
|
4157
4157
|
* @param {Array} arr - The array to check.
|
|
4158
4158
|
* @returns {boolean} - True if the array contains only objects, false otherwise.
|
|
4159
4159
|
*/
|
|
4160
|
-
const isArrayOfObjects = arr => Array.isArray(arr) && arr.map(i => typeof i ===
|
|
4160
|
+
const isArrayOfObjects = arr => Array.isArray(arr) && arr.map(i => typeof i === "object").every(i => i);
|
|
4161
4161
|
|
|
4162
4162
|
/**
|
|
4163
4163
|
* Determines if two sets of data have not changed. Used to show Save button disabled or not.
|
|
4164
|
-
*
|
|
4164
|
+
*
|
|
4165
4165
|
* @param {Object} old - The original data set.
|
|
4166
4166
|
* @param {Object} newData - The new data set to compare against the original.
|
|
4167
4167
|
* @returns {boolean} - True if the data sets have not changed, false otherwise.
|
|
4168
|
-
*
|
|
4168
|
+
*
|
|
4169
4169
|
* This function compares two objects by iterating over the union of their keys.
|
|
4170
4170
|
* For each key, it checks the type of the value in newData:
|
|
4171
4171
|
* - If undefined, it considers it unchanged.
|
|
@@ -4181,13 +4181,13 @@ const hasNotChanged = (old, newData) => {
|
|
|
4181
4181
|
switch (typeof newData[key]) {
|
|
4182
4182
|
case undefined:
|
|
4183
4183
|
return true;
|
|
4184
|
-
case
|
|
4184
|
+
case "object":
|
|
4185
4185
|
try {
|
|
4186
4186
|
if (moment__default["default"].isMoment(newData[key])) {
|
|
4187
|
-
if (typeof newData[key].format ===
|
|
4188
|
-
return old[key] === newData[key].format(
|
|
4187
|
+
if (typeof newData[key].format === "function") {
|
|
4188
|
+
return old[key] === newData[key].format("YYYY-MM-DD");
|
|
4189
4189
|
}
|
|
4190
|
-
return old[key] === moment__default["default"](newData[key]._d).format(
|
|
4190
|
+
return old[key] === moment__default["default"](newData[key]._d).format("YYYY-MM-DD");
|
|
4191
4191
|
} else if (isArrayOfObjects(newData[key])) {
|
|
4192
4192
|
return newData[key].length === (old[key] || []).length && newData[key].map((oKey, i) => hasNotChanged((old[key] || [])[i] || {}, oKey || {})).every(i => i);
|
|
4193
4193
|
}
|
|
@@ -4195,9 +4195,9 @@ const hasNotChanged = (old, newData) => {
|
|
|
4195
4195
|
// console.log(e, data[key], key);
|
|
4196
4196
|
}
|
|
4197
4197
|
return ___default["default"].isEqual(old[key], newData[key]);
|
|
4198
|
-
case
|
|
4199
|
-
case
|
|
4200
|
-
case
|
|
4198
|
+
case "number":
|
|
4199
|
+
case "string":
|
|
4200
|
+
case "boolean":
|
|
4201
4201
|
return old[key] === newData[key];
|
|
4202
4202
|
default:
|
|
4203
4203
|
return false;
|
|
@@ -4207,14 +4207,14 @@ const hasNotChanged = (old, newData) => {
|
|
|
4207
4207
|
|
|
4208
4208
|
/**
|
|
4209
4209
|
* Maps sub groups in the form data structure for submission. This is mainly created for ajaxSubGroup input type.
|
|
4210
|
-
*
|
|
4210
|
+
*
|
|
4211
4211
|
* This function takes a form data structure and maps its sub groups to
|
|
4212
4212
|
* the format expected by the server. It does this by iterating over the
|
|
4213
4213
|
* form definition and checking if any of the inputs have the type 'ajaxSubGroup'
|
|
4214
4214
|
* with either yearRecords or checkboxRecords set. If they do, it aggregates
|
|
4215
4215
|
* the data from the corresponding year-specific keys and sets it as an array
|
|
4216
4216
|
* on the key specified in the form definition.
|
|
4217
|
-
*
|
|
4217
|
+
*
|
|
4218
4218
|
* @param {{ data: Object, form: Object }} - The form data structure.
|
|
4219
4219
|
* @returns {Object} - The mapped form data structure.
|
|
4220
4220
|
*/
|
|
@@ -4229,7 +4229,7 @@ const mapSubGroupsInSubmit = ({
|
|
|
4229
4229
|
Object.keys(form).forEach(k => {
|
|
4230
4230
|
Object.keys(form[k]).forEach(key => {
|
|
4231
4231
|
const input = form[k][key];
|
|
4232
|
-
if (input?.type ===
|
|
4232
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4233
4233
|
ajaxSubGroupsWithPeridicity.push(key);
|
|
4234
4234
|
}
|
|
4235
4235
|
});
|
|
@@ -4277,13 +4277,13 @@ const mapSubGroupsInGet = ({
|
|
|
4277
4277
|
Object.keys(form).forEach(k => {
|
|
4278
4278
|
if (form[k]?.type && form[k]?.dataId) {
|
|
4279
4279
|
const input = form[k];
|
|
4280
|
-
if (input?.type ===
|
|
4280
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4281
4281
|
ajaxSubGroupsWithPeridicity.push(k);
|
|
4282
4282
|
}
|
|
4283
4283
|
} else {
|
|
4284
4284
|
Object.keys(form[k]).forEach(key => {
|
|
4285
4285
|
const input = form[k][key];
|
|
4286
|
-
if (input?.type ===
|
|
4286
|
+
if (input?.type === "ajaxSubGroup" && (typeof input?.meta?.yearRecords === "number" || typeof input?.meta?.checkboxRecords === "string")) {
|
|
4287
4287
|
ajaxSubGroupsWithPeridicity.push(key);
|
|
4288
4288
|
}
|
|
4289
4289
|
});
|
|
@@ -4301,7 +4301,7 @@ const mapSubGroupsInGet = ({
|
|
|
4301
4301
|
return _data;
|
|
4302
4302
|
};
|
|
4303
4303
|
const isObjectEmpty = obj => {
|
|
4304
|
-
if (obj === null || typeof obj !==
|
|
4304
|
+
if (obj === null || typeof obj !== "object") {
|
|
4305
4305
|
return false;
|
|
4306
4306
|
}
|
|
4307
4307
|
if (Object.keys(obj).length === 0) {
|
|
@@ -4419,8 +4419,8 @@ const changeInputMeta = ({
|
|
|
4419
4419
|
* @returns {string} - The formatted date string.
|
|
4420
4420
|
*/
|
|
4421
4421
|
|
|
4422
|
-
const renderDateFormatted = (value, format =
|
|
4423
|
-
return dayjs__default["default"].utc(value,
|
|
4422
|
+
const renderDateFormatted = (value, format = "DD MMM YYYY", locale = "en") => {
|
|
4423
|
+
return dayjs__default["default"].utc(value, "YYYY-MM-DD").locale(locale).format(format);
|
|
4424
4424
|
};
|
|
4425
4425
|
|
|
4426
4426
|
({
|