@builttocreate/engine-utils 2.10.1-beta.v593.24 → 2.10.1-beta.v593.26

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.
@@ -114,23 +114,38 @@ function generateReadableId(parts, type) {
114
114
  throw new Error('generateReadableId: at least one of fields, pages, or views is required');
115
115
  }
116
116
  if (!fields) console.warn('generateReadableId: fields parameter is missing');
117
- var count = 0;
118
- if (fields) count += getFieldsCount(fields, type);
119
- // Note: leaving for now until we allow targeting fieldPositions
120
- // if (pages) count += getFieldPositionsCount(pages, type);
121
- // if (views && views.length > 1) count += getViewsFieldPositionsCount(views, type);
122
117
 
123
- var readableId = "".concat(type).concat(splitterId).concat(count + 1);
124
- count++;
118
+ // let count = 0;
125
119
 
126
- /**
127
- * If the user drags one text field and renames it to text 2, we need to ensure
128
- * the newly generatedId is different than text2
129
- * */
120
+ // if (fields) count += getFieldsCount(fields, type);
121
+ // // Note: leaving for now until we allow targeting fieldPositions
122
+ // // if (pages) count += getFieldPositionsCount(pages, type);
123
+ // // if (views && views.length > 1) count += getViewsFieldPositionsCount(views, type);
130
124
 
131
- fields.forEach(function (field) {
132
- if (field._id === readableId) readableId = "".concat(type).concat(splitterId).concat(count + 1);
133
- });
125
+ // let readableId = `${type}${splitterId}${count + 1}`
126
+ // count++;
127
+
128
+ // /**
129
+ // * If the user drags one text field and renames it to text 2, we need to ensure
130
+ // * the newly generatedId is different than text2
131
+ // * */
132
+
133
+ // fields.forEach((field ) => {
134
+
135
+ // if(field._id === readableId) readableId = `${type}${splitterId}${count + 1}`
136
+
137
+ // })
138
+
139
+ // return readableId;
140
+
141
+ var count = fields.length ? getFieldsCount(fields, type) : 0;
142
+ var readableId = "".concat(type).concat(splitterId).concat(count + 1);
143
+ while (fields.some(function (field) {
144
+ return field._id === readableId;
145
+ })) {
146
+ count++;
147
+ readableId = "".concat(type).concat(splitterId).concat(count + 1);
148
+ }
134
149
  return readableId;
135
150
  }
136
151
  ;
@@ -164,7 +179,6 @@ function generateReadableTableColumnId(tableId, tableColumns, columnId) {
164
179
  var type = (col.type || 'unknown').toLowerCase();
165
180
  counts[type] = (counts[type] || 0) + 1;
166
181
  var readableId = "".concat(type).concat(counts[type]);
167
- counts[type]++;
168
182
  if (col._id === columnId) {
169
183
  /**
170
184
  * If the generatedReadableId is already present in the tableColumns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.10.1-beta.v593.24",
3
+ "version": "2.10.1-beta.v593.26",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [