From 1bd93f0e985a221f542d12258f0aeff3f9cec73f Mon Sep 17 00:00:00 2001 From: jsangmeister Date: Wed, 31 Jul 2019 12:04:15 +0200 Subject: [PATCH] added dialogs for creating and editing tags, statute paragraphs, motion comments and motion blocks --- client/package.json | 2 +- .../motion-block-list.component.html | 66 ++++---- .../motion-block-list.component.ts | 32 ++-- ...motion-comment-section-list.component.html | 153 +++++++----------- .../motion-comment-section-list.component.ts | 125 ++++++-------- .../statute-paragraph-list.component.html | 117 +++++--------- .../statute-paragraph-list.component.ts | 135 ++++++---------- .../tag-list/tag-list.component.html | 68 ++++---- .../components/tag-list/tag-list.component.ts | 137 +++++++--------- openslides/core/views.py | 1 + 10 files changed, 348 insertions(+), 488 deletions(-) diff --git a/client/package.json b/client/package.json index 65a66e9c9..2ced716f8 100644 --- a/client/package.json +++ b/client/package.json @@ -90,7 +90,7 @@ "karma-jasmine-html-reporter": "^1.4.0", "npm-license-crawler": "^0.2.1", "npm-run-all": "^4.1.5", - "prettier": "^1.18.0", + "prettier": "^1.18.2", "protractor": "^5.4.2", "resize-observer-polyfill": "^1.5.1", "source-map-explorer": "^2.0.1", 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 be4934842..7d11da074 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 @@ -3,39 +3,6 @@

Motion blocks

- - - New motion block - -
- -

- - - - A title is required - - -

- - -

- Internal -

- - -
-
- - - - - - -
- + + + +

+ {{ "New motion block" | translate }} +

+
+
+ +

+ + + + A title is required + + +

+ + +

+ Internal +

+ + +
+
+
+ + +
+
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 2d33f766a..40c66b82e 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,5 +1,6 @@ -import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialog, MatDialogRef } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -27,6 +28,11 @@ import { MotionBlockSortService } from 'app/site/motions/services/motion-block-s encapsulation: ViewEncapsulation.None }) export class MotionBlockListComponent extends BaseListViewComponent implements OnInit { + @ViewChild('newMotionBlockDialog', { static: true }) + private newMotionBlockDialog: TemplateRef; + + private dialogRef: MatDialogRef; + /** * Holds the create form */ @@ -95,6 +101,7 @@ export class MotionBlockListComponent extends BaseListViewComponent +

Comment fields

@@ -13,52 +13,11 @@
- - New comment field - -
-

- - - - Required - - -

-

- -

-

- -

-
-
- - - - -
@@ -87,59 +46,22 @@
-
- Edit comment field: -

- - - - Required - - -

-

- -

-

- -

-
- -

Name

-
{{ section.name }}
-

Groups with read permissions

-
    -
  • {{ group.getTitle() }}
  • -
-
No groups selected
-

Groups with write permissions

-
    -
  • {{ group.getTitle() }}
  • -
-
No groups selected
-
+

Name

+
{{ section.name }}
+

Groups with read permissions

+
    +
  • {{ group.getTitle() }}
  • +
+
No groups selected
+

Groups with write permissions

+
    +
  • {{ group.getTitle() }}
  • +
+
No groups selected
- - - @@ -153,3 +75,48 @@ Sort + + + +

+ {{ (currentComment ? "Edit comment field" : "New comment field") | translate }} +

+
+
+

+ + + + Required + + +

+

+ +

+

+ +

+
+
+
+ + +
+
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 9be7b7a3c..0234c3e10 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,5 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialog, MatDialogRef } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -23,7 +24,12 @@ import { ViewGroup } from 'app/site/users/models/view-group'; styleUrls: ['./motion-comment-section-list.component.scss'] }) export class MotionCommentSectionListComponent extends BaseViewComponent implements OnInit { - public commentSectionToCreate: MotionCommentSection | null; + @ViewChild('motionCommentDialog', { static: true }) + private motionCommentDialog: TemplateRef; + + public currentComment: ViewMotionCommentSection | null; + + public dialogRef: MatDialogRef; /** * Source of the Data @@ -31,14 +37,11 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme public commentSections: ViewMotionCommentSection[] = []; /** - * The current focussed formgroup + * formgroup for editing and creating of comments */ - public updateForm: FormGroup; - - public createForm: FormGroup; + public commentFieldForm: FormGroup; public openId: number | null; - public editId: number | null; public groups: BehaviorSubject; @@ -59,6 +62,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme private repo: MotionCommentSectionRepositoryService, private formBuilder: FormBuilder, private promptService: PromptService, + private dialog: MatDialog, private groupRepo: GroupRepositoryService ) { super(titleService, translate, matSnackBar); @@ -68,8 +72,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme read_groups_id: [[]], write_groups_id: [[]] }; - this.createForm = this.formBuilder.group(form); - this.updateForm = this.formBuilder.group(form); + this.commentFieldForm = this.formBuilder.group(form); } /** @@ -82,81 +85,62 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme } /** - * Event on Key Down in update or create form. + * Event on Key Down in form. * * @param event the keyboard event * @param the current view in scope */ - public keyDownFunction(event: KeyboardEvent, viewSection?: ViewMotionCommentSection): void { + public onKeyDown(event: KeyboardEvent, viewSection?: ViewMotionCommentSection): void { if (event.key === 'Enter' && event.shiftKey) { - if (viewSection) { - this.onSaveButton(viewSection); - } else { - this.create(); - } + this.save(); } if (event.key === 'Escape') { - if (viewSection) { - this.editId = null; - } else { - this.commentSectionToCreate = null; - } + this.cancel(); } } /** - * Opens the create form. + * Opens the create dialog. */ - public onPlusButton(): void { - if (!this.commentSectionToCreate) { - this.commentSectionToCreate = new MotionCommentSection(); - this.createForm.setValue({ - name: '', - read_groups_id: [], - write_groups_id: [] - }); - } - } - - /** - * Creates the comment section from the create form. - */ - public create(): void { - if (this.createForm.valid) { - this.commentSectionToCreate.patchValues(this.createForm.value as MotionCommentSection); - this.repo - .create(this.commentSectionToCreate) - .then(() => (this.commentSectionToCreate = null), this.raiseError); - } - } - - /** - * Executed on edit button - * @param viewSection - */ - public onEditButton(viewSection: ViewMotionCommentSection): void { - this.editId = viewSection.id; - - this.updateForm.setValue({ - name: viewSection.name, - read_groups_id: viewSection.read_groups_id, - write_groups_id: viewSection.write_groups_id + public openDialog(c?: ViewMotionCommentSection): void { + this.currentComment = c; + this.commentFieldForm.reset({ + name: c ? c.name : '', + read_groups_id: c ? c.read_groups_id : [], + write_groups_id: c ? c.write_groups_id : [] + }); + this.dialogRef = this.dialog.open(this.motionCommentDialog, { + width: '500px', + maxWidth: '90vw', + maxHeight: '90vh', + disableClose: true }); } /** - * Saves the comment section - * - * @param viewSection The section to save + * saves the current data, either updating an existing comment or creating a new one. */ - public onSaveButton(viewSection: ViewMotionCommentSection): void { - if (this.updateForm.valid) { - this.repo.update(this.updateForm.value as Partial, viewSection).then(() => { - this.openId = this.editId = null; - }, this.raiseError); + public 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); + } else { + const c = new MotionCommentSection(this.commentFieldForm.value); + this.repo.create(c).then(() => this.dialogRef.close(), this.raiseError); + } } } + /** + * close the dialog + */ + public cancel(): void { + this.dialogRef.close(); + } + /** * is executed, when the delete button is pressed * @param viewSection The section to delete @@ -165,18 +149,7 @@ export class MotionCommentSectionListComponent extends BaseViewComponent impleme const title = this.translate.instant('Are you sure you want to delete this comment field?'); const content = viewSection.name; if (await this.promptService.open(title, content)) { - this.repo.delete(viewSection).then(() => (this.openId = this.editId = null), this.raiseError); - } - } - - /** - * Is executed when a mat-extension-panel is closed - * @param viewSection the section in the panel - */ - public panelClosed(viewSection: ViewMotionCommentSection): void { - this.openId = null; - if (this.editId) { - this.onSaveButton(viewSection); + this.repo.delete(viewSection).catch(this.raiseError); } } } 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 bdbbcf1e1..40eb854e2 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 @@ -1,4 +1,4 @@ - +

Statute

@@ -12,41 +12,12 @@
- - New statute paragraph - -
-

- - - - Required - - -

- - -

Statute paragraph

- -
-
-
- - - - -
- - + @@ -55,51 +26,17 @@ {{ statuteParagraph.title }} -
- Edit statute paragraph: -

- - - - Required - - -

- - -

Statute paragraph

- -
-
- - - {{ statuteParagraph.title }} - -
-
-
-
+ + {{ statuteParagraph.title }} + +
+
+
- - - - @@ -123,3 +60,35 @@ Import ... + + + +

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

+
+
+

+ + + + Required + + +

+ + +

Statute paragraph

+ +
+
+
+
+ + +
+
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 8463f4d40..235023c8c 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,5 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialog, MatDialogRef } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -21,7 +22,12 @@ import { StatuteCsvExportService } from 'app/site/motions/services/statute-csv-e styleUrls: ['./statute-paragraph-list.component.scss'] }) export class StatuteParagraphListComponent extends BaseViewComponent implements OnInit { - public statuteParagraphToCreate: StatuteParagraph | null; + @ViewChild('statuteParagraphDialog', { static: true }) + private statuteParagraphDialog: TemplateRef; + + private dialogRef: MatDialogRef; + + private currentStatuteParagraph: ViewStatuteParagraph | null; /** * Source of the Data @@ -29,14 +35,11 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements public statuteParagraphs: ViewStatuteParagraph[] = []; /** - * The current focussed formgroup + * Formgroup for creating and updating of statute paragraphs */ - public updateForm: FormGroup; + public statuteParagraphForm: FormGroup; - public createForm: FormGroup; - - public openId: number | null; - public editId: number | null; + public openId: Number | null; /** * The usual component constructor. Initializes the forms @@ -56,6 +59,7 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements private repo: StatuteParagraphRepositoryService, private formBuilder: FormBuilder, private promptService: PromptService, + private dialog: MatDialog, private csvExportService: StatuteCsvExportService ) { super(titleService, translate, matSnackBar); @@ -64,8 +68,7 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements title: ['', Validators.required], text: ['', Validators.required] }; - this.createForm = this.formBuilder.group(form); - this.updateForm = this.formBuilder.group(form); + this.statuteParagraphForm = this.formBuilder.group(form); } /** @@ -81,53 +84,39 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements } /** - * Add a new Section. + * Open the modal dialog */ - public onPlusButton(): void { - if (!this.statuteParagraphToCreate) { - this.createForm.reset(); - this.createForm.setValue({ - title: '', - text: '' + public openDialog(p?: ViewStatuteParagraph): void { + this.currentStatuteParagraph = p; + this.statuteParagraphForm.reset(); + if (p) { + this.statuteParagraphForm.setValue({ + title: p.title, + text: p.text }); - this.statuteParagraphToCreate = new StatuteParagraph(); } - } - - /** - * Handler when clicking on create to create a new statute paragraph - */ - public create(): void { - if (this.createForm.valid) { - this.statuteParagraphToCreate.patchValues(this.createForm.value as StatuteParagraph); - this.repo.create(this.statuteParagraphToCreate).then(() => { - this.statuteParagraphToCreate = null; - }, this.raiseError); - } - } - - /** - * Executed on edit button - * @param viewStatuteParagraph - */ - public onEditButton(viewStatuteParagraph: ViewStatuteParagraph): void { - this.editId = viewStatuteParagraph.id; - - this.updateForm.setValue({ - title: viewStatuteParagraph.title, - text: viewStatuteParagraph.text + this.dialogRef = this.dialog.open(this.statuteParagraphDialog, { + width: '1000px', + maxWidth: '95vw', + maxHeight: '90vh', + disableClose: true }); } /** - * Saves the statute paragraph - * @param viewStatuteParagraph The statute paragraph to save + * creates a new statute paragraph or updates the current one */ - public onSaveButton(viewStatuteParagraph: ViewStatuteParagraph): void { - if (this.updateForm.valid) { - this.repo.update(this.updateForm.value as Partial, viewStatuteParagraph).then(() => { - this.openId = this.editId = null; - }, this.raiseError); + public 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); + } else { + const p = new StatuteParagraph(this.statuteParagraphForm.value); + this.repo.create(p).then(() => this.dialogRef.close(), this.raiseError); + } } } @@ -139,18 +128,7 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements const title = this.translate.instant('Are you sure you want to delete this statute paragraph?'); const content = viewStatuteParagraph.title; if (await this.promptService.open(title, content)) { - this.repo.delete(viewStatuteParagraph).then(() => (this.openId = this.editId = null), this.raiseError); - } - } - - /** - * Is executed when a mat-extension-panel is closed - * @param viewStatuteParagraph the statute paragraph in the panel - */ - public panelClosed(viewStatuteParagraph: ViewStatuteParagraph): void { - this.openId = null; - if (this.editId) { - this.onSaveButton(viewStatuteParagraph); + this.repo.delete(viewStatuteParagraph).catch(this.raiseError); } } @@ -167,43 +145,20 @@ export class StatuteParagraphListComponent extends BaseViewComponent implements * * @param event has the code */ - public onKeyDownCreate(event: KeyboardEvent): void { + public onKeyDown(event: KeyboardEvent): void { if (event.key === 'Enter' && event.shiftKey) { - this.create(); + this.save(); } if (event.key === 'Escape') { - this.onCancelCreate(); + this.cancel(); } } /** - * Cancels the current form action + * Closes the dialog */ - public onCancelCreate(): void { - this.statuteParagraphToCreate = null; - } - - /** - * clicking Shift and Enter will save automatically - * clicking Escape will cancel the process - * - * @param event has the code - */ - public onKeyDownUpdate(event: KeyboardEvent): void { - if (event.key === 'Enter' && event.shiftKey) { - const myParagraph = this.statuteParagraphs.find(x => x.id === this.editId); - this.onSaveButton(myParagraph); - } - if (event.key === 'Escape') { - this.onCancelUpdate(); - } - } - - /** - * Cancels the current form action - */ - public onCancelUpdate(): void { - this.editId = null; + public cancel(): void { + this.dialogRef.close(); } /** 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 8154989d7..1c93d2056 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 @@ -1,37 +1,10 @@ - -
-

Tags

-
- - - Required - -
-
- - -
- -
+

Tags

-
+
{{ name }}
+ +
+ +
+ +
+ +
+ + + +

+ {{ (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 ae424b516..8150d68d1 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,5 +1,6 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { MatDialog, MatDialogRef } from '@angular/material'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Title } from '@angular/platform-browser'; @@ -13,7 +14,7 @@ import { BaseListViewComponent } from 'app/site/base/base-list-view'; import { ViewTag } from '../../models/view-tag'; /** - * Listview for the complete lsit of available Tags + * Listview for the complete list of available Tags * ### Usage: * ```html * @@ -25,12 +26,19 @@ import { ViewTag } from '../../models/view-tag'; styleUrls: ['./tag-list.component.scss'] }) export class TagListComponent extends BaseListViewComponent implements OnInit { - public editTag = false; - public newTag = false; - public selectedTag: ViewTag; + @ViewChild('tagDialog', { static: true }) + private tagDialog: TemplateRef; - @ViewChild('tagForm', { static: true }) - public tagForm: FormGroup; + private tagForm: FormGroup = this.formBuilder.group({ + name: ['', [Validators.required]] + }); + + private dialogRef: MatDialogRef; + + /** + * Holds the tag that's currently being edited, or null. + */ + public currentTag: ViewTag; /** * Define the columns to show @@ -39,6 +47,14 @@ export class TagListComponent extends BaseListViewComponent implements { prop: 'name', width: 'auto' + }, + { + prop: 'edit', + width: this.singleButtonWidth + }, + { + prop: 'delete', + width: this.singleButtonWidth } ]; @@ -55,7 +71,9 @@ export class TagListComponent extends BaseListViewComponent implements matSnackBar: MatSnackBar, public repo: TagRepositoryService, protected translate: TranslateService, // protected required for ng-translate-extract - private promptService: PromptService + private promptService: PromptService, + private dialog: MatDialog, + private formBuilder: FormBuilder ) { super(titleService, translate, matSnackBar); } @@ -66,93 +84,48 @@ export class TagListComponent extends BaseListViewComponent implements */ public ngOnInit(): void { super.setTitle('Tags'); - this.tagForm = new FormGroup({ name: new FormControl('', Validators.required) }); } /** - * Sends a new or updates tag to the dataStore + * sets the given tag as the current and opens the tag dialog. + * @param tag the current tag, or null if a new tag is to be created */ - public saveTag(): void { - if (this.editTag && this.newTag) { - this.submitNewTag(); - } else if (this.editTag && !this.newTag) { - this.submitEditedTag(); - } - } - - /** - * Saves a newly created tag. - */ - public submitNewTag(): void { - if (!this.tagForm.value || !this.tagForm.valid) { - return; - } - this.repo.create(this.tagForm.value).then(() => { - this.tagForm.reset(); - this.cancelEditing(); - }, this.raiseError); - } - - /** - * Saves an edited tag. - */ - public submitEditedTag(): void { - if (!this.tagForm.value || !this.tagForm.valid) { - return; - } - const updateData = new Tag({ name: this.tagForm.value.name }); - - this.repo.update(updateData, this.selectedTag).then(() => this.cancelEditing(), this.raiseError); - } - - /** - * Deletes the selected Tag after a successful confirmation. - */ - public async deleteSelectedTag(): Promise { - const title = this.translate.instant('Are you sure you want to delete this tag?'); - const content = this.selectedTag.name; - if (await this.promptService.open(title, content)) { - this.repo.delete(this.selectedTag).then(() => this.cancelEditing(), this.raiseError); - } - } - - /** - * Cancels the editing - */ - public cancelEditing(): void { - this.newTag = false; - this.editTag = false; + public openTagDialog(tag?: ViewTag): void { + 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 + }); } /** - * Handler for a click on a row in the table - * @param viewTag + * Submit the form and create or update a tag. */ - public selectTag(viewTag: ViewTag): void { - this.selectedTag = viewTag; - this.setEditMode(true, false); - this.tagForm.setValue({ name: this.selectedTag.name }); - } - - public setEditMode(mode: boolean, newTag: boolean = true): void { - this.editTag = mode; - this.newTag = newTag; - if (!mode) { - this.cancelEditing(); + public onSubmit(): 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); + } else { + this.repo.create(this.tagForm.value).then(() => this.dialogRef.close(), this.raiseError); } } /** - * Handles keyboard events. On enter, the editing is canceled. - * @param event + * Deletes the given Tag after a successful confirmation. */ - public keyDownFunction(event: KeyboardEvent): void { - if (event.key === 'Enter' && event.shiftKey) { - this.submitNewTag(); - } - if (event.key === 'Escape') { - this.cancelEditing(); + public async onDeleteButton(tag: ViewTag): Promise { + const title = this.translate.instant('Are you sure you want to delete this tag?'); + const content = tag.name; + if (await this.promptService.open(title, content)) { + this.repo.delete(tag).catch(this.raiseError); } } } diff --git a/openslides/core/views.py b/openslides/core/views.py index 11f71b968..71ef04fc8 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -186,6 +186,7 @@ class ProjectorViewSet(ModelViewSet): If `reset_scroll` is True, the scoll of the projector will reset. """ projector = self.get_object() + projector.scroll = 0 elements = request.data.get("elements") preview = request.data.get("preview") history_element = request.data.get("append_to_history")