@onehat/data 1.19.25 → 1.19.27
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
package/src/Entity/Entity.js
CHANGED
|
@@ -602,9 +602,6 @@ class Entity extends EventEmitter {
|
|
|
602
602
|
* @return {object} values
|
|
603
603
|
*/
|
|
604
604
|
get submitValues() {
|
|
605
|
-
if (this.isDestroyed) {
|
|
606
|
-
throw Error('this.submitValues is no longer valid. Entity has been destroyed.');
|
|
607
|
-
}
|
|
608
605
|
return this.getSubmitValues();
|
|
609
606
|
}
|
|
610
607
|
|
|
@@ -632,9 +629,6 @@ class Entity extends EventEmitter {
|
|
|
632
629
|
* @return {object} values
|
|
633
630
|
*/
|
|
634
631
|
get submitValuesMapped() {
|
|
635
|
-
if (this.isDestroyed) {
|
|
636
|
-
throw Error('this.submitValuesMapped is no longer valid. Entity has been destroyed.');
|
|
637
|
-
}
|
|
638
632
|
return this.getSubmitValuesMapped();
|
|
639
633
|
}
|
|
640
634
|
|
|
@@ -645,7 +639,7 @@ class Entity extends EventEmitter {
|
|
|
645
639
|
*/
|
|
646
640
|
getDisplayValues = () => {
|
|
647
641
|
if (this.isDestroyed) {
|
|
648
|
-
throw Error('this.
|
|
642
|
+
throw Error('this.getDisplayValues is no longer valid. Entity has been destroyed.');
|
|
649
643
|
}
|
|
650
644
|
let propertyValues = {};
|
|
651
645
|
_.forOwn(this.properties, (property) => {
|
|
@@ -659,9 +653,6 @@ class Entity extends EventEmitter {
|
|
|
659
653
|
* @return {object} values
|
|
660
654
|
*/
|
|
661
655
|
get displayValues() {
|
|
662
|
-
if (this.isDestroyed) {
|
|
663
|
-
throw Error('this.displayValues is no longer valid. Entity has been destroyed.');
|
|
664
|
-
}
|
|
665
656
|
return this.getDisplayValues();
|
|
666
657
|
}
|
|
667
658
|
|
|
@@ -686,9 +677,6 @@ class Entity extends EventEmitter {
|
|
|
686
677
|
* @return {object} values
|
|
687
678
|
*/
|
|
688
679
|
get rawValues() {
|
|
689
|
-
if (this.isDestroyed) {
|
|
690
|
-
throw Error('this.rawValues is no longer valid. Entity has been destroyed.');
|
|
691
|
-
}
|
|
692
680
|
return this.getRawValues();
|
|
693
681
|
}
|
|
694
682
|
|
|
@@ -713,9 +701,6 @@ class Entity extends EventEmitter {
|
|
|
713
701
|
* @return {object} values
|
|
714
702
|
*/
|
|
715
703
|
get parsedRawValues() {
|
|
716
|
-
if (this.isDestroyed) {
|
|
717
|
-
throw Error('this.parsedRawValues is no longer valid. Entity has been destroyed.');
|
|
718
|
-
}
|
|
719
704
|
return this.getParsedRawValues();
|
|
720
705
|
}
|
|
721
706
|
|
|
@@ -726,7 +711,7 @@ class Entity extends EventEmitter {
|
|
|
726
711
|
*/
|
|
727
712
|
getParsedValues = () => {
|
|
728
713
|
if (this.isDestroyed) {
|
|
729
|
-
throw Error('this.
|
|
714
|
+
throw Error('this.getParsedValues is no longer valid. Entity has been destroyed.');
|
|
730
715
|
}
|
|
731
716
|
let propertyValues = {};
|
|
732
717
|
_.forOwn(this.properties, (property) => {
|
|
@@ -740,9 +725,6 @@ class Entity extends EventEmitter {
|
|
|
740
725
|
* @return {object} values
|
|
741
726
|
*/
|
|
742
727
|
get parsedValues() {
|
|
743
|
-
if (this.isDestroyed) {
|
|
744
|
-
throw Error('this.parsedValues is no longer valid. Entity has been destroyed.');
|
|
745
|
-
}
|
|
746
728
|
return this.getParsedValues();
|
|
747
729
|
}
|
|
748
730
|
|
|
@@ -27,14 +27,13 @@ export default function useOneHatData(schemaName, uniqueRepository = false) {
|
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
|
|
30
|
-
let repository
|
|
31
|
-
|
|
32
|
-
setEntities(repository.entities); // Set new state in component
|
|
33
|
-
};
|
|
30
|
+
let repository,
|
|
31
|
+
onChangeData = () => {};
|
|
34
32
|
(async () => {
|
|
35
33
|
|
|
36
34
|
if (uniqueRepository) {
|
|
37
35
|
repository = await oneHatData.createRepository(schemaName);
|
|
36
|
+
repository.isUnique = true;
|
|
38
37
|
} else if (_.isObject(schemaName)) {
|
|
39
38
|
if (schemaName.id) {
|
|
40
39
|
repository = oneHatData.getRepositoryById(schemaName.id);
|
|
@@ -45,6 +44,9 @@ export default function useOneHatData(schemaName, uniqueRepository = false) {
|
|
|
45
44
|
} else {
|
|
46
45
|
repository = oneHatData.getRepository(schemaName); // Get bound Repository for this schema
|
|
47
46
|
}
|
|
47
|
+
onChangeData = () => {
|
|
48
|
+
setEntities(repository.entities); // Set new state in component
|
|
49
|
+
};
|
|
48
50
|
|
|
49
51
|
setRepository(repository);
|
|
50
52
|
setEntities(repository.entities);
|
package/src/OneHatData.js
CHANGED
|
@@ -487,6 +487,7 @@ export class OneHatData extends EventEmitter {
|
|
|
487
487
|
const id = uuid();
|
|
488
488
|
clone.name = clone.name + '-' + id;
|
|
489
489
|
clone.id = id;
|
|
490
|
+
clone.isUnique = true;
|
|
490
491
|
return clone;
|
|
491
492
|
}
|
|
492
493
|
return schema.getBoundRepository();
|
|
@@ -517,6 +518,7 @@ export class OneHatData extends EventEmitter {
|
|
|
517
518
|
|
|
518
519
|
const repository = await this.createRepository(schemaName);
|
|
519
520
|
this.uniqueRepositoriesMap[mapName] = repository.id;
|
|
521
|
+
repository.isUnique = true;
|
|
520
522
|
return repository;
|
|
521
523
|
}
|
|
522
524
|
|
package/src/Repository/Memory.js
CHANGED
|
@@ -331,6 +331,11 @@ class MemoryRepository extends Repository {
|
|
|
331
331
|
passedAll = false;
|
|
332
332
|
return false; // break the forEach loop
|
|
333
333
|
}
|
|
334
|
+
} else if (!_.isNil(filter.fn)) {
|
|
335
|
+
if (!filter.fn(entity)) {
|
|
336
|
+
passedAll = false;
|
|
337
|
+
return false; // break the forEach loop
|
|
338
|
+
}
|
|
334
339
|
} else {
|
|
335
340
|
const { name, value } = filter,
|
|
336
341
|
property = entity.getProperty(name);
|
|
@@ -47,6 +47,11 @@ export default class Repository extends EventEmitter {
|
|
|
47
47
|
*/
|
|
48
48
|
name: schema.name,
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @member {boolean} isUnique - Whether this repository is classified as 'unique'
|
|
52
|
+
*/
|
|
53
|
+
isUnique: false,
|
|
54
|
+
|
|
50
55
|
/**
|
|
51
56
|
* @member {boolean} isAutoLoad - Whether to immediately load this repository's data on instantiation
|
|
52
57
|
*/
|
|
@@ -611,10 +616,6 @@ export default class Repository extends EventEmitter {
|
|
|
611
616
|
* @member {boolean} hasFilters - Whether or not any filters are applied
|
|
612
617
|
*/
|
|
613
618
|
get hasFilters() {
|
|
614
|
-
if (this.isDestroyed) {
|
|
615
|
-
this.throwError('this.hasFilters is no longer valid. Repository has been destroyed.');
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
619
|
return this.filters.length > 0;
|
|
619
620
|
}
|
|
620
621
|
|
|
@@ -622,9 +623,7 @@ export default class Repository extends EventEmitter {
|
|
|
622
623
|
if (!this.hasFilters) {
|
|
623
624
|
return false;
|
|
624
625
|
}
|
|
625
|
-
const found = _.find(this.filters, (filter) =>
|
|
626
|
-
return filter.name === name;
|
|
627
|
-
});
|
|
626
|
+
const found = _.find(this.filters, (filter) => filter.name === name);
|
|
628
627
|
return !!found;
|
|
629
628
|
}
|
|
630
629
|
|
|
@@ -697,14 +696,14 @@ export default class Repository extends EventEmitter {
|
|
|
697
696
|
// Set up new filters
|
|
698
697
|
let filters = clearFirst ?
|
|
699
698
|
[] : // Clear existing filters
|
|
700
|
-
_.
|
|
699
|
+
_.clone(this.filters); // so we can detect changes in _setFilters
|
|
701
700
|
|
|
702
701
|
_.each(newFilters, (newFilter) => {
|
|
703
702
|
|
|
704
703
|
let deleteExisting = false,
|
|
705
704
|
addNew = true;
|
|
706
705
|
|
|
707
|
-
if (!_.isFunction(newFilter)) {
|
|
706
|
+
if (!_.isFunction(newFilter) && _.isNil(newFilter.fn)) {
|
|
708
707
|
if (_.isNil(newFilter.value)) {
|
|
709
708
|
deleteExisting = true;
|
|
710
709
|
addNew = false;
|
package/src/Util/Formatters.js
CHANGED
|
@@ -69,9 +69,9 @@ class Formatters {
|
|
|
69
69
|
// See http://stackoverflow.com/questions/2587345/javascript-date-parse?rq=1
|
|
70
70
|
// If accuracy is absolutely needed and format is known, use a regex to
|
|
71
71
|
// manually parse, then pass in arguments to new Date().
|
|
72
|
-
let date = moment(value, 'YYYY-MM-DD');
|
|
72
|
+
let date = moment(value, 'YYYY-MM-DD', true);
|
|
73
73
|
if (!date) {
|
|
74
|
-
date = moment(value, 'YYYY-MM-DD HH:mm:ss');
|
|
74
|
+
date = moment(value, 'YYYY-MM-DD HH:mm:ss', true);
|
|
75
75
|
}
|
|
76
76
|
if (typeof date !== 'undefined' && date !== null) {
|
|
77
77
|
date = new Date(date);
|