Merge pull request #1753 from emanuelschuetze/fix1704

Project related object (Fixes #1704)
This commit is contained in:
Norman Jäckel 2015-12-11 15:25:56 +01:00
commit c73671805e
4 changed files with 35 additions and 19 deletions

View File

@ -22,12 +22,13 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
])
.factory('Agenda', [
'$http',
'DS',
'Speaker',
'jsDataModel',
'Projector',
'gettextCatalog',
function(DS, Speaker, jsDataModel, Projector, gettextCatalog) {
function($http, DS, Speaker, jsDataModel, Projector, gettextCatalog) {
var name = 'agenda/item';
return DS.defineResource({
name: name,
@ -56,6 +57,14 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
}
return title;
},
// override project function of jsDataModel factory
project: function() {
return $http.post(
'/rest/core/projector/1/prune_elements/',
[{name: this.content_object.collection, id: this.content_object.id}]
);
},
// override isProjected function of jsDataModel factory
isProjected: function () {
var projector = Projector.get(1);
if (typeof projector === 'undefined') return false;
@ -66,6 +75,27 @@ angular.module('OpenSlidesApp.agenda', ['OpenSlidesApp.users'])
element.id == self.content_object.id;
};
return typeof _.findKey(projector.elements, predicate) === 'string';
},
// project list of speakers
projectListOfSpeakers: function() {
return $http.post(
'/rest/core/projector/1/prune_elements/',
[{name: 'agenda/item', id: this.id, list_of_speakers: true}]
);
},
// check if list of speakers is projected
isListOfSpeakersProjected: function () {
// Returns true if there is a projector element with the same
// name and agenda is active.
var projector = Projector.get(1);
if (typeof projector === 'undefined') return false;
var self = this;
var predicate = function (element) {
return element.name == 'agenda/item' &&
element.id == self.id &&
element.list_of_speakers;
};
return typeof _.findKey(projector.elements, predicate) === 'string';
}
},
relations: {

View File

@ -86,15 +86,6 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.alert = {};
$scope.isFilter = true;
// project related item (content object)
$scope.project = function (item) {
item.getContentResource().find(item.content_object.id).then(
function(object) {
object.project();
}
);
};
// open new dialog
$scope.newDialog = function () {
ngDialog.open({
@ -244,11 +235,6 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
$scope.alert = { type: 'danger', msg: data.detail, show: true };
});
};
// project list of speakers
$scope.projectListOfSpeakers = function () {
$http.post('/rest/core/projector/1/prune_elements/',
[{name: 'agenda/item', id: item.id, list_of_speakers: true}]);
};
}
])

View File

@ -5,10 +5,10 @@
<i class="fa fa-angle-double-left fa-lg"></i>
<translate>Back to agenda</translate>
</a>
<!-- TODO: project list
ng-class="{ 'btn-primary': item.isListOfSpeakersProjected() }"-->
<!-- project list of speakers -->
<a os-perms="core.can_manage_projector" class="btn btn-default btn-sm"
ng-click="projectListOfSpeakers()">
ng-class="{ 'btn-primary': item.isListOfSpeakersProjected() }"
ng-click="item.projectListOfSpeakers()">
<i class="fa fa-video-camera"></i>
<translate>List of speakers</translate>
</a>

View File

@ -123,7 +123,7 @@
<td ng-show="!isDeleteMode" os-perms="core.can_manage_projector">
<a class="btn btn-default btn-sm"
ng-class="{ 'btn-primary': item.isProjected() }"
ng-click="project(item)"
ng-click="item.project()"
title="{{ 'Project item' | translate }}">
<i class="fa fa-video-camera"></i>
</a>