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;
}
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

@ -182,15 +182,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)
@ -209,6 +211,9 @@ class ProjectorViewSet(ModelViewSet):
elements_array_validator(elements_history)
projector.elements_history = elements_history
if reset_scroll:
projector.scroll = 0
projector.save()
return Response()