From caed18ef03e39f025e5526bbc5a907eae6cb0380 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Mon, 21 Jan 2019 16:34:19 +0100 Subject: [PATCH] set/read state+recommendation extensions --- .../shared/models/motions/workflow-state.ts | 2 +- .../motion-block-detail.component.html | 8 +- .../motion-block-detail.component.ts | 31 ++++++- .../motion-detail.component.html | 76 +++++++++-------- .../motion-detail/motion-detail.component.ts | 42 ++++++++++ .../motion-list/motion-list.component.html | 44 ++++++---- .../motion-list/motion-list.component.ts | 22 +++++ .../app/site/motions/models/view-motion.ts | 22 +++++ .../motions/services/motion-pdf.service.ts | 4 +- .../services/motion-repository.service.ts | 84 ++++++++++++++++++- 10 files changed, 270 insertions(+), 65 deletions(-) diff --git a/client/src/app/shared/models/motions/workflow-state.ts b/client/src/app/shared/models/motions/workflow-state.ts index 45b7e2772..fdf334298 100644 --- a/client/src/app/shared/models/motions/workflow-state.ts +++ b/client/src/app/shared/models/motions/workflow-state.ts @@ -26,7 +26,7 @@ export class WorkflowState extends Deserializer { public allow_create_poll: boolean; public allow_submitter_edit: boolean; public dont_set_identifier: boolean; - public show_state_extension_field: number; + public show_state_extension_field: boolean; public merge_amendment_into_final: MergeAmendment; public show_recommendation_extension_field: boolean; public next_states_id: number[]; diff --git a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html index c556c4897..a12024798 100644 --- a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html +++ b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.html @@ -62,7 +62,7 @@ lightblue: motion.state.css_class === 'primary' }" > - {{ motion.state.name | translate }} + {{ getStateLabel(motion) }} @@ -72,11 +72,7 @@ Recommendation - {{ - motion.recommendation - ? (motion.recommendation.recommendation_label | translate) - : ('not set' | translate) - }} + {{ getRecommendationLabel(motion) }} diff --git a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.ts b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.ts index faef863e4..bb6cc47f4 100644 --- a/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.ts +++ b/client/src/app/site/motions/components/motion-block-detail/motion-block-detail.component.ts @@ -1,17 +1,18 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { FormGroup, FormControl, Validators } from '@angular/forms'; -import { Title } from '@angular/platform-browser'; import { MatSnackBar } from '@angular/material'; +import { Title } from '@angular/platform-browser'; import { TranslateService } from '@ngx-translate/core'; import { ListViewBaseComponent } from 'app/site/base/list-view-base'; -import { MotionBlockRepositoryService } from '../../services/motion-block-repository.service'; import { MotionBlock } from 'app/shared/models/motions/motion-block'; +import { MotionBlockRepositoryService } from '../../services/motion-block-repository.service'; +import { MotionRepositoryService } from '../../services/motion-repository.service'; import { ViewMotionBlock } from '../../models/view-motion-block'; -import { ViewMotion } from '../../models/view-motion'; import { PromptService } from 'app/core/services/prompt.service'; +import { ViewMotion } from '../../models/view-motion'; /** * Detail component to display one motion block @@ -52,6 +53,7 @@ export class MotionBlockDetailComponent extends ListViewBaseComponent - - {{ motion.state.name | translate }} - - - {{ motion.state.name | translate }} - +
+ + {{ stateLabel }} + +
+ + + + +
+
+
+ + {{ stateLabel }} + +
@@ -251,6 +258,7 @@ (click)="setRecommendation(recommendation.id)" > {{ recommendation.recommendation_label | translate }} +  ... - - {{ - motion.recommendation - ? (motion.recommendation.recommendation_label | translate) - : ('not set' | translate) - }} - - - {{ - motion.recommendation - ? (motion.recommendation.recommendation_label | translate) - : ('not set' | translate) - }} - - +
+ + {{ recommendationLabel }} + +
+ + + + +
+
+
+ + {{ recommendationLabel }} + +
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 5ac67ffc1..74a662dbc 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 @@ -114,6 +114,20 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { return false; } + /** + * @returns the current recommendation label (with extension) + */ + public get recommendationLabel(): string { + return this.repo.getExtendedRecommendationLabel(this.motion); + } + + /** + * @returns the current state label (with extension) + */ + public get stateLabel(): string { + return this.repo.getExtendedStateLabel(this.motion); + } + /** * Saves the target motion. Accessed via the getter and setter. */ @@ -286,6 +300,16 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { */ public personalNoteContent: PersonalNoteContent; + /** + * new state extension label to be submitted, if state extensions can be set + */ + public newStateExtension = ''; + + /** + * new recommendation extension label to be submitted, if recommendation extensions can be set + */ + public newRecommendationExtension = ''; + /** * Constuct the detail view. * @@ -460,6 +484,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { this.repo.getViewModelObservable(motionId).subscribe(newViewMotion => { if (newViewMotion) { this.motion = newViewMotion; + this.newStateExtension = this.motion.stateExtension; + this.newRecommendationExtension = this.motion.recommendationExtension; this.personalNoteService.getPersonalNoteObserver(this.motion.motion).subscribe(pn => { this.personalNoteContent = pn; }); @@ -906,6 +932,14 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { this.repo.setState(this.motion, id); } + /** + * triggers the update this motion's state extension according to the current string + * in {@link newStateExtension} + */ + public setStateExtension(): void { + this.repo.setStateExtension(this.motion, this.newStateExtension); + } + /** * Sets the recommendation * @@ -915,6 +949,14 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit { this.repo.setRecommendation(this.motion, id); } + /** + * triggers the update this motion's recommendation extension according to the current string + * in {@link newRecommendationExtension} + */ + public setRecommendationExtension(): void { + this.repo.setRecommendationExtension(this.motion, this.newRecommendationExtension); + } + /** * Sets the category for current motion * diff --git a/client/src/app/site/motions/components/motion-list/motion-list.component.html b/client/src/app/site/motions/components/motion-list/motion-list.component.html index 047c98f6a..db46bb07d 100644 --- a/client/src/app/site/motions/components/motion-list/motion-list.component.html +++ b/client/src/app/site/motions/components/motion-list/motion-list.component.html @@ -17,8 +17,11 @@ - + @@ -30,7 +33,7 @@ - + Projector @@ -82,14 +85,12 @@ lightblue: motion.state.css_class === 'primary' }" > - {{ motion.state.name | translate }} + {{ getStateLabel(motion) }} - {{ - motion.recommendation.recommendation_label | translate - }} + {{ getRecommendationLabel(motion) }} @@ -198,20 +199,29 @@ label Set status - - - -