Merge pull request #2204 from joelmacht/is#2110

Add tags for assignments (partly fixes Issue #2110)
This commit is contained in:
Norman Jäckel 2016-08-03 15:54:59 +02:00 committed by GitHub
commit fdfdd2e2a5
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) { phases: function(Assignment) {
return Assignment.getPhases(); return Assignment.getPhases();
} }
@ -59,6 +62,9 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll();
}, },
tags: function(Tag) {
return Tag.findAll();
},
phases: function(Assignment) { phases: function(Assignment) {
return Assignment.getPhases(); return Assignment.getPhases();
} }
@ -99,7 +105,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
.factory('AssignmentForm', [ .factory('AssignmentForm', [
'gettextCatalog', 'gettextCatalog',
'operator', 'operator',
function (gettextCatalog, operator) { 'Tag',
function (gettextCatalog, operator, Tag) {
return { return {
// ngDialog for assignment form // ngDialog for assignment form
getDialog: function (assignment) { 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.') description: gettextCatalog.getString('If deactivated the election appears as internal item on agenda.')
}, },
hide: !operator.hasPerms('assignments.can_manage') 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', 'ngDialog',
'AssignmentForm', 'AssignmentForm',
'Assignment', 'Assignment',
'Tag',
'phases', 'phases',
function($scope, ngDialog, AssignmentForm, Assignment, phases) { function($scope, ngDialog, AssignmentForm, Assignment, Tag, phases) {
Assignment.bindAll({}, $scope, 'assignments'); Assignment.bindAll({}, $scope, 'assignments');
Tag.bindAll({}, $scope, 'tags');
$scope.phases = phases; $scope.phases = phases;
$scope.alert = {}; $scope.alert = {};
@ -200,7 +228,15 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
assignment.description, assignment.description,
$scope.phases[assignment.phase].display_name, $scope.phases[assignment.phase].display_name,
_.map(assignment.assignment_related_users, _.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(" "); ].join(" ");
}; };
@ -545,7 +581,7 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
'no': '' 'no': ''
}; };
} }
if (option.votes.length) { if (option.votes.length) {
defaultValue.yes = option.votes[0].weight; defaultValue.yes = option.votes[0].weight;
defaultValue.no = option.votes[1].weight; defaultValue.no = option.votes[1].weight;

View File

@ -51,6 +51,11 @@
<!-- posts --> <!-- posts -->
<h3 translate>Number of posts to be elected</h3> <h3 translate>Number of posts to be elected</h3>
{{ assignment.open_posts }}<br> {{ 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>
<div class="col-md-6"> <div class="col-md-6">
<!-- phase --> <!-- phase -->

View File

@ -138,6 +138,9 @@
<!-- title --> <!-- title -->
<td ng-if="!assignment.quickEdit" ng-mouseover="assignment.hover=true" ng-mouseleave="assignment.hover=false"> <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> <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}"> <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="openDialog(assignment)" translate>Edit</a> |
<a href="" ng-click="assignment.quickEdit=true" translate>QuickEdit</a> | <a href="" ng-click="assignment.quickEdit=true" translate>QuickEdit</a> |
@ -184,7 +187,16 @@
ng-model="assignment.phase" class="form-control" id="selectPhase"> ng-model="assignment.phase" class="form-control" id="selectPhase">
</select> </select>
</div> </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>
<div class="spacer"> <div class="spacer">
<button ng-click="cancelQuickEdit(assignment)" class="btn btn-default pull-left" translate> <button ng-click="cancelQuickEdit(assignment)" class="btn btn-default pull-left" translate>