Added meta box in assignment detail view (Fixes #1866)

This commit is contained in:
Emanuel Schuetze 2016-01-17 21:47:07 +01:00
parent 851252dfe8
commit 8bf82a0306
2 changed files with 49 additions and 2 deletions

View File

@ -49,6 +49,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
}, },
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll();
},
phases: function(Assignment) {
return Assignment.getPhases();
} }
} }
}) })
@ -122,7 +125,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
key: 'open_posts', key: 'open_posts',
type: 'input', type: 'input',
templateOptions: { templateOptions: {
label: gettextCatalog.getString('Number of members to be elected'), label: gettextCatalog.getString('Number of posts to be elected'),
type: 'number', type: 'number',
required: true required: true
} }
@ -225,11 +228,14 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'Assignment', 'Assignment',
'User', 'User',
'assignment', 'assignment',
function($scope, $http, gettext, ngDialog, AssignmentForm, operator, Assignment, User, assignment) { 'phases',
function($scope, $http, gettext, ngDialog, AssignmentForm, operator, Assignment, User, assignment, phases) {
User.bindAll({}, $scope, 'users'); User.bindAll({}, $scope, 'users');
Assignment.bindOne(assignment.id, $scope, 'assignment'); Assignment.bindOne(assignment.id, $scope, 'assignment');
Assignment.loadRelations(assignment, 'agenda_item'); Assignment.loadRelations(assignment, 'agenda_item');
$scope.candidateSelectBox = {}; $scope.candidateSelectBox = {};
// get all item types via OPTIONS request
$scope.phases = phases.data.actions.POST.phase.choices;
$scope.alert = {}; $scope.alert = {};
// open edit dialog // open edit dialog
@ -289,6 +295,11 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
else else
return false; return false;
}; };
// update phase
$scope.updatePhase = function (phase_id) {
assignment.phase = phase_id;
Assignment.save(assignment);
}
// create new ballot // create new ballot
$scope.createBallot = function () { $scope.createBallot = function () {
$http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/') $http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/')

View File

@ -39,6 +39,42 @@
</div> </div>
</div> </div>
<div class="meta">
<div class="title" ng-click="isMeta = !isMeta">
<div class="name">
<i class="fa fa-info-circle"></i>
<translate>Meta information</translate>
</div>
<div class="icon">
<i class="fa fa-lg" ng-class="isMeta ? 'fa-angle-down' : 'fa-angle-up'"></i>
</div>
</div>
<div class="detail" uib-collapse="isMeta">
<div class="row">
<div class="col-md-6">
<!-- posts -->
<h3 translate>Number of posts to be elected</h3>
{{ assignment.open_posts }}<br>
</div>
<div class="col-md-6">
<!-- phase -->
<h3 translate>Phase</h3>
<span class="label" ng-class="{'label-primary': assignment.phase == 0,
'label-warning': assignment.phase == 1,
'label-success': assignment.phase == 2 }">
{{ phases[assignment.phase].display_name | translate }}
</span>
<div os-perms="assignments.can_manage" class="spacer">
<select ng-model="phaseSelect" class="form-control" ng-change="updatePhase(phaseSelect)">
<option value="" translate>--- Set phase ---</option>
<option ng-repeat="phase in phases" value="{{ phase.value }}">{{ phase.display_name }}</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="details"> <div class="details">
<h3 translate>Description</h3> <h3 translate>Description</h3>
<div class="white-space-pre-line">{{ assignment.description }}</div> <div class="white-space-pre-line">{{ assignment.description }}</div>