From ea0a6050183514709e156111141d92d4f5a9d77c Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Thu, 14 Feb 2019 10:12:31 +0100 Subject: [PATCH] modified final version edit --- .../app/site/motions/models/view-motion.ts | 8 + .../motion-detail-diff.component.html | 2 + .../motion-detail-diff.component.scss | 2 +- .../motion-detail-diff.component.ts | 3 + .../motion-detail.component.html | 213 +++++++++++------- .../motion-detail.component.scss | 38 ++-- .../motion-detail/motion-detail.component.ts | 73 +++++- .../styles/global-components-style.scss | 4 + 8 files changed, 243 insertions(+), 100 deletions(-) diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index b7b023f44..86582ac7a 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -42,6 +42,14 @@ export enum ChangeRecoMode { ModifiedFinal = 'modified_final_version' } +export const verboseChangeRecoMode = { + original: 'Original version', + changed: 'Changed version', + diff: 'Diff version', + agreed: 'Final version', + modified_final_version: 'Final print template' +}; + export interface MotionTitleInformation extends TitleInformationWithAgendaItem { title: string; identifier?: string; diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html index a87bffda4..b259f3031 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.html @@ -38,6 +38,8 @@
{{ 'No change recommendations yet' | translate }}
+{{ preamble | translate }} +
diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.scss b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.scss index 73ac1b400..44f738980 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.scss +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.scss @@ -58,7 +58,7 @@ background-color: #eee; border: solid 1px #ddd; border-radius: 3px; - margin-bottom: 5px; + margin-bottom: 15px; padding: 5px 10px; a, diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts index 8e07ad319..0c4491d32 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail-diff/motion-detail-diff.component.ts @@ -64,6 +64,8 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte */ public lineLength: number; + public preamble: string; + /** * @param title * @param translate @@ -92,6 +94,7 @@ export class MotionDetailDiffComponent extends BaseViewComponent implements Afte ) { super(title, translate, matSnackBar); this.configService.get('motions_line_length').subscribe(lineLength => (this.lineLength = lineLength)); + this.configService.get('motions_preamble').subscribe(preamble => (this.preamble = preamble)); } /** 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 d8db3417d..6070c5977 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 @@ -436,83 +436,115 @@
- -
- - - Invalid line number - + + - - - - - + + +
- - + + + + + + + + +
@@ -579,13 +611,13 @@ - - {{ preamble | translate }} + + {{ preamble | translate }}
+ +
+ +
+ This field is required. +
+
+ +
outside + +
@@ -918,9 +975,9 @@ diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.scss b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.scss index 827b2a53a..650ee17bc 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.scss +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.scss @@ -23,30 +23,36 @@ span { display: flow-root; } -.motion-text-controls { - float: right; - margin-left: 5px; - margin-top: -15px; - height: 50px; +.motion-text-toolbar-wrapper { + display: flex; + justify-content: flex-end; button { - font-size: 115%; + font-weight: 400; + margin-top: 7px; } + height: 50px; + margin: -16px -16px 5px -16px; + padding: 0 16px; + > button { // Prevent moving the buttons when the "go to line"-input is shown margin-top: 7px; } - .motion-goto-line { - width: 150px; - } - input[type='number']::-webkit-inner-spin-button, - input[type='number']::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; - } - input[type='number'] { - -moz-appearance: textfield; + + .motion-text-controls { + .motion-goto-line { + width: 150px; + } + input[type='number']::-webkit-inner-spin-button, + input[type='number']::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; + } + input[type='number'] { + -moz-appearance: textfield; + } } } diff --git a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts index 3a4bcdf2b..8e6ae03e4 100644 --- a/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/motions/modules/motion-detail/components/motion-detail/motion-detail.component.ts @@ -45,7 +45,12 @@ import { ViewMotionNotificationEditMotion, TypeOfNotificationViewMotion } from 'app/site/motions/models/view-motion-notify'; -import { ViewMotion, ChangeRecoMode, LineNumberingMode } from 'app/site/motions/models/view-motion'; +import { + ViewMotion, + ChangeRecoMode, + LineNumberingMode, + verboseChangeRecoMode +} from 'app/site/motions/models/view-motion'; import { ViewStatuteParagraph } from 'app/site/motions/models/view-statute-paragraph'; import { ViewTag } from 'app/site/tags/models/view-tag'; import { ViewUnifiedChange } from 'app/shared/models/motions/view-unified-change'; @@ -123,6 +128,30 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, return this.repo.getExtendedStateLabel(this.motion); } + private finalEditMode = false; + + /** + * check if the 'final version edit mode' is active + * + * @returns true if active + */ + public get isFinalEdit(): boolean { + return this.finalEditMode; + } + + /** + * Helper to check the current state of the final version edit + * + * @returns true if the local edit of the modified_final_version differs + * from the submitted version + */ + public get finalVersionEdited(): boolean { + return ( + this.crMode === ChangeRecoMode.ModifiedFinal && + this.contentForm.get('modified_final_version').value !== this.motion.modified_final_version + ); + } + /** * Saves the target motion. Accessed via the getter and setter. */ @@ -275,6 +304,8 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, */ public ChangeRecoMode = ChangeRecoMode; + public verboseChangeRecoMode = verboseChangeRecoMode; + /** * For using the enum constants from the template */ @@ -704,8 +735,9 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, selected_paragraphs: [], statute_amendment: [''], // Internal value for the checkbox, not saved to the model statute_paragraph_id: [''], - motion_block_id: [], // TODO: Can be removed if this is not required - parent_id: [] + motion_block_id: [], + parent_id: [], + modified_final_version: [''] }); this.updateWorkflowIdForCreateForm(); @@ -1062,7 +1094,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, 'Are you sure you want to copy the final version to the print template?' ); if (await this.promptService.open(title, null)) { - await this.updateMotion({ modified_final_version: finalVersion }, this.motion); + this.updateMotion({ modified_final_version: finalVersion }, this.motion).then( + () => this.setChangeRecoMode(ChangeRecoMode.ModifiedFinal), + this.raiseError + ); } } else { await this.updateMotion({ modified_final_version: finalVersion }, this.motion); @@ -1070,7 +1105,6 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, } catch (e) { this.raiseError(e); } - this.setChangeRecoMode(ChangeRecoMode.ModifiedFinal); } /** @@ -1079,6 +1113,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, public async deleteModifiedFinalVersion(): Promise { const title = this.translate.instant('Are you sure you want to delete the print template?'); if (await this.promptService.open(title, null)) { + this.finalEditMode = false; this.updateMotion({ modified_final_version: '' }, this.motion).then( () => this.setChangeRecoMode(ChangeRecoMode.Final), this.raiseError @@ -1444,6 +1479,27 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, } } + /** + * Submits the modified final version of the motion + */ + public onSubmitFinalVersion(): void { + const val = this.contentForm.get('modified_final_version').value; + this.updateMotion({ modified_final_version: val }, this.motion).then(() => { + this.finalEditMode = false; + this.contentForm.get('modified_final_version').markAsPristine(); + }, this.raiseError); + } + + /** + * Cancels the final version edit and resets the form value + * + * TODO: the tinyMCE editor content should reset, too + */ + public cancelFinalVersionEdit(): void { + this.finalEditMode = false; + this.contentForm.patchValue({ modified_final_version: this.motion.modified_final_version }); + } + /** * Toggles the favorite status */ @@ -1548,4 +1604,11 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit, } } } + + /** + * Activates the 'edit final version' mode + */ + public editModifiedFinal(): void { + this.finalEditMode = true; + } } diff --git a/client/src/assets/styles/global-components-style.scss b/client/src/assets/styles/global-components-style.scss index a779da3d9..5c06218a8 100644 --- a/client/src/assets/styles/global-components-style.scss +++ b/client/src/assets/styles/global-components-style.scss @@ -46,6 +46,10 @@ color: mat-color($warn); } + .outline-border-bottom { + border-bottom: 1px solid $os-outline; + } + /* motion list/detail view */ .mat-chip-list.user .mat-chip { color: mat-color($foreground, text);