Skip to content

Commit

Permalink
modify the logic of tab selection after deleting rpc setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Aug 26, 2018
1 parent d859e94 commit 4be5492
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/scripts/controllers/settings-ariang.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
return $scope.context.currentTab === 'rpc' + rpcIndex;
};

$scope.getCurrentRpcTabIndex = function () {
if ($scope.isCurrentGlobalTab()) {
return -1;
}

return parseInt($scope.context.currentTab.substring(3));
};

$scope.updateTitlePreview = function () {
$scope.context.titlePreview = getFinalTitle();
};
Expand All @@ -74,7 +82,7 @@
var tabIndex = -1;

if (!$scope.isCurrentGlobalTab()) {
tabIndex = parseInt($scope.context.currentTab.substring(3));
tabIndex = parseInt($scope.getCurrentRpcTabIndex());
}

if (tabIndex < $scope.context.rpcSettings.length - 1) {
Expand All @@ -89,7 +97,7 @@
var tabIndex = -1;

if (!$scope.isCurrentGlobalTab()) {
tabIndex = parseInt($scope.context.currentTab.substring(3));
tabIndex = parseInt($scope.getCurrentRpcTabIndex());
}

if (tabIndex > 0) {
Expand Down Expand Up @@ -246,12 +254,17 @@
ariaNgLocalizationService.confirm('Confirm Remove', 'Are you sure you want to remove rpc setting "{{rpcName}}"?', 'warning', function () {
setNeedRefreshPage();

var currentIndex = $scope.getCurrentRpcTabIndex();
var index = $scope.context.rpcSettings.indexOf(setting);
ariaNgSettingService.removeRpcSetting(setting);
$scope.context.rpcSettings.splice(index, 1);

if ($scope.isCurrentRpcTab(index) && index >= $scope.context.rpcSettings.length) {
if (currentIndex >= $scope.context.rpcSettings.length) {
$scope.changeRpcTab($scope.context.rpcSettings.length - 1);
} else if (currentIndex <= 0 || currentIndex <= index) {
; // Do Nothing
} else { // currentIndex > index
$scope.changeRpcTab(currentIndex - 1);
}
}, false, {
textParams: {
Expand Down

0 comments on commit 4be5492

Please sign in to comment.