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
project: function (projectorId, tree) {
var isProjectedId = this.isProjected(tree);
if (isProjectedId > 0) {
// Deactivate
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/');
}
var isProjectedIds = this.isProjected(tree);
_.forEach(isProjectedIds, function (id) {
$http.post('/rest/core/projector/' + id + '/clear_elements/');
});
// 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 id = tree ? this.id : this.content_object.id;
return $http.post(
@ -160,13 +159,11 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
},
// project list of speakers
projectListOfSpeakers: function(projectorId) {
var isProjectedId = this.isListOfSpeakersProjected();
if (isProjectedId > 0) {
// Deactivate
$http.post('/rest/core/projector/' + isProjectedId + '/clear_elements/');
}
// Activate
if (isProjectedId != projectorId) {
var isProjectedIds = this.isListOfSpeakersProjected();
_.forEach(isProjectedIds, function (id) {
$http.post('/rest/core/projector/' + id + '/clear_elements/');
});
if (_.indexOf(isProjectedIds, projectorId) == -1) {
return $http.post(
'/rest/core/projector/' + projectorId + '/prune_elements/',
[{name: 'agenda/list-of-speakers', id: this.id}]

View File

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

View File

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

View File

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

View File

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