Separate out object name checking from the sorting function (#4677)

This commit is contained in:
Khalid Adil
2022-02-09 11:59:56 -06:00
committed by GitHub
parent 22604220de
commit ce98c10145

View File

@ -480,32 +480,36 @@ export default {
return scrollTopAmount >= treeStart && scrollTopAmount < treeEnd; return scrollTopAmount >= treeStart && scrollTopAmount < treeEnd;
}, },
sortNameAscending(a, b) { getLowercaseObjectName(domainObject) {
// sorting tree children items let objectName;
if (!(a.name && b.name)) { if (!domainObject) {
if (a.object.name.toLowerCase() return objectName;
> b.object.name.toLowerCase()) {
return 1;
}
if (b.object.name.toLowerCase()
> a.object.name.toLowerCase()) {
return -1;
}
} }
// sorting composition items if (domainObject.name) {
if (!a.name || !b.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; return 0;
} }
if (a.name.toLowerCase() // sorting composition items
> b.name.toLowerCase()) { if (objectAName > objectBName) {
return 1; return 1;
} }
if (b.name.toLowerCase() if (objectBName > objectAName) {
> a.name.toLowerCase()) {
return -1; return -1;
} }