create MotionPoll in JS
This commit is contained in:
parent
798126551b
commit
2495ba609b
@ -97,6 +97,7 @@ class MotionPollSerializer(ModelSerializer):
|
|||||||
model = MotionPoll
|
model = MotionPoll
|
||||||
fields = (
|
fields = (
|
||||||
'id',
|
'id',
|
||||||
|
'motion',
|
||||||
'yes',
|
'yes',
|
||||||
'no',
|
'no',
|
||||||
'abstain',
|
'abstain',
|
||||||
|
@ -2,10 +2,20 @@
|
|||||||
|
|
||||||
angular.module('OpenSlidesApp.motions', [])
|
angular.module('OpenSlidesApp.motions', [])
|
||||||
|
|
||||||
|
.factory('MotionPoll', [
|
||||||
|
'DS',
|
||||||
|
function(DS) {
|
||||||
|
return DS.defineResource({
|
||||||
|
name: 'motions/motionpoll',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
.factory('Motion', [
|
.factory('Motion', [
|
||||||
'DS',
|
'DS',
|
||||||
|
'MotionPoll',
|
||||||
'jsDataModel',
|
'jsDataModel',
|
||||||
function(DS, jsDataModel) {
|
function(DS, MotionPoll, jsDataModel) {
|
||||||
var name = 'motions/motion'
|
var name = 'motions/motion'
|
||||||
return DS.defineResource({
|
return DS.defineResource({
|
||||||
name: name,
|
name: name,
|
||||||
@ -70,6 +80,10 @@ angular.module('OpenSlidesApp.motions', [])
|
|||||||
localKeys: 'supporters_id',
|
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');
|
Motion.bindOne(motion.id, $scope, 'motion');
|
||||||
Category.bindAll({}, $scope, 'categories');
|
Category.bindAll({}, $scope, 'categories');
|
||||||
User.bindAll({}, $scope, 'users');
|
User.bindAll({}, $scope, 'users');
|
||||||
Motion.loadRelations(motion);
|
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',
|
.controller('MotionCreateCtrl',
|
||||||
function($scope, $state, $http, Motion, Agenda, User, Category, Workflow, Tag, Mediafile) {
|
function($scope, $state, $http, Motion, Agenda, User, Category, Workflow, Tag, Mediafile) {
|
||||||
|
@ -39,6 +39,12 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</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="row">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<h3 translate>Text</h3>
|
<h3 translate>Text</h3>
|
||||||
|
Loading…
Reference in New Issue
Block a user