@onehat/data 1.13.4 → 1.13.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.13.4",
3
+ "version": "1.13.5",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -232,8 +232,49 @@ class OneBuildRepository extends AjaxRepository {
232
232
  };
233
233
  }
234
234
 
235
+
235
236
  /**
236
- * Login to OnBuild API
237
+ * Integrates with RestTrait::reorder in OneBuild API
238
+ * @param {entity} dragRecord - which entity was being dragged
239
+ * @param {entity} dropRecord - which entity it was dropped on to
240
+ * @param {string} dropPosition - position in which it was dropped; could be 'before' or 'after'
241
+ * @return {Promise}
242
+ */
243
+ reorder = (dragRecord, dropRecord, dropPosition) => {
244
+ const data = {
245
+ url: 'reorder',
246
+ data: qs.stringify({
247
+ ids: dragRecord.id,
248
+ dropPosition,
249
+ dropRecord_id: dropRecord.id,
250
+ }),
251
+ method: 'POST',
252
+ baseURL: this.api.baseURL,
253
+ };
254
+
255
+ if (this.debugMode) {
256
+ console.log('reorder', data);
257
+ }
258
+
259
+ return this.axios(data)
260
+ .then((result) => {
261
+ if (this.debugMode) {
262
+ console.log('reorder response', result);
263
+ }
264
+
265
+ const response = result.data;
266
+ if (!response.success) {
267
+ throw new Error(response.data);
268
+ }
269
+
270
+ // Reload the repository, so updated sort_order values can be retrieved
271
+ this.reload();
272
+
273
+ });
274
+ }
275
+
276
+ /**
277
+ * Login to OneBuild API
237
278
  * @param {object} creds - object with two properties:
238
279
  * - username,
239
280
  * - password,
@@ -269,7 +310,7 @@ class OneBuildRepository extends AjaxRepository {
269
310
  }
270
311
 
271
312
  /**
272
- * Logout from OnBuild API
313
+ * Logout from OneBuild API
273
314
  * @return {Promise}
274
315
  */
275
316
  logout = () => {