54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
|
/**
|
||
|
* An element which displays a list of selectable paths containing Dockerfiles.
|
||
|
*/
|
||
|
angular.module('quay').directive('dockerfilePathSelect', function () {
|
||
|
var directiveDefinitionObject = {
|
||
|
priority: 0,
|
||
|
templateUrl: '/static/directives/dockerfile-path-select.html',
|
||
|
replace: false,
|
||
|
transclude: true,
|
||
|
restrict: 'C',
|
||
|
scope: {
|
||
|
'currentPath': '=currentPath',
|
||
|
'isValidPath': '=?isValidPath',
|
||
|
'paths': '=paths',
|
||
|
'supportsFullListing': '=supportsFullListing'
|
||
|
},
|
||
|
controller: function($scope, $element) {
|
||
|
$scope.isUnknownPath = true;
|
||
|
$scope.selectedPath = null;
|
||
|
|
||
|
var checkPath = function() {
|
||
|
$scope.isUnknownPath = false;
|
||
|
$scope.isValidPath = false;
|
||
|
|
||
|
var path = $scope.currentPath || '';
|
||
|
if (path.length == 0 || path[0] != '/') {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$scope.isValidPath = true;
|
||
|
|
||
|
if (!$scope.paths) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$scope.isUnknownPath = $scope.supportsFullListing && $scope.paths.indexOf(path) < 0;
|
||
|
};
|
||
|
|
||
|
$scope.setPath = function(path) {
|
||
|
$scope.currentPath = path;
|
||
|
$scope.selectedPath = null;
|
||
|
};
|
||
|
|
||
|
$scope.setSelectedPath = function(path) {
|
||
|
$scope.currentPath = path;
|
||
|
$scope.selectedPath = path;
|
||
|
};
|
||
|
|
||
|
$scope.$watch('currentPath', checkPath);
|
||
|
$scope.$watch('paths', checkPath);
|
||
|
}
|
||
|
};
|
||
|
return directiveDefinitionObject;
|
||
|
});
|