@onehat/data 1.22.28 → 1.22.30
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/Property/Mixed.js
CHANGED
|
@@ -21,7 +21,7 @@ import _ from 'lodash';
|
|
|
21
21
|
* Class represents a Property that can store values of multiple types.
|
|
22
22
|
* The actual type is determined dynamically based on the value being set.
|
|
23
23
|
*
|
|
24
|
-
* Usage: { name: 'date', title: 'Date', types: ['date', 'string'], },
|
|
24
|
+
* Usage: { name: 'date', title: 'Date', type: 'mixed', types: ['date', 'string'], },
|
|
25
25
|
* This is primarily used to allow a field that's normally one PropertyType
|
|
26
26
|
* to also accept string values (e.g. values like '2025-01-01' or 'N/A').
|
|
27
27
|
*
|
|
@@ -402,6 +402,56 @@ export default class MixedProperty extends EventEmitter {
|
|
|
402
402
|
this.internalProperties.forEach((property) => property.destroy());
|
|
403
403
|
this.internalProperties.clear();
|
|
404
404
|
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Returns the default configuration for this PropertyType.
|
|
408
|
+
* For MixedProperty, this delegates to the first configured type's defaults.
|
|
409
|
+
* @param {Object} defaults - The default configuration to merge with (should include 'types' array)
|
|
410
|
+
* @returns {Object} The default configuration
|
|
411
|
+
*/
|
|
412
|
+
static getStaticDefaults(defaults = {}) {
|
|
413
|
+
const mixedPropertyDefaults = {
|
|
414
|
+
name: null,
|
|
415
|
+
allowNull: true,
|
|
416
|
+
depends: null,
|
|
417
|
+
mapping: null,
|
|
418
|
+
submitAsString: false,
|
|
419
|
+
isSortable: true,
|
|
420
|
+
isTempId: false,
|
|
421
|
+
isVirtual: false,
|
|
422
|
+
title: null,
|
|
423
|
+
tooltip: null,
|
|
424
|
+
fieldGroup: null,
|
|
425
|
+
isForeignModel: false,
|
|
426
|
+
filterType: null,
|
|
427
|
+
isFilteringDisabled: false,
|
|
428
|
+
viewerType: null,
|
|
429
|
+
editorType: null,
|
|
430
|
+
isEditingDisabled: false,
|
|
431
|
+
defaultValue: null,
|
|
432
|
+
formatter: null,
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// If types are configured, use the first type's default value
|
|
436
|
+
if (defaults.types && Array.isArray(defaults.types) && defaults.types.length > 0) {
|
|
437
|
+
const
|
|
438
|
+
firstTypeConfig = defaults.types[0],
|
|
439
|
+
firstTypeName = typeof firstTypeConfig === 'string' ? firstTypeConfig : firstTypeConfig.type;
|
|
440
|
+
if (firstTypeName) {
|
|
441
|
+
try {
|
|
442
|
+
const PropertyClass = MixedProperty.prototype._getPropertyClass(firstTypeName);
|
|
443
|
+
const typeDefaults = PropertyClass.getStaticDefaults ? PropertyClass.getStaticDefaults() : {};
|
|
444
|
+
if (typeDefaults.defaultValue !== undefined) {
|
|
445
|
+
mixedPropertyDefaults.defaultValue = typeDefaults.defaultValue;
|
|
446
|
+
}
|
|
447
|
+
} catch (e) {
|
|
448
|
+
// If we can't get the property class, just use null default
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return _.merge({}, mixedPropertyDefaults, defaults);
|
|
454
|
+
}
|
|
405
455
|
}
|
|
406
456
|
|
|
407
457
|
MixedProperty.className = 'Mixed';
|
package/src/Repository/Ajax.js
CHANGED
|
@@ -480,7 +480,7 @@ class AjaxRepository extends Repository {
|
|
|
480
480
|
const
|
|
481
481
|
currentEntityCount = this.entities.length,
|
|
482
482
|
newPageSize = this.pageSize;
|
|
483
|
-
if (this.page === 1 && currentEntityCount >= newPageSize && this.isPaginated) {
|
|
483
|
+
if (this.previousPage === 1 && this.page === 1 && currentEntityCount >= newPageSize && this.isPaginated) {
|
|
484
484
|
// Optimization: if we're on page 1 and already have enough entities
|
|
485
485
|
// for the new page size, just truncate the existing data instead of reloading
|
|
486
486
|
const entitiesToRemove = this.entities.splice(newPageSize);
|
|
@@ -491,7 +491,7 @@ class AjaxRepository extends Repository {
|
|
|
491
491
|
console.log(`Truncated entities from ${currentEntityCount} to ${newPageSize}`);
|
|
492
492
|
}
|
|
493
493
|
} else {
|
|
494
|
-
// We need more data or
|
|
494
|
+
// We need more data or weren't already on page 1, so reload
|
|
495
495
|
return this.reload();
|
|
496
496
|
}
|
|
497
497
|
}
|
|
@@ -190,6 +190,11 @@ export default class Repository extends EventEmitter {
|
|
|
190
190
|
*/
|
|
191
191
|
this.page = 1;
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @member {number} previousPage - State: Previous page number in pagination
|
|
195
|
+
*/
|
|
196
|
+
this.previousPage = null;
|
|
197
|
+
|
|
193
198
|
/**
|
|
194
199
|
* Getter for
|
|
195
200
|
* @member {number} pageTotal - State: Total number of entities on the current page
|
|
@@ -940,6 +945,8 @@ export default class Repository extends EventEmitter {
|
|
|
940
945
|
return false;
|
|
941
946
|
}
|
|
942
947
|
|
|
948
|
+
this.previousPage = this.page;
|
|
949
|
+
|
|
943
950
|
// Reset to page 1 (don't use setPage(), so we can skip _onChangePagination, which we'll do later)
|
|
944
951
|
this.page = 1;
|
|
945
952
|
this.emit('changePage');
|
|
@@ -975,6 +982,7 @@ export default class Repository extends EventEmitter {
|
|
|
975
982
|
return false;
|
|
976
983
|
}
|
|
977
984
|
|
|
985
|
+
this.previousPage = this.page;
|
|
978
986
|
this.page = page;
|
|
979
987
|
this.emit('changePage');
|
|
980
988
|
if (this._onChangePagination) {
|
package/src/Schema/Schema.js
CHANGED
|
@@ -286,7 +286,9 @@ export default class Schema extends EventEmitter {
|
|
|
286
286
|
if (!propertyType) {
|
|
287
287
|
propertyType = PropertyTypes['string'];
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
// Pass the property definition to getStaticDefaults for types like 'mixed'
|
|
290
|
+
// that need access to the configuration (e.g., the types array)
|
|
291
|
+
const staticDefaults = propertyType.getStaticDefaults(property);
|
|
290
292
|
defaultValue = staticDefaults.defaultValue;
|
|
291
293
|
}
|
|
292
294
|
if (_.isFunction(defaultValue)) {
|