Skip to content

Commit

Permalink
Merge pull request #918 from jwforres/bug_1189390_empty_project_selector
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Feb 5, 2015
2 parents b9426c4 + 0199374 commit 2275083
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 39 deletions.
56 changes: 37 additions & 19 deletions assets/app/scripts/directives/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,44 @@ angular.module('openshiftConsole')
},
templateUrl: 'views/_project-nav.html',
link: function ($scope, element, attrs) {
// The double timeout is a hack to guarantee DOM is finished rendering
$timeout(function () {
$timeout(function () {
$('.selectpicker').selectpicker({
iconBase: 'fa',
tickIcon: 'fa-check'
}).change(function() {
var newProject = $( this ).val();
var currentURL = $location.url();
var currProjRegex = /\/project\/[^\/]+/;
var currProjPrefix = currProjRegex.exec(currentURL);
var newURL = currentURL.replace(currProjPrefix, "/project/" + encodeURIComponent(newProject));
$scope.$apply(function() {
$location.url(newURL);
});
});
var select = $('.selectpicker', element);

LabelFilter.setupFilterWidget($(".navbar-filter-widget", element), $(".active-filters", element));
}, 0);
}, 0);
var updateOptions = function(projects) {
$each(projects, function(name, project) {
$('<option>')
.attr("value", project.metadata.name)
.attr("selected", project.metadata.name == $scope.selected)
.text(project.displayName || project.metadata.name)
.appendTo(select);
});
// TODO add back in when we support create project
// <option data-divider="true"></option>
// <option>Create new</option>
};

updateOptions($scope.projects);

select.selectpicker({
iconBase: 'fa',
tickIcon: 'fa-check'
}).change(function() {
var newProject = $( this ).val();
var currentURL = $location.url();
var currProjRegex = /\/project\/[^\/]+/;
var currProjPrefix = currProjRegex.exec(currentURL);
var newURL = currentURL.replace(currProjPrefix, "/project/" + encodeURIComponent(newProject));
$scope.$apply(function() {
$location.url(newURL);
});
});

LabelFilter.setupFilterWidget($(".navbar-filter-widget", element), $(".active-filters", element));

$scope.$watch("projects", function(projects) {
select.empty();
updateOptions(projects);
select.selectpicker('refresh');
});
}
};
})
Expand Down
8 changes: 1 addition & 7 deletions assets/app/views/_project-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
<div class="form-group">
<label class="control-label" for="boostrapSelect">Projects</label>
<!-- TODO add multiple attribute back to the select tag when we support selecting multiple -->
<select class="selectpicker form-control" data-selected-text-format="count>3" id="boostrapSelect">
<option ng-selected="selected == proj.metadata.name" ng-repeat="proj in projects" value="{{proj.metadata.name}}">{{proj.displayName || proj.metadata.name}}</option>
<!-- TODO add back in when we support create project
<option data-divider="true"></option>
<option>Create new</option>
-->
</select>
<select class="selectpicker form-control" data-selected-text-format="count>3" id="boostrapSelect"></select>
</div>
</div>
<div class="navbar-search filter">
Expand Down
26 changes: 13 additions & 13 deletions pkg/assets/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -13419,20 +13419,23 @@ projects:"=",
selected:"="
},
templateUrl:"views/_project-nav.html",
link:function(d, e) {
a(function() {
a(function() {
$(".selectpicker").selectpicker({
link:function(a, d) {
var e = $(".selectpicker", d), f = function(b) {
$each(b, function(b, c) {
$("<option>").attr("value", c.metadata.name).attr("selected", c.metadata.name == a.selected).text(c.displayName || c.metadata.name).appendTo(e);
});
};
f(a.projects), e.selectpicker({
iconBase:"fa",
tickIcon:"fa-check"
}).change(function() {
var a = $(this).val(), c = b.url(), e = /\/project\/[^\/]+/, f = e.exec(c), g = c.replace(f, "/project/" + encodeURIComponent(a));
d.$apply(function() {
var c = $(this).val(), d = b.url(), e = /\/project\/[^\/]+/, f = e.exec(d), g = d.replace(f, "/project/" + encodeURIComponent(c));
a.$apply(function() {
b.url(g);
});
}), c.setupFilterWidget($(".navbar-filter-widget", e), $(".active-filters", e));
}, 0);
}, 0);
}), c.setupFilterWidget($(".navbar-filter-widget", d), $(".active-filters", d)), a.$watch("projects", function(a) {
e.empty(), f(a), e.selectpicker("refresh");
});
}
};
} ]).directive("projectPage", function() {
Expand Down Expand Up @@ -55307,10 +55310,7 @@ func views_pods_html() ([]byte, error) {
return _views_pods_html, nil
}

var _views_project_nav_html = []byte(`<div class="navbar-project"> <div class="navbar-project-menu"> <div class="form-group"> <label class="control-label" for="boostrapSelect">Projects</label> <!-- TODO add multiple attribute back to the select tag when we support selecting multiple --> <select class="selectpicker form-control" data-selected-text-format="count>3" id="boostrapSelect"> <option ng-selected="selected == proj.metadata.name" ng-repeat="proj in projects" value="{{proj.metadata.name}}">{{proj.displayName || proj.metadata.name}} <!-- TODO add back in when we support create project
<option data-divider="true"></option>
<option>Create new</option>
--> </select> </div> </div> <div class="navbar-search filter"> <div class="container-fluid"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Filter by labels</label> <div class="navbar-filter-widget"> </div> </div> </div> <div class="col-md-6 active-filters"> </div> </div> </div> </div> </div>`)
var _views_project_nav_html = []byte(`<div class="navbar-project"> <div class="navbar-project-menu"> <div class="form-group"> <label class="control-label" for="boostrapSelect">Projects</label> <!-- TODO add multiple attribute back to the select tag when we support selecting multiple --> <select class="selectpicker form-control" data-selected-text-format="count>3" id="boostrapSelect"></select> </div> </div> <div class="navbar-search filter"> <div class="container-fluid"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label class="control-label">Filter by labels</label> <div class="navbar-filter-widget"> </div> </div> </div> <div class="col-md-6 active-filters"> </div> </div> </div> </div> </div>`)

func views_project_nav_html() ([]byte, error) {
return _views_project_nav_html, nil
Expand Down

0 comments on commit 2275083

Please sign in to comment.