Merge pull request #4255 from MaximilianKrambach/motionNavigation

sort 'previous/next motion' by identifier in detail view
This commit is contained in:
Emanuel Schütze 2019-02-05 14:48:17 +01:00 committed by GitHub
commit 2ef3b6929f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
});