@builttocreate/engine-utils 2.10.1-beta.v593.23 → 2.10.1-beta.v593.25
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/generateReadableId.js +0 -1
- package/dist/validateReadableId.js +25 -24
- package/package.json +1 -1
|
@@ -164,7 +164,6 @@ function generateReadableTableColumnId(tableId, tableColumns, columnId) {
|
|
|
164
164
|
var type = (col.type || 'unknown').toLowerCase();
|
|
165
165
|
counts[type] = (counts[type] || 0) + 1;
|
|
166
166
|
var readableId = "".concat(type).concat(counts[type]);
|
|
167
|
-
counts[type]++;
|
|
168
167
|
if (col._id === columnId) {
|
|
169
168
|
/**
|
|
170
169
|
* If the generatedReadableId is already present in the tableColumns,
|
|
@@ -146,33 +146,34 @@ var _default = exports["default"] = function _default(readableId, fields, tableC
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
//6. Check for duplicates in readableIds
|
|
149
|
-
if (!Array.isArray(fields)) return;
|
|
150
|
-
|
|
151
|
-
//DuplicateId check for fieldIds
|
|
152
|
-
var duplicateField = fields.find(function (field) {
|
|
153
|
-
return field._id === readableId;
|
|
154
|
-
});
|
|
155
|
-
if (duplicateField) {
|
|
156
|
-
console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
149
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (fieldId) {
|
|
165
|
-
var targetField = fields.find(function (field) {
|
|
166
|
-
return field._id === fieldId;
|
|
150
|
+
if (Array.isArray(fields)) {
|
|
151
|
+
//DuplicateId check for fieldIds
|
|
152
|
+
var duplicateField = fields.find(function (field) {
|
|
153
|
+
return field._id === readableId;
|
|
167
154
|
});
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
155
|
+
if (duplicateField) {
|
|
156
|
+
console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* DuplicateId check for nested tables of collection fields
|
|
162
|
+
* When readableIds for nestedTables are passed in, we need the fieldId to retrieve the collection fields that houses the nestedTable
|
|
163
|
+
*/
|
|
164
|
+
if (fieldId) {
|
|
165
|
+
var targetField = fields.find(function (field) {
|
|
166
|
+
return field._id === fieldId;
|
|
172
167
|
});
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
if ((targetField === null || targetField === void 0 ? void 0 : targetField.type) === _FieldTypes["default"].collection) {
|
|
169
|
+
var flattenedSchema = (0, _fieldHelper.flattenSchemaTree)(targetField.schema);
|
|
170
|
+
var readableIdExists = flattenedSchema.some(function (schema) {
|
|
171
|
+
return schema.id === readableId;
|
|
172
|
+
});
|
|
173
|
+
if (readableIdExists) {
|
|
174
|
+
console.warn("validateReadableId: \"".concat(readableId, "\" is invalid - it already exists in fields"));
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
}
|