From 530dcf490a059c841e4beb28b50c1d9afafa9cd1 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Tue, 16 Jul 2019 10:48:48 +0200 Subject: [PATCH] Enhance subcategories - show parents over children in motion list, motion detail and PDF - indent children of categories in the filter list --- .../ui-services/base-filter-list.service.ts | 14 +++++++-- .../icon-container.component.scss | 1 + .../filter-menu/filter-menu.component.html | 2 +- .../filter-menu/filter-menu.component.scss | 4 +++ .../app/site/motions/models/view-category.ts | 11 +++++++ .../motion-detail.component.html | 16 +++++++--- .../motion-list/motion-list.component.html | 31 +------------------ .../motions/services/motion-pdf.service.ts | 10 +++++- client/src/styles.scss | 4 +++ 9 files changed, 54 insertions(+), 39 deletions(-) diff --git a/client/src/app/core/ui-services/base-filter-list.service.ts b/client/src/app/core/ui-services/base-filter-list.service.ts index b9333dc07..e467bf520 100644 --- a/client/src/app/core/ui-services/base-filter-list.service.ts +++ b/client/src/app/core/ui-services/base-filter-list.service.ts @@ -36,6 +36,7 @@ export interface OsFilterOption { label: string; condition: OsFilterOptionCondition; isActive?: boolean; + isChild?: boolean; } /** @@ -46,6 +47,14 @@ export interface OsFilterIndicator { option: OsFilterOption; } +/** + * Extends the BaseViewModel with a parent + * Required to represent parent-child relationships in the filter + */ +interface HierarchyModel extends BaseViewModel { + parent: BaseViewModel; +} + /** * Define the type of a filter condition */ @@ -266,10 +275,11 @@ export abstract class BaseFilterListService { filterProperties = viewModel .filter(model => (excludeIds && excludeIds.length ? !excludeIds.includes(model.id) : true)) - .map(model => { + .map((model: HierarchyModel) => { return { condition: model.id, - label: model.getTitle() + label: model.getTitle(), + isChild: !!model.parent }; }); diff --git a/client/src/app/shared/components/icon-container/icon-container.component.scss b/client/src/app/shared/components/icon-container/icon-container.component.scss index d52dfe256..1b350f70a 100644 --- a/client/src/app/shared/components/icon-container/icon-container.component.scss +++ b/client/src/app/shared/components/icon-container/icon-container.component.scss @@ -37,5 +37,6 @@ os-icon-container { margin: auto 5px; text-overflow: ellipsis; overflow: hidden; + white-space: pre-line; } } diff --git a/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.html b/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.html index 0bb9ef514..b0b42612d 100644 --- a/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.html +++ b/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.html @@ -14,7 +14,7 @@
diff --git a/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.scss b/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.scss index 6f3d99f0b..191b24a66 100644 --- a/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.scss +++ b/client/src/app/shared/components/sort-filter-bar/filter-menu/filter-menu.component.scss @@ -28,6 +28,10 @@ mat-divider { font-style: italic; } +.filter-child { + margin-left: 20px; +} + // adds breaks to mat-checkboxes with long labels ::ng-deep .mat-checkbox-layout { white-space: normal !important; diff --git a/client/src/app/site/motions/models/view-category.ts b/client/src/app/site/motions/models/view-category.ts index bb05bd70a..9ba876c60 100644 --- a/client/src/app/site/motions/models/view-category.ts +++ b/client/src/app/site/motions/models/view-category.ts @@ -64,6 +64,17 @@ export class ViewCategory extends BaseViewModel implements CategoryTit return name; } + /** + * Shows the (direct) parent above the current category + */ + public get nameWithParentAbove(): string { + if (this.parent) { + return `${this.parent.toString()}\n${this.toString()}`; + } else { + return this.toString(); + } + } + public constructor(category: Category, parent?: ViewCategory) { super(Category.COLLECTIONSTRING, category); this._parent = parent; diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html index 85a4b2cb8..3ea4bdd03 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.html @@ -152,9 +152,7 @@ - - Sequential number {{ motion.id }} - + Sequential number {{ motion.id }} ·  @@ -345,10 +343,18 @@ - {{ motion.category ? motion.category.prefixedNameWithParents : '–' }} +
+
+ {{ motion.category.parent }} +
+ {{ 'Subcategory' | translate }}: + {{ motion.category }} +
+ + -
- - - State - -
-
-
- - {{ motion.category.prefixedNameWithParents }} - -
-
- - {{ motion.motion_block.title }} - -
-
- - - {{ tag.getTitle() }} - - - -
-
-
-
-
-
@@ -163,7 +134,7 @@
- {{ motion.category.prefixedNameWithParents }} + {{ motion.category.nameWithParentAbove }}
diff --git a/client/src/app/site/motions/services/motion-pdf.service.ts b/client/src/app/site/motions/services/motion-pdf.service.ts index 66ccd00f6..ba547970b 100644 --- a/client/src/app/site/motions/services/motion-pdf.service.ts +++ b/client/src/app/site/motions/services/motion-pdf.service.ts @@ -310,13 +310,21 @@ export class MotionPdfService { // category if (motion.category && (!infoToExport || infoToExport.includes('category'))) { + let categoryText = ''; + if (!!motion.category.parent) { + categoryText = `${motion.category.parent.toString()}\n${this.translate.instant( + 'Subcategory' + )}: ${motion.category.toString()}`; + } else { + categoryText = motion.category.toString(); + } metaTableBody.push([ { text: `${this.translate.instant('Category')}:`, style: 'boldText' }, { - text: motion.category.prefixedNameWithParents + text: categoryText } ]); } diff --git a/client/src/styles.scss b/client/src/styles.scss index e093c9462..076bbcdf8 100644 --- a/client/src/styles.scss +++ b/client/src/styles.scss @@ -732,6 +732,10 @@ button.mat-menu-item.selected { color: rgba(0, 0, 0, 0.87) !important; } +.multi-line-chip { + white-space: pre-line +} + /* TODO: move to site.component.scss-theme.scss (does not work currently) */ /* make the .user-menu expansion panel look like the nav-toolbar above */