Skip to content

Commit

Permalink
Sort properties and actions before layout. (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstegeman authored Feb 13, 2020
1 parent 238783b commit ab8bb0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions static/js/schema-impl/capability/thing.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ class Thing {
* HTML view for Thing.
*/
attachExpandedView() {
for (const prop of Object.values(this.displayedProperties)) {
// Note: the UI will not show them in actual sorted order around the hub.
// However, sorting here will at least make it draw them in a consistent
// position each time.
const props = Array.from(Object.values(this.displayedProperties))
.sort((a, b) => a.detail.label.localeCompare(b.detail.label));
for (const prop of props) {
// only attach the first time.
if ((!prop.hasOwnProperty('attached') || !prop.attached) &&
prop.hasOwnProperty('detail')) {
Expand All @@ -379,7 +384,9 @@ class Thing {
}
}

for (const action of Object.values(this.displayedActions)) {
const actions = Array.from(Object.values(this.displayedActions))
.sort((a, b) => a.detail.label.localeCompare(b.detail.label));
for (const action of actions) {
// only attach the first time.
if ((!action.hasOwnProperty('attached') || !action.attached) &&
action.hasOwnProperty('detail')) {
Expand Down

0 comments on commit ab8bb0d

Please sign in to comment.