forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
labels.js
48 lines (47 loc) · 1.56 KB
/
labels.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
angular.module('openshiftConsole')
.directive('labels', function($location, $timeout, LabelFilter) {
return {
restrict: 'E',
scope: {
labels: '=',
// if you specify clickable, then everything below is required unless specified as optional
clickable: "@?",
kind: "@?",
projectName: "@?",
limit: '=?',
titleKind: '@?', // optional, instead of putting kind into that part of the hover
// title, it will put this string instead, e.g. if you want 'builds for build config foo'
navigateUrl: '@?' // optional to override the default
},
templateUrl: 'views/directives/labels.html',
link: function(scope) {
scope.filterAndNavigate = function(key, value) {
if (scope.kind && scope.projectName) {
$location.url(scope.navigateUrl || ("/project/" + scope.projectName + "/browse/" + scope.kind));
$timeout(function() {
var selector = {};
selector[key] = value;
LabelFilter.setLabelSelector(new LabelSelector(selector, true));
}, 1);
}
};
}
};
})
.directive('labelEditor', function() {
return {
restrict: 'E',
scope: {
labels: "=",
expand: "=?",
canToggle: "=?"
},
templateUrl: 'views/directives/label-editor.html',
link: function(scope, element, attrs) {
if (!angular.isDefined(attrs.canToggle)) {
scope.canToggle = true;
}
}
};
});