@builttocreate/engine-utils 2.10.1-beta.v593.8 → 2.10.1-beta.v593.9

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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -8,6 +9,7 @@ exports.generateReadableTableColumnId = generateReadableTableColumnId;
8
9
  exports.getFieldPositionsCount = getFieldPositionsCount;
9
10
  exports.getFieldsCount = getFieldsCount;
10
11
  exports.getViewsFieldPositionsCount = getViewsFieldPositionsCount;
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
13
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
12
14
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
15
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
@@ -119,6 +121,12 @@ function generateReadableId(parts, type) {
119
121
  // if (views && views.length > 1) count += getViewsFieldPositionsCount(views, type);
120
122
 
121
123
  var readableId = "".concat(type).concat(splitterId).concat(count + 1);
124
+
125
+ /**
126
+ * If the user drags one text field and renames it to text 2, we need to ensure
127
+ * the newly generatedId is different than text2
128
+ * */
129
+
122
130
  fields.forEach(function (field) {
123
131
  if (field._id === readableId) readableId = "".concat(type).concat(splitterId).concat(count + 2);
124
132
  });
@@ -136,8 +144,9 @@ function generateReadableId(parts, type) {
136
144
  function generateReadableTableColumnId(tableId, tableColumns, columnId) {
137
145
  //Add logic that ensures that created Id is not a duplicate
138
146
  if (!tableId) throw new Error('generateReadableTableColumnId: tableId is required');
139
- if (!columnId) throw new Error('generateReadableTableColumnId');
147
+ if (!columnId) throw new Error('generateReadableTableColumnId: columnId is required');
140
148
  if (!tableColumns || !Array.isArray(tableColumns)) {
149
+ console.warn('generateReadableTableColumnId: tableColumns parameter is missing or not an array');
141
150
  return "".concat(tableId, "Column1");
142
151
  }
143
152
  var counts = {};
@@ -149,13 +158,29 @@ function generateReadableTableColumnId(tableId, tableColumns, columnId) {
149
158
  var _iterator = _createForOfIteratorHelper(validColumns),
150
159
  _step;
151
160
  try {
152
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
161
+ var _loop = function _loop() {
153
162
  var col = _step.value;
154
163
  var type = (col.type || 'unknown').toLowerCase();
155
164
  counts[type] = (counts[type] || 0) + 1;
165
+ var readableId = "".concat(type).concat(counts[type]);
156
166
  if (col._id === columnId) {
157
- return "".concat(type).concat(counts[type]);
167
+ /**
168
+ * If the user drags one text column it would have text1 as the id. If he renames it to text2, we
169
+ * need to esnure the newly generatedId is different than text2
170
+ */
171
+ tableColumns.forEach(function (column) {
172
+ if (column._id === readableId) {
173
+ readableId = "".concat(type).concat(counts[type] + 2);
174
+ }
175
+ });
176
+ return {
177
+ v: readableId
178
+ };
158
179
  }
180
+ };
181
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
182
+ var _ret = _loop();
183
+ if ((0, _typeof2["default"])(_ret) === "object") return _ret.v;
159
184
  }
160
185
  } catch (err) {
161
186
  _iterator.e(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "2.10.1-beta.v593.8",
3
+ "version": "2.10.1-beta.v593.9",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [