Abstract out the display of entities (users, robot accounts, and teams) into a nice directive to ensure that we always display the correctly formatted entity information (icon and name)

This commit is contained in:
Joseph Schorr 2013-11-26 14:37:55 -05:00
parent 72acc8769b
commit d5c0f768c2
8 changed files with 63 additions and 35 deletions

View file

@ -460,6 +460,37 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
});
quayApp.directive('entityReference', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/entity-reference.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'name': '=name',
'orgname': '=orgname',
'team': '=team',
'isrobot': '=isrobot'
},
controller: function($scope, $element) {
$scope.getPrefix = function(name) {
if (!name) { return ''; }
var plus = name.indexOf('+');
return name.substr(0, plus + 1);
};
$scope.getShortenedName = function(name) {
if (!name) { return ''; }
var plus = name.indexOf('+');
return name.substr(plus + 1);
};
}
};
return directiveDefinitionObject;
});
quayApp.directive('markdownView', function () {
var directiveDefinitionObject = {
priority: 0,

View file

@ -427,16 +427,6 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
$scope.permissions = {'team': [], 'user': []};
$scope.getPrefix = function(name) {
var plus = name.indexOf('+');
return name.substr(0, plus + 1);
};
$scope.getShortenedName = function(name) {
var plus = name.indexOf('+');
return name.substr(plus + 1);
};
$scope.grantRole = function() {
$('#confirmaddoutsideModal').modal('hide');
var entity = $scope.currentAddEntity;