Skip to content

Commit

Permalink
closing tabs behavior #1014
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Oct 18, 2016
1 parent 153e4fc commit a2db25b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/admin/src/resources/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
};

$scope.closeTab = function(tab, index) {
$scope.tabService.remove(index);
$scope.tabService.remove(index, $scope);
};

$scope.switchTo = function(type, reset) {
Expand Down
9 changes: 8 additions & 1 deletion modules/admin/src/resources/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,15 @@ zaa.factory("CrudTabService", function() {

service.tabs = [];

service.remove = function(index) {
service.remove = function(index, $scope) {
service.tabs.splice(index, 1);

if (service.tabs.length > 0) {
var lastTab = service.tabs.slice(-1)[0];
lastTab.active = true;
} else {
$scope.switchTo(0);
}
};

service.addTab = function(id, api, arrayIndex, name, modelClass) {
Expand Down

0 comments on commit a2db25b

Please sign in to comment.