Correct projector scroll reset

Fixes the "everytime reset" with #4887
This commit is contained in:
FinnStutzenstein 2019-08-01 08:03:34 +02:00
parent 62c55094bb
commit 35e88b8386
2 changed files with 21 additions and 5 deletions

View File

@ -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<void> {
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);
}
/**

View File

@ -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()