create MotionPoll in JS
This commit is contained in:
parent
798126551b
commit
2495ba609b
@ -97,6 +97,7 @@ class MotionPollSerializer(ModelSerializer):
|
||||
model = MotionPoll
|
||||
fields = (
|
||||
'id',
|
||||
'motion',
|
||||
'yes',
|
||||
'no',
|
||||
'abstain',
|
||||
|
@ -2,10 +2,20 @@
|
||||
|
||||
angular.module('OpenSlidesApp.motions', [])
|
||||
|
||||
.factory('MotionPoll', [
|
||||
'DS',
|
||||
function(DS) {
|
||||
return DS.defineResource({
|
||||
name: 'motions/motionpoll',
|
||||
});
|
||||
}
|
||||
])
|
||||
|
||||
.factory('Motion', [
|
||||
'DS',
|
||||
'MotionPoll',
|
||||
'jsDataModel',
|
||||
function(DS, jsDataModel) {
|
||||
function(DS, MotionPoll, jsDataModel) {
|
||||
var name = 'motions/motion'
|
||||
return DS.defineResource({
|
||||
name: name,
|
||||
@ -70,6 +80,10 @@ angular.module('OpenSlidesApp.motions', [])
|
||||
localKeys: 'supporters_id',
|
||||
}
|
||||
],
|
||||
'motions/motionpoll': {
|
||||
localField: 'polls',
|
||||
foreignKey: 'motion_id',
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -252,12 +266,34 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
|
||||
};
|
||||
})
|
||||
|
||||
.controller('MotionDetailCtrl', function($scope, Motion, Category, User, motion) {
|
||||
.controller('MotionDetailCtrl', [
|
||||
'$scope',
|
||||
'Motion',
|
||||
'Category',
|
||||
'User',
|
||||
'motion',
|
||||
'$http',
|
||||
function($scope, Motion, Category, User, motion, $http) {
|
||||
Motion.bindOne(motion.id, $scope, 'motion');
|
||||
Category.bindAll({}, $scope, 'categories');
|
||||
User.bindAll({}, $scope, 'users');
|
||||
Motion.loadRelations(motion);
|
||||
|
||||
$scope.create_poll = function () {
|
||||
$http.post('/rest/motions/motion/' + motion.id + '/create_poll/', {})
|
||||
.success(function(data){
|
||||
$scope.alert.show = false;
|
||||
})
|
||||
.error(function(data){
|
||||
$scope.alert = { type: 'danger', msg: data.detail, show: true };
|
||||
});
|
||||
}
|
||||
|
||||
$scope.delete_poll = function (poll) {
|
||||
poll.DSDestroy();
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
.controller('MotionCreateCtrl',
|
||||
function($scope, $state, $http, Motion, Agenda, User, Category, Workflow, Tag, Mediafile) {
|
||||
|
@ -39,6 +39,12 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<a href="#" ng-click="create_poll()">Create Poll</a>
|
||||
<div ng-repeat="poll in motion.polls">
|
||||
{{ poll.id }}
|
||||
<a href="#" ng-click="delete_poll(poll)">delete</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h3 translate>Text</h3>
|
||||
|
Loading…
Reference in New Issue
Block a user