From d739b982bbcaa3b558282b297be39080ba0077b4 Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Tue, 20 Aug 2019 12:42:50 +0200 Subject: [PATCH] Overwork motion detail UI set Default action to "create amendment" (if permitted) put edit in the menu put next and prev motion in the menu (mobile) resort motion menu move "show enitre motion text" under the motion-preview change "show entire motion text" from button to checkbox create a custom tooltip for the main action in os-head-bar create a custom "cancel edit" function in os-head-bar overwork location.back logic --- .../core/ui-services/routing-state.service.ts | 20 ++-- .../head-bar/head-bar.component.html | 21 ++-- .../components/head-bar/head-bar.component.ts | 23 ++++- .../speaker-button.component.html | 4 + .../amendment-create-wizard.component.html | 2 +- .../manage-submitters.component.html | 2 +- .../manage-submitters.component.scss | 8 ++ .../motion-detail.component.html | 95 +++++++++---------- .../motion-detail.component.scss | 5 + client/src/styles.scss | 7 -- 10 files changed, 107 insertions(+), 80 deletions(-) diff --git a/client/src/app/core/ui-services/routing-state.service.ts b/client/src/app/core/ui-services/routing-state.service.ts index 7bb2d5a5d..320209b2f 100644 --- a/client/src/app/core/ui-services/routing-state.service.ts +++ b/client/src/app/core/ui-services/routing-state.service.ts @@ -1,3 +1,4 @@ +import { Location } from '@angular/common'; import { Injectable } from '@angular/core'; import { Router, RoutesRecognized } from '@angular/router'; @@ -14,7 +15,7 @@ export class RoutingStateService { /** * Hold the previous URL */ - private _previousUrl: string; + private previousUrl: string; /** * Unsafe paths that the user should not go "back" to @@ -23,14 +24,11 @@ export class RoutingStateService { private unsafeUrls: string[] = ['/login', '/privacypolicy', '/legalnotice']; /** - * @return Get the previous URL + * Checks if the previous URL is safe to navigate to. + * If this fails, the open nav button should be shown */ - public get previousUrl(): string { - return this._previousUrl ? this._previousUrl : null; - } - public get isSafePrevUrl(): boolean { - return !!this.previousUrl && !this.unsafeUrls.includes(this.previousUrl); + return !this.previousUrl || !this.unsafeUrls.includes(this.previousUrl); } /** @@ -38,14 +36,18 @@ export class RoutingStateService { * * @param router Angular Router */ - public constructor(private router: Router) { + public constructor(private router: Router, private location: Location) { this.router.events .pipe( filter(e => e instanceof RoutesRecognized), pairwise() ) .subscribe((event: any[]) => { - this._previousUrl = event[0].urlAfterRedirects; + this.previousUrl = event[0].urlAfterRedirects; }); } + + public goBack(): void { + this.location.back(); + } } diff --git a/client/src/app/shared/components/head-bar/head-bar.component.html b/client/src/app/shared/components/head-bar/head-bar.component.html index 442df3bb1..fb0ca493c 100644 --- a/client/src/app/shared/components/head-bar/head-bar.component.html +++ b/client/src/app/shared/components/head-bar/head-bar.component.html @@ -11,7 +11,7 @@ - @@ -35,21 +35,17 @@ - - + @@ -60,9 +56,10 @@ diff --git a/client/src/app/shared/components/head-bar/head-bar.component.ts b/client/src/app/shared/components/head-bar/head-bar.component.ts index f644bbc54..54fdd4d2d 100644 --- a/client/src/app/shared/components/head-bar/head-bar.component.ts +++ b/client/src/app/shared/components/head-bar/head-bar.component.ts @@ -63,7 +63,7 @@ export class HeadBarComponent { * Custom icon if necessary */ @Input() - public mainButtonIcon = 'add'; + public mainButtonIcon = 'add_circle'; /** * Determine edit mode @@ -105,12 +105,24 @@ export class HeadBarComponent { @Input() public prevUrl = '../'; + /** + * Optional tooltip for the main action + */ + @Input() + public mainActionTooltip: string; + /** * Emit a signal to the parent component if the main button was clicked */ @Output() public mainEvent = new EventEmitter(); + /** + * Optional custom event for cancel the edit + */ + @Output() + public cancelEditEvent = new EventEmitter(); + /** * Sends a signal if a detail view should be saved */ @@ -139,6 +151,13 @@ export class HeadBarComponent { this.mainEvent.next(); } + /** + * Emits a signal to for custom cancel edits + */ + public sendCancelEditEvent(): void { + this.cancelEditEvent.next(); + } + /** * Clicking the burger-menu-icon should toggle the menu */ @@ -159,7 +178,7 @@ export class HeadBarComponent { */ public onBackButton(): void { if (this.goBack) { - this.router.navigateByUrl(this.routingState.previousUrl); + this.routingState.goBack(); } else { this.router.navigate([this.prevUrl], { relativeTo: this.route }); } diff --git a/client/src/app/shared/components/speaker-button/speaker-button.component.html b/client/src/app/shared/components/speaker-button/speaker-button.component.html index e4b92c517..74cc4befa 100644 --- a/client/src/app/shared/components/speaker-button/speaker-button.component.html +++ b/client/src/app/shared/components/speaker-button/speaker-button.component.html @@ -14,6 +14,10 @@ diff --git a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html index d801bbe76..398c5052b 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/amendment-create-wizard/amendment-create-wizard.component.html @@ -1,4 +1,4 @@ - +

New amendment