From 5ed1631a3526ffce25af7b5be14cee102165aab3 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 19 Jun 2022 12:18:13 +0200 Subject: [PATCH] resort attributes for display --- src/public/app/entities/note_short.js | 7 ++++++- .../app/widgets/attribute_widgets/attribute_editor.js | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index 8d2fc8e25..138a388ab 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -640,13 +640,18 @@ class NoteShort { return []; } - return this.getAttributes() + const promotedAttrs = this.getAttributes() .filter(attr => attr.isDefinition()) .filter(attr => { const def = attr.getDefinition(); return def && def.isPromoted; }); + + // attrs are not resorted if position changes after initial load + promotedAttrs.sort((a, b) => a.position < b.position ? -1 : 1); + + return promotedAttrs; } hasAncestor(ancestorNoteId, visitedNoteIds = null) { diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.js index c140e0139..bbc27fe4f 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js @@ -468,6 +468,8 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget { async renderOwnedAttributes(ownedAttributes, saved) { ownedAttributes = ownedAttributes.filter(oa => !oa.isDeleted); + // attrs are not resorted if position changes after initial load + ownedAttributes.sort((a, b) => a.position < b.position ? -1 : 1); let htmlAttrs = (await attributeRenderer.renderAttributes(ownedAttributes, true)).html();