From 35e88b838661bdc5e0b648400d348f7807a1d150 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Thu, 1 Aug 2019 08:03:34 +0200 Subject: [PATCH] Correct projector scroll reset Fixes the "everytime reset" with #4887 --- .../core/core-services/projector.service.ts | 19 +++++++++++++++---- openslides/core/views.py | 7 ++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/client/src/app/core/core-services/projector.service.ts b/client/src/app/core/core-services/projector.service.ts index 5982833d6..5e5fc592f 100644 --- a/client/src/app/core/core-services/projector.service.ts +++ b/client/src/app/core/core-services/projector.service.ts @@ -158,7 +158,7 @@ export class ProjectorService { changed = true; } if (changed) { - await this.projectRequest(projector, projector.elements, null, removedElements); + await this.projectRequest(projector, projector.elements, null, removedElements, false, true); } } } @@ -211,7 +211,8 @@ export class ProjectorService { elements?: ProjectorElements, preview?: ProjectorElements, appendToHistory?: ProjectorElements, - deleteLastHistroyElement?: boolean + deleteLastHistroyElement?: boolean, + resetScroll?: boolean ): Promise { const requestData: any = {}; if (elements) { @@ -229,6 +230,9 @@ export class ProjectorService { if (appendToHistory && appendToHistory.length && deleteLastHistroyElement) { throw new Error('You cannot append to the history and delete the last element at the same time'); } + if (resetScroll) { + requestData.reset_scroll = resetScroll; + } await this.http.post(`/rest/core/projector/${projector.id}/project/`, requestData); } @@ -361,7 +365,14 @@ export class ProjectorService { const removedElements = projector.removeAllNonStableElements(); projector.addElement(projector.elements_preview.splice(previewIndex, 1)[0]); - await this.projectRequest(projector, projector.elements, projector.elements_preview, removedElements); + await this.projectRequest( + projector, + projector.elements, + projector.elements_preview, + removedElements, + false, + true + ); } /** @@ -388,7 +399,7 @@ export class ProjectorService { if (lastElement) { projector.addElement(lastElement); } - await this.projectRequest(projector, projector.elements, projector.elements_preview, null, true); + await this.projectRequest(projector, projector.elements, projector.elements_preview, null, true, true); } /** diff --git a/openslides/core/views.py b/openslides/core/views.py index 3c984fe6f..789ea26a3 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -177,15 +177,17 @@ class ProjectorViewSet(ModelViewSet): If `delete_last_history_element` is True, the last element is deleted. Note: You cannot give `append_to_history` and `delete_last_history_element` at the same time. + + 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") delete_last_history_element = request.data.get( "delete_last_history_element", False ) + reset_scroll = request.data.get("reset_scroll", False) if elements is not None: elements_validator(elements) @@ -204,6 +206,9 @@ class ProjectorViewSet(ModelViewSet): elements_array_validator(elements_history) projector.elements_history = elements_history + if reset_scroll: + projector.scroll = 0 + projector.save() return Response()