@onehat/data 1.9.0 → 1.9.2
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.
|
@@ -263,6 +263,17 @@ describe('Repository Base', function() {
|
|
|
263
263
|
expect(sortDirection).to.be.eq('ASC');
|
|
264
264
|
});
|
|
265
265
|
|
|
266
|
+
it('getSortFn', function() {
|
|
267
|
+
this.repository.setSorters([{
|
|
268
|
+
name: 'value',
|
|
269
|
+
direction: 'ASC',
|
|
270
|
+
fn: 'natsort',
|
|
271
|
+
}]);
|
|
272
|
+
|
|
273
|
+
const sortFn = this.repository.getSortFn();
|
|
274
|
+
expect(sortFn).to.be.eq('natsort');
|
|
275
|
+
});
|
|
276
|
+
|
|
266
277
|
});
|
|
267
278
|
|
|
268
279
|
describe('filtering', function() {
|
package/package.json
CHANGED
|
@@ -1364,6 +1364,20 @@ export default class Repository extends EventEmitter {
|
|
|
1364
1364
|
return this.sorters[0].direction;
|
|
1365
1365
|
}
|
|
1366
1366
|
|
|
1367
|
+
/**
|
|
1368
|
+
* Gets the sort function, if only one sorter is applied.
|
|
1369
|
+
* @return {Schema} schema
|
|
1370
|
+
*/
|
|
1371
|
+
getSortFn = () => {
|
|
1372
|
+
if (this.isDestroyed) {
|
|
1373
|
+
throw Error('this.getSortDirection is no longer valid. Repository has been destroyed.');
|
|
1374
|
+
}
|
|
1375
|
+
if (!this.allowsMultiSort || this.sorters.length < 1) {
|
|
1376
|
+
return null;
|
|
1377
|
+
}
|
|
1378
|
+
return this.sorters[0].fn;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1367
1381
|
/**
|
|
1368
1382
|
* Gets the associated Repository
|
|
1369
1383
|
* @param {string} repositoryName - Name of the Repository to retrieve
|