From 30c93f399065b5167fb85b9e30908814e49a1463 Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Tue, 6 Aug 2019 09:26:11 +0200 Subject: [PATCH] w --- AUTHORS | 1 + .../agenda-content-object-form.component.html | 8 ++-- .../motion-block-list.component.html | 20 ++++----- .../motion-block-list.component.scss | 10 ++++- .../motion-block-list.component.ts | 43 +++++++----------- ...motion-comment-section-list.component.html | 4 +- .../motion-comment-section-list.component.ts | 44 ++++++++----------- .../statute-paragraph-list.component.html | 6 +-- .../statute-paragraph-list.component.ts | 44 ++++++++----------- .../tag-list/tag-list.component.html | 24 +++++----- .../components/tag-list/tag-list.component.ts | 42 ++++++++++++------ 11 files changed, 119 insertions(+), 127 deletions(-) diff --git a/AUTHORS b/AUTHORS index e438973a9..6147d3e87 100644 --- a/AUTHORS +++ b/AUTHORS @@ -30,3 +30,4 @@ Authors of OpenSlides in chronological order of first contribution: Jochen Saalfeld Fadi Abbud Gabriel Meyer + Joshua Sangmeister diff --git a/client/src/app/shared/components/agenda-content-object-form/agenda-content-object-form.component.html b/client/src/app/shared/components/agenda-content-object-form/agenda-content-object-form.component.html index 3cd2a2f02..bd59f1a30 100644 --- a/client/src/app/shared/components/agenda-content-object-form/agenda-content-object-form.component.html +++ b/client/src/app/shared/components/agenda-content-object-form/agenda-content-object-form.component.html @@ -1,9 +1,11 @@
- - Add to agenda - +

+ + Add to agenda + +

diff --git a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.html b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.html index 7d11da074..af403280c 100644 --- a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.html +++ b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.html @@ -41,16 +41,14 @@ {{ "New motion block" | translate }}
-
+
-

- - - - A title is required - - -

+ + + + A title is required + +

@@ -61,9 +59,9 @@

- - +
diff --git a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.scss b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.scss index 7a60d3212..83f48c826 100644 --- a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.scss +++ b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.scss @@ -8,6 +8,12 @@ } } -.mat-form-field { - width: 50%; +.mat-dialog-container { + .mat-dialog-title { + margin: 0; + } + + .mat-form-field { + width: 100%; + } } diff --git a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.ts b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.ts index 40c66b82e..478a093ad 100644 --- a/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.ts +++ b/client/src/app/site/motions/modules/motion-block/components/motion-block-list/motion-block-list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { MatDialog, MatDialogRef } from '@angular/material'; +import { MatDialog } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -17,6 +17,7 @@ import { ViewItem } from 'app/site/agenda/models/view-item'; import { BaseListViewComponent } from 'app/site/base/base-list-view'; import { ViewMotionBlock } from 'app/site/motions/models/view-motion-block'; import { MotionBlockSortService } from 'app/site/motions/services/motion-block-sort.service'; +import { infoDialogSettings } from 'app/shared/utils/dialog-settings'; /** * Table for the motion blocks @@ -31,8 +32,6 @@ export class MotionBlockListComponent extends BaseListViewComponent; - private dialogRef: MatDialogRef; - /** * Holds the create form */ @@ -136,13 +135,9 @@ export class MotionBlockListComponent extends BaseListViewComponent { + if (res) { + this.save(); + } + }) } /** - * Click handler for the save button. * Sends the block to create to the repository and resets the form. */ - public async onSaveNewButton(): Promise { + private save(): void { if (this.createBlockForm.valid) { const block = this.createBlockForm.value; if (!block.agenda_parent_id) { @@ -171,14 +165,12 @@ export class MotionBlockListComponent extends BaseListViewComponent
- -
diff --git a/client/src/app/site/motions/modules/motion-comment-section/components/motion-comment-section-list/motion-comment-section-list.component.ts b/client/src/app/site/motions/modules/motion-comment-section/components/motion-comment-section-list/motion-comment-section-list.component.ts index 0234c3e10..6a72f1c15 100644 --- a/client/src/app/site/motions/modules/motion-comment-section/components/motion-comment-section-list/motion-comment-section-list.component.ts +++ b/client/src/app/site/motions/modules/motion-comment-section/components/motion-comment-section-list/motion-comment-section-list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { MatDialog, MatDialogRef } from '@angular/material'; +import { MatDialog } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -14,6 +14,7 @@ import { MotionCommentSection } from 'app/shared/models/motions/motion-comment-s import { BaseViewComponent } from 'app/site/base/base-view'; import { ViewMotionCommentSection } from 'app/site/motions/models/view-motion-comment-section'; import { ViewGroup } from 'app/site/users/models/view-group'; +import { infoDialogSettings } from 'app/shared/utils/dialog-settings'; /** * List view for the comment sections. @@ -29,8 +30,6 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme public currentComment: ViewMotionCommentSection | null; - public dialogRef: MatDialogRef; - /** * Source of the Data */ @@ -93,54 +92,47 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme public onKeyDown(event: KeyboardEvent, viewSection?: ViewMotionCommentSection): void { if (event.key === 'Enter' && event.shiftKey) { this.save(); + this.dialog.closeAll(); } if (event.key === 'Escape') { - this.cancel(); + this.dialog.closeAll(); } } /** * Opens the create dialog. */ - public openDialog(c?: ViewMotionCommentSection): void { - this.currentComment = c; + public openDialog(commentSection?: ViewMotionCommentSection): void { + this.currentComment = commentSection; this.commentFieldForm.reset({ - name: c ? c.name : '', - read_groups_id: c ? c.read_groups_id : [], - write_groups_id: c ? c.write_groups_id : [] + name: commentSection ? commentSection.name : '', + read_groups_id: commentSection ? commentSection.read_groups_id : [], + write_groups_id: commentSection ? commentSection.write_groups_id : [] }); - this.dialogRef = this.dialog.open(this.motionCommentDialog, { - width: '500px', - maxWidth: '90vw', - maxHeight: '90vh', - disableClose: true + const dialogRef = this.dialog.open(this.motionCommentDialog, infoDialogSettings); + dialogRef.afterClosed().subscribe((res) => { + if (res) { + this.save(); + } }); } /** * saves the current data, either updating an existing comment or creating a new one. */ - public save(): void { + private save(): void { if (this.commentFieldForm.valid) { // eiher update or create if (this.currentComment) { - this.repo - .update(this.commentFieldForm.value as Partial, this.currentComment) - .then(() => this.dialogRef.close(), this.raiseError); + this.repo.update(this.commentFieldForm.value as Partial, this.currentComment).catch(this.raiseError); } else { const c = new MotionCommentSection(this.commentFieldForm.value); - this.repo.create(c).then(() => this.dialogRef.close(), this.raiseError); + this.repo.create(c).catch(this.raiseError); } + this.commentFieldForm.reset(); } } - /** - * close the dialog - */ - public cancel(): void { - this.dialogRef.close(); - } - /** * is executed, when the delete button is pressed * @param viewSection The section to delete diff --git a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html index 40eb854e2..8d4baf4a7 100644 --- a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html +++ b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.html @@ -64,7 +64,7 @@

- {{ (currentStatuteParagraph ? "Edit statute paragraph" : "New statute paragraph") | translate }} + {{ ((currentStatuteParagraph ? "Edit" : "New") + "statute paragraph") | translate }}

@@ -84,10 +84,10 @@
- -
diff --git a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.ts b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.ts index 235023c8c..ae7e9dca5 100644 --- a/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.ts +++ b/client/src/app/site/motions/modules/statute-paragraph/components/statute-paragraph-list/statute-paragraph-list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { MatDialog, MatDialogRef } from '@angular/material'; +import { MatDialog } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import { StatuteParagraph } from 'app/shared/models/motions/statute-paragraph'; import { BaseViewComponent } from 'app/site/base/base-view'; import { ViewStatuteParagraph } from 'app/site/motions/models/view-statute-paragraph'; import { StatuteCsvExportService } from 'app/site/motions/services/statute-csv-export.service'; +import { largeDialogSettings } from 'app/shared/utils/dialog-settings'; /** * List view for the statute paragraphs. @@ -25,8 +26,6 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements @ViewChild('statuteParagraphDialog', { static: true }) private statuteParagraphDialog: TemplateRef; - private dialogRef: MatDialogRef; - private currentStatuteParagraph: ViewStatuteParagraph | null; /** @@ -86,37 +85,36 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements /** * Open the modal dialog */ - public openDialog(p?: ViewStatuteParagraph): void { - this.currentStatuteParagraph = p; + public openDialog(paragraph?: ViewStatuteParagraph): void { + this.currentStatuteParagraph = paragraph; this.statuteParagraphForm.reset(); - if (p) { + if (paragraph) { this.statuteParagraphForm.setValue({ - title: p.title, - text: p.text + title: paragraph.title, + text: paragraph.text }); } - this.dialogRef = this.dialog.open(this.statuteParagraphDialog, { - width: '1000px', - maxWidth: '95vw', - maxHeight: '90vh', - disableClose: true + const dialogRef = this.dialog.open(this.statuteParagraphDialog, largeDialogSettings); + dialogRef.afterClosed().subscribe((res) => { + if (res) { + this.save(); + } }); } /** * creates a new statute paragraph or updates the current one */ - public save(): void { + private save(): void { if (this.statuteParagraphForm.valid) { // eiher update or create if (this.currentStatuteParagraph) { - this.repo - .update(this.statuteParagraphForm.value as Partial, this.currentStatuteParagraph) - .then(() => this.dialogRef.close(), this.raiseError); + this.repo.update(this.statuteParagraphForm.value as Partial, this.currentStatuteParagraph).catch(this.raiseError); } else { const p = new StatuteParagraph(this.statuteParagraphForm.value); - this.repo.create(p).then(() => this.dialogRef.close(), this.raiseError); + this.repo.create(p).catch(this.raiseError); } + this.statuteParagraphForm.reset(); } } @@ -148,19 +146,13 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements public onKeyDown(event: KeyboardEvent): void { if (event.key === 'Enter' && event.shiftKey) { this.save(); + this.dialog.closeAll(); } if (event.key === 'Escape') { - this.cancel(); + this.dialog.closeAll(); } } - /** - * Closes the dialog - */ - public cancel(): void { - this.dialogRef.close(); - } - /** * Triggers a csv export of the statute paragraphs */ diff --git a/client/src/app/site/tags/components/tag-list/tag-list.component.html b/client/src/app/site/tags/components/tag-list/tag-list.component.html index 1c93d2056..651d0be7c 100644 --- a/client/src/app/site/tags/components/tag-list/tag-list.component.html +++ b/client/src/app/site/tags/components/tag-list/tag-list.component.html @@ -39,20 +39,20 @@

{{ (currentTag ? 'Edit tag' : 'New tag') | translate }}

-
-
+
+ -
+ +
-
- - -
- +
+ + +
diff --git a/client/src/app/site/tags/components/tag-list/tag-list.component.ts b/client/src/app/site/tags/components/tag-list/tag-list.component.ts index 8150d68d1..4b2200f20 100644 --- a/client/src/app/site/tags/components/tag-list/tag-list.component.ts +++ b/client/src/app/site/tags/components/tag-list/tag-list.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { MatDialog, MatDialogRef } from '@angular/material'; +import { MatDialog } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -12,6 +12,7 @@ import { PromptService } from 'app/core/ui-services/prompt.service'; import { Tag } from 'app/shared/models/core/tag'; import { BaseListViewComponent } from 'app/site/base/base-list-view'; import { ViewTag } from '../../models/view-tag'; +import { infoDialogSettings } from 'app/shared/utils/dialog-settings'; /** * Listview for the complete list of available Tags @@ -33,8 +34,6 @@ export class TagListComponent extends BaseListViewComponent implements name: ['', [Validators.required]] }); - private dialogRef: MatDialogRef; - /** * Holds the tag that's currently being edited, or null. */ @@ -94,28 +93,27 @@ export class TagListComponent extends BaseListViewComponent implements this.currentTag = tag; this.tagForm.reset(); this.tagForm.get('name').setValue(this.currentTag ? this.currentTag.name : ''); - this.dialogRef = this.dialog.open(this.tagDialog, { - width: '400px', - maxWidth: '90vw', - maxHeight: '90vh', - disableClose: true - }); + const dialogRef = this.dialog.open(this.tagDialog, infoDialogSettings); + dialogRef.afterClosed().subscribe((res) => { + if (res) { + this.save(); + } + }) } /** * Submit the form and create or update a tag. */ - public onSubmit(): void { + private save(): void { if (!this.tagForm.value || !this.tagForm.valid) { return; } if (this.currentTag) { - this.repo - .update(new Tag(this.tagForm.value), this.currentTag) - .then(() => this.dialogRef.close(), this.raiseError); + this.repo.update(new Tag(this.tagForm.value), this.currentTag).catch(this.raiseError); } else { - this.repo.create(this.tagForm.value).then(() => this.dialogRef.close(), this.raiseError); + this.repo.create(this.tagForm.value).catch(this.raiseError); } + this.tagForm.reset(); // reset here so pressing shift+enter wont save when dialog isnt open } /** @@ -128,4 +126,20 @@ export class TagListComponent extends BaseListViewComponent implements this.repo.delete(tag).catch(this.raiseError); } } + + /** + * clicking Shift and Enter will save automatically + * clicking Escape will cancel the process + * + * @param event has the code + */ + public onKeyDown(event: KeyboardEvent): void { + if (event.key === 'Enter' && event.shiftKey) { + this.save(); + this.dialog.closeAll(); + } + if (event.key === 'Escape') { + this.dialog.closeAll(); + } + } }