@onehat/data 1.20.8 → 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 +25 -18
- 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 +35 -30
- 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 +37 -31
- package/src/Repository/OneBuild2.js +19 -13
- package/src/Repository/Repository.js +106 -103
- package/src/Schema/Schema.js +9 -6
package/src/Schema/Schema.js
CHANGED
|
@@ -274,6 +274,12 @@ export default class Schema extends EventEmitter {
|
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
// In here, we're looking for default values for each property
|
|
278
|
+
// based entirely on the property definition or property type.
|
|
279
|
+
// The property has not been intantiatiated in either case,
|
|
280
|
+
// so we don't have access to the entity's data.
|
|
281
|
+
// Unfortunately, defaults get applied at instantiation time...
|
|
282
|
+
|
|
277
283
|
const found = {};
|
|
278
284
|
_.each(this.model.properties, (property) => {
|
|
279
285
|
let defaultValue = null;
|
|
@@ -282,14 +288,11 @@ export default class Schema extends EventEmitter {
|
|
|
282
288
|
} else {
|
|
283
289
|
// Look in the property types for a default value
|
|
284
290
|
let propertyType = PropertyTypes[property.type];
|
|
285
|
-
if (!
|
|
286
|
-
defaultValue = propertyType.defaultValue;
|
|
287
|
-
} else {
|
|
291
|
+
if (!propertyType) {
|
|
288
292
|
propertyType = PropertyTypes['string'];
|
|
289
|
-
if (!_.isNil(propertyType.defaultValue)) {
|
|
290
|
-
defaultValue = propertyType.defaultValue;
|
|
291
|
-
}
|
|
292
293
|
}
|
|
294
|
+
const staticDefaults = propertyType.getStaticDefaults();
|
|
295
|
+
defaultValue = staticDefaults.defaultValue;
|
|
293
296
|
}
|
|
294
297
|
if (_.isFunction(defaultValue)) {
|
|
295
298
|
defaultValue = defaultValue();
|