Get a nice dropdown of tags working on the visualize tags tab
This commit is contained in:
parent
be9906167a
commit
5741656411
8 changed files with 431 additions and 18 deletions
35
static/js/directives/ui/multiselect-dropdown.js
Normal file
35
static/js/directives/ui/multiselect-dropdown.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* An element which displays a dropdown for selecting multiple elements.
|
||||
*/
|
||||
angular.module('quay').directive('multiselectDropdown', function ($compile) {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/multiselect-dropdown.html',
|
||||
transclude: true,
|
||||
replace: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'items': '=items',
|
||||
'selectedItems': '=selectedItems',
|
||||
'itemName': '@itemName',
|
||||
'itemChecked': '&itemChecked'
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
$scope.isChecked = function(checked, item) {
|
||||
return checked.indexOf(item) >= 0;
|
||||
};
|
||||
|
||||
$scope.toggleItem = function(item) {
|
||||
var isChecked = $scope.isChecked($scope.selectedItems, item);
|
||||
if (!isChecked) {
|
||||
$scope.selectedItems.push(item);
|
||||
} else {
|
||||
var index = $scope.selectedItems.indexOf(item);
|
||||
$scope.selectedItems.splice(index, 1);
|
||||
}
|
||||
$scope.itemChecked({'item': item, 'checked': !isChecked});
|
||||
};
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue