Merge pull request #4891 from FinnStutzenstein/fixProjectorScroll

Correct projector scroll reset
This commit is contained in:
Sean 2019-08-01 14:03:45 +02:00 committed by GitHub
commit bc99750869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -158,7 +158,7 @@ export class ProjectorService {
changed = true; changed = true;
} }
if (changed) { 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, elements?: ProjectorElements,
preview?: ProjectorElements, preview?: ProjectorElements,
appendToHistory?: ProjectorElements, appendToHistory?: ProjectorElements,
deleteLastHistroyElement?: boolean deleteLastHistroyElement?: boolean,
resetScroll?: boolean
): Promise<void> { ): Promise<void> {
const requestData: any = {}; const requestData: any = {};
if (elements) { if (elements) {
@ -229,6 +230,9 @@ export class ProjectorService {
if (appendToHistory && appendToHistory.length && deleteLastHistroyElement) { if (appendToHistory && appendToHistory.length && deleteLastHistroyElement) {
throw new Error('You cannot append to the history and delete the last element at the same time'); 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); await this.http.post(`/rest/core/projector/${projector.id}/project/`, requestData);
} }
@ -361,7 +365,14 @@ export class ProjectorService {
const removedElements = projector.removeAllNonStableElements(); const removedElements = projector.removeAllNonStableElements();
projector.addElement(projector.elements_preview.splice(previewIndex, 1)[0]); 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) { if (lastElement) {
projector.addElement(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);
} }
/** /**

View File

@ -182,15 +182,17 @@ class ProjectorViewSet(ModelViewSet):
If `delete_last_history_element` is True, the last element is deleted. If `delete_last_history_element` is True, the last element is deleted.
Note: You cannot give `append_to_history` and `delete_last_history_element` Note: You cannot give `append_to_history` and `delete_last_history_element`
at the same time. at the same time.
If `reset_scroll` is True, the scoll of the projector will reset.
""" """
projector = self.get_object() projector = self.get_object()
projector.scroll = 0
elements = request.data.get("elements") elements = request.data.get("elements")
preview = request.data.get("preview") preview = request.data.get("preview")
history_element = request.data.get("append_to_history") history_element = request.data.get("append_to_history")
delete_last_history_element = request.data.get( delete_last_history_element = request.data.get(
"delete_last_history_element", False "delete_last_history_element", False
) )
reset_scroll = request.data.get("reset_scroll", False)
if elements is not None: if elements is not None:
elements_validator(elements) elements_validator(elements)
@ -209,6 +211,9 @@ class ProjectorViewSet(ModelViewSet):
elements_array_validator(elements_history) elements_array_validator(elements_history)
projector.elements_history = elements_history projector.elements_history = elements_history
if reset_scroll:
projector.scroll = 0
projector.save() projector.save()
return Response() return Response()