@onehat/data 1.20.3 → 1.20.4
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 +1 -1
- package/src/Repository/OneBuild.js +13 -4
package/package.json
CHANGED
|
@@ -262,22 +262,31 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Integrates with RestTrait::reorder in OneBuild API
|
|
265
|
-
* @param {entity}
|
|
265
|
+
* @param {entity|array} dragRecordOrIds - which entity or ids were being dragged
|
|
266
266
|
* @param {entity} dropRecord - which entity it was dropped on to
|
|
267
267
|
* @param {string} dropPosition - position in which it was dropped; could be 'before' or 'after'
|
|
268
268
|
* @return {Promise}
|
|
269
269
|
*/
|
|
270
|
-
reorder = (
|
|
270
|
+
reorder = (dragRecordOrIds, dropRecord, dropPosition) => {
|
|
271
271
|
|
|
272
272
|
if (!this.isOnline) {
|
|
273
273
|
this.throwError('Offline');
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
|
|
277
|
+
let ids;
|
|
278
|
+
if (_.isArray(dragRecordOrIds)) {
|
|
279
|
+
ids = dragRecordOrIds;
|
|
280
|
+
} else if (dragRecordOrIds?.id) {
|
|
281
|
+
ids = [dragRecordOrIds.id];
|
|
282
|
+
} else {
|
|
283
|
+
throw Error('dragRecordOrIds must be an entity or array of ids')
|
|
284
|
+
}
|
|
285
|
+
|
|
277
286
|
const data = {
|
|
278
287
|
url: this.name + '/reorder',
|
|
279
288
|
data: qs.stringify({
|
|
280
|
-
ids
|
|
289
|
+
ids,
|
|
281
290
|
dropPosition,
|
|
282
291
|
dropRecord_id: dropRecord.id,
|
|
283
292
|
}),
|