From 11c565282fe6c205ec31fe5f255ff297122153c9 Mon Sep 17 00:00:00 2001 From: GabrielMeyer Date: Tue, 7 May 2019 12:13:18 +0200 Subject: [PATCH] Fixes the listing of motions in a category - Sorting by motion.category_weight --- .../category-list/category-list.component.html | 2 +- .../category-list/category-list.component.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/motions/modules/category/components/category-list/category-list.component.html b/client/src/app/site/motions/modules/category/components/category-list/category-list.component.html index 29e9e5256..e7818d7dc 100644 --- a/client/src/app/site/motions/modules/category/components/category-list/category-list.component.html +++ b/client/src/app/site/motions/modules/category/components/category-list/category-list.component.html @@ -122,7 +122,7 @@
Motions:
-
    +
    • {{ motion.getListTitle() }}
diff --git a/client/src/app/site/motions/modules/category/components/category-list/category-list.component.ts b/client/src/app/site/motions/modules/category/components/category-list/category-list.component.ts index 6a9bbfe3a..f51aa36bc 100644 --- a/client/src/app/site/motions/modules/category/components/category-list/category-list.component.ts +++ b/client/src/app/site/motions/modules/category/components/category-list/category-list.component.ts @@ -190,6 +190,18 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit { return this.motionRepo.getSortedViewModelList().filter(m => m.category_id === category.id); } + /** + * Function to get a sorted list of all motions in a specific category. + * Sorting by `category_weight`. + * + * @param category the target category in where the motions are. + * + * @returns all motions in the given category sorted by their category_weight. + */ + public getSortedMotionListInCategory(category: Category): ViewMotion[] { + return this.motionsInCategory(category).sort((a, b) => a.category_weight - b.category_weight); + } + /** * Fetch the correct URL for a detail sort view *