Skip to content

Commit

Permalink
Bug fix #134: Allow user enable/disable multiple repositories at once
Browse files Browse the repository at this point in the history
When user selects multiple repositories with the same state (enabled or
disabled), he/she will be able to perform the action on all them.
Otherwise, the 'Enable/Disable' button will be disabled as the selected
repositories has different state.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
  • Loading branch information
alinefm authored and danielhb committed Dec 19, 2016
1 parent 9c61cfd commit d8b9b8c
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions ui/js/src/gingerbase.host-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ gingerbase.init_update = function() {
$(this).attr('disabled', false);
}
});
}else if(toEnable === 'enable'){
$.each($('#'+repositoriesGrid.selectButtonContainer[0].id+' ul.dropdown-menu .btn'), function(i,button){
if($(this).attr('id') === 'repositories-grid-edit-button'){
$(this).attr('disabled', true);
}else {
$(this).attr('disabled', false);
}
});
}else {
$.each($('#'+repositoriesGrid.selectButtonContainer[0].id+' ul.dropdown-menu .btn'), function(i,button){
if($(this).attr('id') === 'repositories-grid-add-button'){
Expand Down Expand Up @@ -140,11 +148,14 @@ gingerbase.init_update = function() {
if (!repository) {
return;
}
var name = repository[0]['repo_id'];
var enable = !repository[0]['enabled'];
enableRepositoryButtons(false);
gingerbase.enableRepository(name, enable, function() {
wok.topic('gingerbase/repositoryUpdated').publish();

$.each(repository, function(index, repo){
var name = repo['repo_id'];
var enable = !repo['enabled'];
enableRepositoryButtons(false);
gingerbase.enableRepository(name, enable, function() {
wok.topic('gingerbase/repositoryUpdated').publish();
});
});
} else {
return false;
Expand Down Expand Up @@ -248,7 +259,20 @@ gingerbase.init_update = function() {
actionHtml = ['<i class="fa',' ',actionIcon,'"></i>',' ',actionText].join('');
$('#repositories-grid-enable-button').html(actionHtml);
} else {
enableRepositoryButtons('some');
var repoState = repository[0]['enabled'];
var diff = false;
$.each(repository, function(index, repo){
if (repo['enabled'] != repoState) {
diff = true;
return false;
}
});
if (diff) {
enableRepositoryButtons('some');
}
else {
enableRepositoryButtons('enable');
}
}
},
frozenFields: [],
Expand Down

0 comments on commit d8b9b8c

Please sign in to comment.