Add tags for assingments

This commit is contained in:
joelmacht 2016-06-19 22:17:41 +02:00
parent 51c466f7cf
commit 19592f1eea
3 changed files with 58 additions and 5 deletions

View File

@ -43,6 +43,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
}
);
},
tags: function(Tag) {
return Tag.findAll();
},
phases: function(Assignment) {
return Assignment.getPhases();
}
@ -59,6 +62,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
users: function(User) {
return User.findAll();
},
tags: function(Tag) {
return Tag.findAll();
},
phases: function(Assignment) {
return Assignment.getPhases();
}
@ -99,7 +105,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
.factory('AssignmentForm', [
'gettextCatalog',
'operator',
function (gettextCatalog, operator) {
'Tag',
function (gettextCatalog, operator, Tag) {
return {
// ngDialog for assignment form
getDialog: function (assignment) {
@ -165,6 +172,25 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
description: gettextCatalog.getString('If deactivated the election appears as internal item on agenda.')
},
hide: !operator.hasPerms('assignments.can_manage')
},
{
key: 'more',
type: 'checkbox',
templateOptions: {
label: gettextCatalog.getString('Show extended fields')
},
hide: !operator.hasPerms('assignments.can_manage')
},
{
key: 'tags_id',
type: 'select-multiple',
templateOptions: {
label: gettextCatalog.getString('Tags'),
options: Tag.getAll(),
ngOptions: 'option.id as option.name for option in to.options',
placeholder: gettextCatalog.getString('Select or search a tag ...')
},
hideExpression: '!model.more'
}];
}
};
@ -176,9 +202,11 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'ngDialog',
'AssignmentForm',
'Assignment',
'Tag',
'phases',
function($scope, ngDialog, AssignmentForm, Assignment, phases) {
function($scope, ngDialog, AssignmentForm, Assignment, Tag, phases) {
Assignment.bindAll({}, $scope, 'assignments');
Tag.bindAll({}, $scope, 'tags');
$scope.phases = phases;
$scope.alert = {};
@ -200,7 +228,15 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
assignment.description,
$scope.phases[assignment.phase].display_name,
_.map(assignment.assignment_related_users,
function (candidate) {return candidate.user.get_short_name();}).join(" "),
function (candidate) {
return candidate.user.get_short_name();
}
).join(" "),
_.map(assignment.tags,
function (tag) {
return tag.name;
}
).join(" "),
].join(" ");
};

View File

@ -51,6 +51,11 @@
<!-- posts -->
<h3 translate>Number of posts to be elected</h3>
{{ assignment.open_posts }}<br>
<!-- Tags -->
<h3 ng-if="assignment.tags.length > 0" translate>Tags</h3>
<span ng-repeat="tag in assignment.tags">
{{ tag.name }}{{$last ? '' : ', '}}
</span>
</div>
<div class="col-md-6">
<!-- phase -->

View File

@ -138,6 +138,9 @@
<!-- title -->
<td ng-if="!assignment.quickEdit" ng-mouseover="assignment.hover=true" ng-mouseleave="assignment.hover=false">
<strong><a ui-sref="assignments.assignment.detail({id: assignment.id})">{{ assignment.title }}</a></strong>
<span ng-repeat="tag in assignment.tags" class="label label-default">
{{ tag.name }}
</span>
<div os-perms="assignments.can_manage" class="hoverActions" ng-class="{'hiddenDiv': !assignment.hover}">
<a href="" ng-click="openDialog(assignment)" translate>Edit</a> |
<a href="" ng-click="assignment.quickEdit=true" translate>QuickEdit</a> |
@ -184,7 +187,16 @@
ng-model="assignment.phase" class="form-control" id="selectPhase">
</select>
</div>
<div class="col-xs-6"></div>
<div class="col-xs-6">
<label for="selectTags" translate>Tags</label>
<select multiple chosen
ng-model="assignment.tags_id"
ng-options="tag.id as tag.name for tag in tags"
search-contains="true"
id="selectTag"
class="form-control">
</select>
</div>
</div>
<div class="spacer">
<button ng-click="cancelQuickEdit(assignment)" class="btn btn-default pull-left" translate>