changed all project functions

This commit is contained in:
FinnStutzenstein 2016-11-11 09:37:37 +01:00
parent 43d9733881
commit af9755cb9a
5 changed files with 35 additions and 40 deletions

View File

@ -113,13 +113,12 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
}, },
// override project function of jsDataModel factory // override project function of jsDataModel factory
project: function (projectorId, tree) { project: function (projectorId, tree) {
var isProjectedId = this.isProjected(tree); var isProjectedIds = this.isProjected(tree);
if (isProjectedId > 0) { _.forEach(isProjectedIds, function (id) {
// Deactivate $http.post('/rest/core/projector/' + id + '/clear_elements/');
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/'); });
}
// Activate, if the projector_id is a new projector. // Activate, if the projector_id is a new projector.
if (isProjectedId != projectorId) { if (_.indexOf(isProjectedIds, projectorId) == -1) {
var name = tree ? 'agenda/item-list' : this.content_object.collection; var name = tree ? 'agenda/item-list' : this.content_object.collection;
var id = tree ? this.id : this.content_object.id; var id = tree ? this.id : this.content_object.id;
return $http.post( return $http.post(
@ -160,13 +159,11 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
}, },
// project list of speakers // project list of speakers
projectListOfSpeakers: function(projectorId) { projectListOfSpeakers: function(projectorId) {
var isProjectedId = this.isListOfSpeakersProjected(); var isProjectedIds = this.isListOfSpeakersProjected();
if (isProjectedId > 0) { _.forEach(isProjectedIds, function (id) {
// Deactivate $http.post('/rest/core/projector/' + id + '/clear_elements/');
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/'); });
} if (_.indexOf(isProjectedIds, projectorId) == -1) {
// Activate
if (isProjectedId != projectorId) {
return $http.post( return $http.post(
'/rest/core/projector/' + projectorId + '/prune_elements/', '/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: 'agenda/list-of-speakers', id: this.id}] [{name: 'agenda/list-of-speakers', id: this.id}]

View File

@ -255,12 +255,11 @@ angular.module('OpenSlidesApp.agenda.site', [
}; };
// project agenda // project agenda
$scope.projectAgenda = function (projectorId, tree, id) { $scope.projectAgenda = function (projectorId, tree, id) {
var isAgendaProjectedId = $scope.isAgendaProjected($scope.mainListTree); var isAgendaProjectedIds = $scope.isAgendaProjected($scope.mainListTree);
if (isAgendaProjectedId > 0) { _.forEach(isAgendaProjectedIds, function (id) {
// Deactivate $http.post('/rest/core/projector/' + id + '/clear_elements/');
$http.post('/rest/core/projector/' + isAgendaProjectedId + '/clear_elements/'); });
} if (_.indexOf(isAgendaProjectedIds, projectorId) == -1) {
if (isAgendaProjectedId != projectorId) {
$http.post('/rest/core/projector/' + projectorId + '/prune_elements/', $http.post('/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: 'agenda/item-list', tree: tree, id: id}]); [{name: 'agenda/item-list', tree: tree, id: id}]);
} }
@ -568,12 +567,11 @@ angular.module('OpenSlidesApp.agenda.site', [
// Project current list of speakers // Project current list of speakers
// same logic as in core/base.js // same logic as in core/base.js
$scope.projectCurrentLoS = function (projectorId) { $scope.projectCurrentLoS = function (projectorId) {
var isCurrentLoSProjectedId = $scope.isCurrentLoSProjected($scope.mainListTree); var isCurrentLoSProjectedIds = $scope.isCurrentLoSProjected($scope.mainListTree);
if (isCurrentLoSProjectedId > 0) { _.forEach(isCurrentLoSProjectedIds, function (id) {
// Deactivate $http.post('/rest/core/projector/' + id + '/clear_elements/');
$http.post('/rest/core/projector/' + isCurrentLoSProjectedId + '/clear_elements/'); });
} if (_.indexOf(isCurrentLoSProjectedIds, projectorId) == -1) {
if (isCurrentLoSProjectedId != projectorId) {
$http.post('/rest/core/projector/' + projectorId + '/prune_elements/', $http.post('/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: 'agenda/current-list-of-speakers'}]); [{name: 'agenda/current-list-of-speakers'}]);
} }

View File

@ -268,11 +268,11 @@ angular.module('OpenSlidesApp.assignments', [])
}, },
// override project function of jsDataModel factory // override project function of jsDataModel factory
project: function (projectorId, pollId) { project: function (projectorId, pollId) {
var isProjectedId = this.isProjected(pollId); var isProjectedIds = this.isProjected(pollId);
if (isProjectedId > 0) { _.forEach(isProjectedIds, function (id) {
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/'); $http.post('/rest/core/projector/' + id + '/clear_elements/');
} });
if (isProjectedId != projectorId) { if (_.indexOf(isProjectedIds, projectorId) == -1) {
return $http.post( return $http.post(
'/rest/core/projector/' + projectorId + '/prune_elements/', '/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: 'assignments/assignment', id: this.id, poll: pollId}] [{name: 'assignments/assignment', id: this.id, poll: pollId}]

View File

@ -391,11 +391,11 @@ angular.module('OpenSlidesApp.core', [
BaseModel.prototype.project = function(projectorId) { BaseModel.prototype.project = function(projectorId) {
// if this object is already projected on projectorId, delete this element from this projector // if this object is already projected on projectorId, delete this element from this projector
var isProjectedIds = this.isProjected(); var isProjectedIds = this.isProjected();
if (isProjectedIds.length > 0) { _.forEach(isProjectedIds, function (id) {
$http.post('/rest/core/projector/' + isProjectedIds[0] + '/clear_elements/'); $http.post('/rest/core/projector/' + id + '/clear_elements/');
} });
// if it was the same projector before, just delete it but not show again // Show the element, if it was not projected before on the given projector
if (isProjectedIds[0] != projectorId) { if (_.indexOf(isProjectedIds, projectorId) == -1) {
return $http.post( return $http.post(
'/rest/core/projector/' + projectorId + '/prune_elements/', '/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: this.getResourceName(), id: this.id}] [{name: this.getResourceName(), id: this.id}]

View File

@ -156,11 +156,11 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
// ** PDF presentation functions **/ // ** PDF presentation functions **/
// show document on projector // show document on projector
$scope.showMediafile = function (projectorId, mediafile) { $scope.showMediafile = function (projectorId, mediafile) {
var isProjectedId = mediafile.isProjected(); var isProjectedIds = mediafile.isProjected();
if (isProjectedId > 0) { _.forEach(isProjectedIds, function (id) {
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/'); $http.post('/rest/core/projector/' + id + '/clear_elements/');
} });
if (isProjectedId != projectorId) { if (_.indexOf(isProjectedIds, projectorId) == -1) {
var postUrl = '/rest/core/projector/' + projectorId + '/prune_elements/'; var postUrl = '/rest/core/projector/' + projectorId + '/prune_elements/';
var data = [{ var data = [{
name: 'mediafiles/mediafile', name: 'mediafiles/mediafile',