From 0a06d05bdd2209e2d90c9f8c4f87af2ec884f7a4 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Tue, 5 Feb 2019 10:02:10 +0100 Subject: [PATCH] sort 'previous/next motion' by identifier in detail view --- .../motion-detail/motion-detail.component.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts index 520e754f5..6989fa403 100644 --- a/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/components/motion-detail/motion-detail.component.ts @@ -976,9 +976,21 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { } /** - * Sets the previous and next motion + * Sets the previous and next motion. Sorts ascending by identifier, and + * then appending motion without identifiers sorted by title */ public setSurroundingMotions(): void { + this.allMotions.sort((a, b) => { + if (a.identifier && b.identifier) { + return a.identifier.localeCompare(b.identifier, this.translate.currentLang); + } else if (a.identifier) { + return 1; + } else if (b.identifier) { + return -1; + } else { + return a.title.localeCompare(b.title, this.translate.currentLang); + } + }); const indexOfCurrent = this.allMotions.findIndex(motion => { return motion === this.motion; });