@onehat/data 1.12.0 → 1.13.1

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.12.0",
3
+ "version": "1.13.1",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -479,9 +479,15 @@ export default class Repository extends EventEmitter {
479
479
  throw Error('this.getDefaultSorters is no longer valid. Repository has been destroyed.');
480
480
  }
481
481
  let sorters = [];
482
- if (this.schema && this.schema.model) {
482
+ if (this.schema?.model) {
483
483
  if (_.size(this.schema.model.sorters) > 0) {
484
484
  sorters = this.schema.model.sorters
485
+ } else if (!_.isNil(this.schema.model.sortProperty)) {
486
+ sorters = [{
487
+ name: this.schema.model.sortProperty,
488
+ direction: 'ASC',
489
+ fn: 'default',
490
+ }];
485
491
  } else if (!_.isNil(this.schema.model.displayProperty)) {
486
492
  sorters = [{
487
493
  name: this.schema.model.displayProperty,
@@ -58,6 +58,12 @@ export default class Schema extends EventEmitter {
58
58
  */
59
59
  displayProperty: null,
60
60
 
61
+ /**
62
+ * @member {string} sortProperty - name of sort Property (e.g. 'users__sort_order')
63
+ * if sortProperty has a value and sorters is left blank, an automatic sorter with this property will be created.
64
+ */
65
+ sortProperty: null,
66
+
61
67
  /**
62
68
  * @member {array} properties - Array of Property definition objects
63
69
  */
@@ -1,7 +1,7 @@
1
1
  import moment from 'moment';
2
2
  import momentAlt from 'relative-time-parser'; // Notice this version of moment is imported from 'relative-time-parser', and may be out of sync with our general 'moment' package
3
3
  import accounting from 'accounting-js';
4
- import * as chrono from 'chrono-node';
4
+ // import * as chrono from 'chrono-node'; // Doesn't yet work in React Native ("SyntaxError: Invalid RegExp: Quantifier has nothing to repeat, js engine: hermes") Github ticket: https://github.com/facebook/hermes/blob/main/doc/RegExp.md
5
5
  import _ from 'lodash';
6
6
 
7
7
  class Parsers {