mirror of
https://github.com/nasa/openmct.git
synced 2025-04-11 05:10:21 +00:00
Separate out object name checking from the sorting function (#4677)
This commit is contained in:
parent
22604220de
commit
ce98c10145
@ -480,32 +480,36 @@ export default {
|
||||
|
||||
return scrollTopAmount >= treeStart && scrollTopAmount < treeEnd;
|
||||
},
|
||||
sortNameAscending(a, b) {
|
||||
// sorting tree children items
|
||||
if (!(a.name && b.name)) {
|
||||
if (a.object.name.toLowerCase()
|
||||
> b.object.name.toLowerCase()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (b.object.name.toLowerCase()
|
||||
> a.object.name.toLowerCase()) {
|
||||
return -1;
|
||||
}
|
||||
getLowercaseObjectName(domainObject) {
|
||||
let objectName;
|
||||
if (!domainObject) {
|
||||
return objectName;
|
||||
}
|
||||
|
||||
// sorting composition items
|
||||
if (!a.name || !b.name) {
|
||||
if (domainObject.name) {
|
||||
objectName = domainObject.name.toLowerCase();
|
||||
}
|
||||
|
||||
if (domainObject.object && domainObject.object.name) {
|
||||
objectName = domainObject.object.name.toLowerCase();
|
||||
}
|
||||
|
||||
return objectName;
|
||||
},
|
||||
sortNameAscending(a, b) {
|
||||
// sorting tree children items
|
||||
let objectAName = this.getLowercaseObjectName(a);
|
||||
let objectBName = this.getLowercaseObjectName(b);
|
||||
if (!objectAName || !objectBName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a.name.toLowerCase()
|
||||
> b.name.toLowerCase()) {
|
||||
// sorting composition items
|
||||
if (objectAName > objectBName) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (b.name.toLowerCase()
|
||||
> a.name.toLowerCase()) {
|
||||
if (objectBName > objectAName) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user