@onehat/data 1.20.9 → 1.21.0
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/cypress/downloads/downloads.html +0 -0
- package/cypress/e2e/Entity.cy.js +2 -2
- package/cypress/e2e/Property/Base64.cy.js +37 -3
- package/cypress/e2e/Property/Boolean.cy.js +30 -0
- package/cypress/e2e/Property/Currency.cy.js +41 -0
- package/cypress/e2e/Property/Date.cy.js +33 -0
- package/cypress/e2e/Property/DateTime.cy.js +33 -0
- package/cypress/e2e/Property/Float.cy.js +31 -0
- package/cypress/e2e/Property/Integer.cy.js +31 -0
- package/cypress/e2e/Property/Json.cy.js +29 -0
- package/cypress/e2e/Property/PercentInt.cy.js +32 -0
- package/cypress/e2e/Property/Property.cy.js +29 -0
- package/cypress/e2e/Property/Time.cy.js +33 -0
- package/cypress/e2e/Repository/Repository.cy.js +23 -16
- package/cypress/e2e/Schema.cy.js +2 -2
- package/package.json +1 -1
- package/src/Integration/Browser/Repository/Cookie.js +4 -4
- package/src/Integration/Browser/Repository/IndexedDB.js +4 -4
- package/src/Integration/Browser/Repository/LocalStorage.js +4 -4
- package/src/Integration/Browser/Repository/SecureLocalStorage.js +2 -2
- package/src/Integration/Browser/Repository/SecureSessionStorage.js +2 -2
- package/src/Integration/Browser/Repository/SessionStorage.js +4 -4
- package/src/Integration/ReactNative/Repository/AsyncStorage.js +8 -8
- package/src/Integration/ReactNative/Repository/SecureStore.js +4 -4
- package/src/Property/Base64.js +21 -11
- package/src/Property/Boolean.js +20 -12
- package/src/Property/Currency.js +30 -21
- package/src/Property/Date.js +23 -14
- package/src/Property/DateTime.js +18 -9
- package/src/Property/File.js +0 -4
- package/src/Property/Float.js +19 -10
- package/src/Property/Integer.js +19 -10
- package/src/Property/Json.js +22 -13
- package/src/Property/Percent.js +2 -2
- package/src/Property/PercentInt.js +16 -7
- package/src/Property/Property.js +150 -140
- package/src/Property/String.js +2 -7
- package/src/Property/Time.js +17 -8
- package/src/Property/Uuid.js +3 -8
- package/src/Property/index.js +2 -0
- package/src/Repository/Ajax.js +33 -28
- package/src/Repository/LocalFromRemote/Command.js +5 -5
- package/src/Repository/LocalFromRemote/CommandRepository.js +1 -1
- package/src/Repository/LocalFromRemote/LocalFromRemote.js +18 -17
- package/src/Repository/Memory.js +22 -21
- package/src/Repository/Null.js +5 -5
- package/src/Repository/Offline.js +17 -16
- package/src/Repository/OneBuild.js +34 -28
- package/src/Repository/OneBuild2.js +16 -10
- package/src/Repository/Repository.js +105 -102
- package/src/Schema/Schema.js +9 -6
|
@@ -24,7 +24,7 @@ class SessionStorageRepository extends OfflineRepository {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
_storageGetValue
|
|
27
|
+
_storageGetValue(name) {
|
|
28
28
|
const result = this._store.session(name);
|
|
29
29
|
let value;
|
|
30
30
|
try {
|
|
@@ -36,18 +36,18 @@ class SessionStorageRepository extends OfflineRepository {
|
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
_storageSetValue
|
|
39
|
+
_storageSetValue(name, value) {
|
|
40
40
|
if (!_.isString(value)) {
|
|
41
41
|
value = JSON.stringify(value);
|
|
42
42
|
}
|
|
43
43
|
return this._store.session(name, value);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
_storageDeleteValue
|
|
46
|
+
_storageDeleteValue(name) {
|
|
47
47
|
return this._store.session.remove(name);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
clearAll
|
|
50
|
+
clearAll() {
|
|
51
51
|
return this._store.session.clearAll();
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -21,7 +21,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
21
21
|
_.merge(this, config);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
async _storageGetValue(name) {
|
|
25
25
|
try {
|
|
26
26
|
|
|
27
27
|
if (this.debugMode) {
|
|
@@ -51,7 +51,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
async _storageGetMultiple(keys) {
|
|
55
55
|
try {
|
|
56
56
|
|
|
57
57
|
if (keys.length === 0) {
|
|
@@ -115,7 +115,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
async _storageSetValue(name, value) {
|
|
119
119
|
try {
|
|
120
120
|
if (!_.isString(value)) {
|
|
121
121
|
value = JSON.stringify(value);
|
|
@@ -134,7 +134,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
async _storageSetMultiple(values) {
|
|
138
138
|
try {
|
|
139
139
|
const converted = [],
|
|
140
140
|
keys = [];
|
|
@@ -166,7 +166,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
async _storageDeleteValue(name) {
|
|
170
170
|
try {
|
|
171
171
|
if (_.isNil(name) || (_.isString(name) && name === '')) {
|
|
172
172
|
return;
|
|
@@ -186,7 +186,7 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
async _storageDeleteMultiple(keys) {
|
|
190
190
|
try {
|
|
191
191
|
if (_.isNil(keys) || (_.isArray(keys) && !keys.length)) {
|
|
192
192
|
return;
|
|
@@ -206,12 +206,12 @@ class AsyncStorageRepository extends OfflineRepository {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
async clearAll() {
|
|
210
210
|
await this.load([]);
|
|
211
211
|
await this.clearLastSync();
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
async getAllKeys() {
|
|
215
215
|
return await AsyncStorage.getAllKeys();
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -20,7 +20,7 @@ class SecureStoreRepository extends OfflineRepository {
|
|
|
20
20
|
_.merge(this, config);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
async _storageGetValue(name) {
|
|
24
24
|
try {
|
|
25
25
|
|
|
26
26
|
if (this.debugMode) {
|
|
@@ -72,7 +72,7 @@ class SecureStoreRepository extends OfflineRepository {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
async _storageSetValue(name, value) {
|
|
76
76
|
try {
|
|
77
77
|
if (!_.isString(value)) {
|
|
78
78
|
value = JSON.stringify(value);
|
|
@@ -123,7 +123,7 @@ class SecureStoreRepository extends OfflineRepository {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
async _storageDeleteValue(name) {
|
|
127
127
|
try {
|
|
128
128
|
if (this.debugMode) {
|
|
129
129
|
console.log(this.name, 'SecureStore.delete', name);
|
|
@@ -160,7 +160,7 @@ class SecureStoreRepository extends OfflineRepository {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
async clearAll() {
|
|
164
164
|
await this.load([]);
|
|
165
165
|
}
|
|
166
166
|
|
package/src/Property/Base64.js
CHANGED
|
@@ -11,23 +11,33 @@ import _ from 'lodash';
|
|
|
11
11
|
*/
|
|
12
12
|
export default class Base64Property extends Property {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_.merge(
|
|
20
|
-
|
|
14
|
+
static defaults = {
|
|
15
|
+
isSortable: false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
constructor(config = {}, entity) {
|
|
19
|
+
config = _.merge({}, Base64Property.defaults, config);
|
|
20
|
+
super(config, entity);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
25
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
26
|
+
* @returns {Object} The default configuration
|
|
27
|
+
*/
|
|
28
|
+
static getStaticDefaults(defaults = {}) {
|
|
29
|
+
const superDefaults = super.getStaticDefaults();
|
|
30
|
+
return _.merge({}, superDefaults, Base64Property.defaults, defaults);
|
|
21
31
|
}
|
|
22
32
|
|
|
23
|
-
encode
|
|
33
|
+
encode(value) {
|
|
24
34
|
return Base64.encode(value);
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
/**
|
|
28
38
|
* Decodes to UTF-8 string
|
|
29
39
|
*/
|
|
30
|
-
decode
|
|
40
|
+
decode(value) {
|
|
31
41
|
return Base64.decode(value);
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -35,11 +45,11 @@ export default class Base64Property extends Property {
|
|
|
35
45
|
* Decodes to bytes, which is compatible with browser's built-in atob()
|
|
36
46
|
* (Which is absent in node)
|
|
37
47
|
*/
|
|
38
|
-
atob
|
|
48
|
+
atob(value) {
|
|
39
49
|
return Base64.atob(value);
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
btoa
|
|
52
|
+
btoa(value) {
|
|
43
53
|
return Base64.btoa(value);
|
|
44
54
|
}
|
|
45
55
|
|
package/src/Property/Boolean.js
CHANGED
|
@@ -11,19 +11,27 @@ import _ from 'lodash';
|
|
|
11
11
|
*/
|
|
12
12
|
export default class BooleanProperty extends Property {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
static defaults = {
|
|
15
|
+
submitAsInt: false,
|
|
16
|
+
defaultValue: false,
|
|
17
|
+
};
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
19
|
+
constructor(config = {}, entity) {
|
|
20
|
+
config = _.merge({}, BooleanProperty.defaults, config);
|
|
21
|
+
super(config, entity);
|
|
22
|
+
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
26
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
27
|
+
* @returns {Object} The default configuration
|
|
28
|
+
*/
|
|
29
|
+
static getStaticDefaults(defaults = {}) {
|
|
30
|
+
const superDefaults = super.getStaticDefaults();
|
|
31
|
+
return _.merge({}, superDefaults, BooleanProperty.defaults, defaults);
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
parse
|
|
34
|
+
parse(value) {
|
|
27
35
|
if (this.isDestroyed) {
|
|
28
36
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
29
37
|
}
|
|
@@ -33,14 +41,14 @@ export default class BooleanProperty extends Property {
|
|
|
33
41
|
return Parsers.ParseBool(value);
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
getDisplayValue
|
|
44
|
+
getDisplayValue() {
|
|
37
45
|
if (this.isDestroyed) {
|
|
38
46
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
39
47
|
}
|
|
40
48
|
return Formatters.FormatBoolAsYesNo(this.parsedValue);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
getSubmitValue
|
|
51
|
+
getSubmitValue() {
|
|
44
52
|
if (this.isDestroyed) {
|
|
45
53
|
throw Error('this.getSubmitValue is no longer valid. Property has been destroyed.');
|
|
46
54
|
}
|
|
@@ -53,7 +61,7 @@ export default class BooleanProperty extends Property {
|
|
|
53
61
|
return Parsers.ParseBool(this.parsedValue); // Use a Parser instead of a Formatter to make sure we submit it as an actual boolean primitive value
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
toggle
|
|
64
|
+
toggle() {
|
|
57
65
|
if (this.isDestroyed) {
|
|
58
66
|
throw Error('this.toggle is no longer valid. Property has been destroyed.');
|
|
59
67
|
}
|
package/src/Property/Currency.js
CHANGED
|
@@ -10,29 +10,38 @@ import _ from 'lodash';
|
|
|
10
10
|
*/
|
|
11
11
|
export default class CurrencyProperty extends Property {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
static defaults = {
|
|
14
|
+
displayOptions: {
|
|
15
|
+
symbol: "$",
|
|
16
|
+
format: '%s%v',
|
|
17
|
+
decimal: '.' ,
|
|
18
|
+
thousand: ',',
|
|
19
|
+
precision: 2,
|
|
20
|
+
grouping: 3,
|
|
21
|
+
stripZeros: false,
|
|
22
|
+
fallback: 0,
|
|
23
|
+
},
|
|
24
|
+
submitAsString: true, // NOTE, we want to use the accounting.toFixed() method by default
|
|
25
|
+
defaultValue: 0.00,
|
|
26
|
+
omitZeros: false, // Should we omit any .00 at the end?
|
|
27
|
+
};
|
|
15
28
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
decimal: '.' ,
|
|
21
|
-
thousand: ',',
|
|
22
|
-
precision: 2,
|
|
23
|
-
grouping: 3,
|
|
24
|
-
stripZeros: false,
|
|
25
|
-
fallback: 0,
|
|
26
|
-
},
|
|
27
|
-
submitAsString: true, // NOTE, we want to use the accounting.toFixed() method by default
|
|
28
|
-
defaultValue: 0.00,
|
|
29
|
-
omitZeros: false, // Should we omit any .00 at the end?
|
|
30
|
-
};
|
|
29
|
+
constructor(config = {}, entity) {
|
|
30
|
+
config = _.merge({}, CurrencyProperty.defaults, config);
|
|
31
|
+
super(config, entity);
|
|
32
|
+
}
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
36
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
37
|
+
* @returns {Object} The default configuration
|
|
38
|
+
*/
|
|
39
|
+
static getStaticDefaults(defaults = {}) {
|
|
40
|
+
const superDefaults = super.getStaticDefaults();
|
|
41
|
+
return _.merge({}, superDefaults, CurrencyProperty.defaults, defaults);
|
|
33
42
|
}
|
|
34
43
|
|
|
35
|
-
parse
|
|
44
|
+
parse(value) {
|
|
36
45
|
if (this.isDestroyed) {
|
|
37
46
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
38
47
|
}
|
|
@@ -42,7 +51,7 @@ export default class CurrencyProperty extends Property {
|
|
|
42
51
|
return accounting.unformat(value);
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
getDisplayValue
|
|
54
|
+
getDisplayValue() {
|
|
46
55
|
if (this.isDestroyed) {
|
|
47
56
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
48
57
|
}
|
|
@@ -54,7 +63,7 @@ export default class CurrencyProperty extends Property {
|
|
|
54
63
|
return ret;
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
getSubmitValue
|
|
66
|
+
getSubmitValue() {
|
|
58
67
|
if (this.isDestroyed) {
|
|
59
68
|
throw Error('this.getSubmitValue is no longer valid. Property has been destroyed.');
|
|
60
69
|
}
|
package/src/Property/Date.js
CHANGED
|
@@ -11,16 +11,25 @@ import _ from 'lodash';
|
|
|
11
11
|
*/
|
|
12
12
|
export default class DateProperty extends Property {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
static defaults = {
|
|
15
|
+
readFormat: 'YYYY-MM-DD',
|
|
16
|
+
displayFormat: 'MMM DD, YYYY',
|
|
17
|
+
submitFormat: 'YYYY-MM-DD',
|
|
18
|
+
};
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
20
|
+
constructor(config = {}, entity) {
|
|
21
|
+
config = _.merge({}, DateProperty.defaults, config);
|
|
22
|
+
super(config, entity);
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
27
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
28
|
+
* @returns {Object} The default configuration
|
|
29
|
+
*/
|
|
30
|
+
static getStaticDefaults(defaults = {}) {
|
|
31
|
+
const superDefaults = super.getStaticDefaults();
|
|
32
|
+
return _.merge({}, superDefaults, DateProperty.defaults, defaults);
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
/**
|
|
@@ -41,7 +50,7 @@ export default class DateProperty extends Property {
|
|
|
41
50
|
* @param {any} value
|
|
42
51
|
* @return {moment} parsedValue
|
|
43
52
|
*/
|
|
44
|
-
parse
|
|
53
|
+
parse(value) {
|
|
45
54
|
if (this.isDestroyed) {
|
|
46
55
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
47
56
|
}
|
|
@@ -61,32 +70,32 @@ export default class DateProperty extends Property {
|
|
|
61
70
|
return result;
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
getDisplayValue
|
|
73
|
+
getDisplayValue() {
|
|
65
74
|
if (this.isDestroyed) {
|
|
66
75
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
67
76
|
}
|
|
68
77
|
return Formatters.FormatDate(this.parsedValue, this.displayFormat);
|
|
69
78
|
}
|
|
70
79
|
|
|
71
|
-
getSubmitValue
|
|
80
|
+
getSubmitValue() {
|
|
72
81
|
if (this.isDestroyed) {
|
|
73
82
|
throw Error('this.getSubmitValue is no longer valid. Property has been destroyed.');
|
|
74
83
|
}
|
|
75
84
|
return Formatters.FormatDate(this.parsedValue, this.submitFormat);
|
|
76
85
|
}
|
|
77
86
|
|
|
78
|
-
getValueFormattedAs
|
|
87
|
+
getValueFormattedAs(format) {
|
|
79
88
|
if (this.isDestroyed) {
|
|
80
89
|
throw Error('this.getValueFormattedAs is no longer valid. Property has been destroyed.');
|
|
81
90
|
}
|
|
82
91
|
return Formatters.FormatDate(this.parsedValue, format);
|
|
83
92
|
}
|
|
84
93
|
|
|
85
|
-
getMoment
|
|
94
|
+
getMoment() {
|
|
86
95
|
return this.getParsedValue();
|
|
87
96
|
}
|
|
88
97
|
|
|
89
|
-
isToday
|
|
98
|
+
isToday() {
|
|
90
99
|
return this.getMoment().isSame(new Date(), 'day');
|
|
91
100
|
}
|
|
92
101
|
};
|
package/src/Property/DateTime.js
CHANGED
|
@@ -9,18 +9,27 @@ import _ from 'lodash';
|
|
|
9
9
|
*/
|
|
10
10
|
export default class DateTimeProperty extends DateProperty {
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
static defaults = {
|
|
13
|
+
readFormat: 'YYYY-MM-DDTHH:mm:ss', // ISO 8601
|
|
14
|
+
displayFormat: 'MMM DD, YYYY - HH:mm:ss',
|
|
15
|
+
submitFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
16
|
+
};
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
18
|
+
constructor(config = {}, entity) {
|
|
19
|
+
config = _.merge({}, DateTimeProperty.defaults, config);
|
|
20
|
+
super(config, entity);
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
25
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
26
|
+
* @returns {Object} The default configuration
|
|
27
|
+
*/
|
|
28
|
+
static getStaticDefaults(defaults = {}) {
|
|
29
|
+
const superDefaults = super.getStaticDefaults();
|
|
30
|
+
return _.merge({}, superDefaults, DateTimeProperty.defaults, defaults);
|
|
22
31
|
}
|
|
23
|
-
|
|
32
|
+
|
|
24
33
|
};
|
|
25
34
|
|
|
26
35
|
DateTimeProperty.className = 'DateTime';
|
package/src/Property/File.js
CHANGED
|
@@ -8,10 +8,6 @@ import _ from 'lodash';
|
|
|
8
8
|
* @extends Base64Property
|
|
9
9
|
*/
|
|
10
10
|
export default class FileProperty extends Base64Property {
|
|
11
|
-
constructor(config = {}) {
|
|
12
|
-
super(...arguments);
|
|
13
|
-
_.merge(this, config);
|
|
14
|
-
}
|
|
15
11
|
|
|
16
12
|
get urlencoded() {
|
|
17
13
|
return encodeURIComponent(this.displayValue);
|
package/src/Property/Float.js
CHANGED
|
@@ -10,18 +10,27 @@ import _ from 'lodash';
|
|
|
10
10
|
*/
|
|
11
11
|
export default class FloatProperty extends Property {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
13
|
+
static defaults = {
|
|
14
|
+
precision: 2,
|
|
15
|
+
// defaultValue: 0.00,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
constructor(config = {}, entity) {
|
|
19
|
+
config = _.merge({}, FloatProperty.defaults, config);
|
|
20
|
+
super(config, entity);
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
25
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
26
|
+
* @returns {Object} The default configuration
|
|
27
|
+
*/
|
|
28
|
+
static getStaticDefaults(defaults = {}) {
|
|
29
|
+
const superDefaults = super.getStaticDefaults();
|
|
30
|
+
return _.merge({}, superDefaults, FloatProperty.defaults, defaults);
|
|
22
31
|
}
|
|
23
32
|
|
|
24
|
-
setPrecision
|
|
33
|
+
setPrecision(precision) {
|
|
25
34
|
this.precision = precision;
|
|
26
35
|
this.parsedValue = this.parse(this.rawValue);
|
|
27
36
|
}
|
|
@@ -31,7 +40,7 @@ export default class FloatProperty extends Property {
|
|
|
31
40
|
* @param {any} value
|
|
32
41
|
* @return {string} parsedValue
|
|
33
42
|
*/
|
|
34
|
-
parse
|
|
43
|
+
parse(value) {
|
|
35
44
|
if (this.isDestroyed) {
|
|
36
45
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
37
46
|
}
|
package/src/Property/Integer.js
CHANGED
|
@@ -12,18 +12,27 @@ let lastId = 0;
|
|
|
12
12
|
*/
|
|
13
13
|
export default class IntegerProperty extends Property {
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
static defaults = {
|
|
16
|
+
// defaultValue: 0,
|
|
17
|
+
idStartsAt: 100 * 1000 * 1000 * 1000, // 100 billion
|
|
18
|
+
};
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
_.merge(this, defaults, config);
|
|
20
|
+
constructor(config = {}, entity) {
|
|
21
|
+
config = _.merge({}, IntegerProperty.defaults, config);
|
|
22
|
+
super(config, entity);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
27
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
28
|
+
* @returns {Object} The default configuration
|
|
29
|
+
*/
|
|
30
|
+
static getStaticDefaults(defaults = {}) {
|
|
31
|
+
const superDefaults = super.getStaticDefaults();
|
|
32
|
+
return _.merge({}, superDefaults, IntegerProperty.defaults, defaults);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
parse(value) {
|
|
27
36
|
if (this.isDestroyed) {
|
|
28
37
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
29
38
|
}
|
|
@@ -37,7 +46,7 @@ export default class IntegerProperty extends Property {
|
|
|
37
46
|
* Generates a new id
|
|
38
47
|
* Mainly for temporary, in-memory usage
|
|
39
48
|
*/
|
|
40
|
-
newId
|
|
49
|
+
newId() {
|
|
41
50
|
let id,
|
|
42
51
|
hasId = false;
|
|
43
52
|
|
package/src/Property/Json.js
CHANGED
|
@@ -26,21 +26,30 @@ import _ from 'lodash';
|
|
|
26
26
|
*/
|
|
27
27
|
export default class JsonProperty extends Property {
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
29
|
+
static defaults = {
|
|
30
|
+
submitAsString: true,
|
|
31
|
+
isSortable: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
constructor(config = {}, entity) {
|
|
35
|
+
config = _.merge({}, JsonProperty.defaults, config);
|
|
36
|
+
super(config, entity);
|
|
37
|
+
}
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
41
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
42
|
+
* @returns {Object} The default configuration
|
|
43
|
+
*/
|
|
44
|
+
static getStaticDefaults(defaults = {}) {
|
|
45
|
+
const superDefaults = super.getStaticDefaults();
|
|
46
|
+
return _.merge({}, superDefaults, JsonProperty.defaults, defaults);
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
/**
|
|
41
50
|
* Validates a JSON string
|
|
42
51
|
*/
|
|
43
|
-
isValid
|
|
52
|
+
isValid(value) {
|
|
44
53
|
try {
|
|
45
54
|
JSON.parse(value);
|
|
46
55
|
} catch (e) {
|
|
@@ -49,7 +58,7 @@ export default class JsonProperty extends Property {
|
|
|
49
58
|
return true;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
parse
|
|
61
|
+
parse(value) {
|
|
53
62
|
if (this.isDestroyed) {
|
|
54
63
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
55
64
|
}
|
|
@@ -71,7 +80,7 @@ export default class JsonProperty extends Property {
|
|
|
71
80
|
return ret;
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
getDisplayValue
|
|
83
|
+
getDisplayValue() {
|
|
75
84
|
if (this.isDestroyed) {
|
|
76
85
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
77
86
|
}
|
|
@@ -88,7 +97,7 @@ export default class JsonProperty extends Property {
|
|
|
88
97
|
return this.parsedValue;
|
|
89
98
|
}
|
|
90
99
|
|
|
91
|
-
getSubmitValue
|
|
100
|
+
getSubmitValue() {
|
|
92
101
|
if (this.isDestroyed) {
|
|
93
102
|
throw Error('this.getSubmitValue is no longer valid. Property has been destroyed.');
|
|
94
103
|
}
|
|
@@ -107,7 +116,7 @@ export default class JsonProperty extends Property {
|
|
|
107
116
|
* Utility function - gets the JSON string in a way that is safe to display in HTML.
|
|
108
117
|
* i.e. It enables us to show a JSON string in HTML *without its contents being interpreted as HTML*
|
|
109
118
|
*/
|
|
110
|
-
getAsHtmlSafe
|
|
119
|
+
getAsHtmlSafe() {
|
|
111
120
|
const str = JSON.stringify(this.parsedValue);
|
|
112
121
|
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
113
122
|
}
|
package/src/Property/Percent.js
CHANGED
|
@@ -11,7 +11,7 @@ import _ from 'lodash';
|
|
|
11
11
|
*/
|
|
12
12
|
export default class PercentProperty extends PercentIntProperty {
|
|
13
13
|
|
|
14
|
-
parse
|
|
14
|
+
parse(value) {
|
|
15
15
|
if (this.isDestroyed) {
|
|
16
16
|
throw Error('this.parse is no longer valid. Property has been destroyed.');
|
|
17
17
|
}
|
|
@@ -29,7 +29,7 @@ export default class PercentProperty extends PercentIntProperty {
|
|
|
29
29
|
return parsed;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
getDisplayValue
|
|
32
|
+
getDisplayValue() {
|
|
33
33
|
if (this.isDestroyed) {
|
|
34
34
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
35
35
|
}
|
|
@@ -10,17 +10,26 @@ import _ from 'lodash';
|
|
|
10
10
|
*/
|
|
11
11
|
export default class PercentIntProperty extends FloatProperty {
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
static defaults = {
|
|
14
|
+
omitZeros: false, // Should we omit any .00 at the end?
|
|
15
|
+
};
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
constructor(config = {}, entity) {
|
|
18
|
+
config = _.merge({}, PercentIntProperty.defaults, config);
|
|
19
|
+
super(config, entity);
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Returns the default configuration for this PropertyType, going up the hierarchy.
|
|
24
|
+
* @param {Object} defaults - The default configuration to merge with
|
|
25
|
+
* @returns {Object} The default configuration
|
|
26
|
+
*/
|
|
27
|
+
static getStaticDefaults(defaults = {}) {
|
|
28
|
+
const superDefaults = super.getStaticDefaults();
|
|
29
|
+
return _.merge({}, superDefaults, PercentIntProperty.defaults, defaults);
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
getDisplayValue
|
|
32
|
+
getDisplayValue() {
|
|
24
33
|
if (this.isDestroyed) {
|
|
25
34
|
throw Error('this.getDisplayValue is no longer valid. Property has been destroyed.');
|
|
26
35
|
}
|