Skip to content

Commit

Permalink
Merge pull request #184 from mwaylabs/feature/tab-fix
Browse files Browse the repository at this point in the history
Feature/tab fix
  • Loading branch information
Yasin Abdelmonem authored Nov 24, 2017
2 parents 0c76491 + 0ac82ae commit 1684e54
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v1.21.1
## Bug Fixes
### Ui components module
- Fix bug that tab pane could not be selected by number anymore

# v1.21.0
## Features
### Backbone module
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mw-uikit",
"description": "A toolbox to build portals with AngularJS 1.5.x that have a lot of forms and list views for example admin portals to manage data.",
"author": "Alexander Zarges <[email protected]> (http://relution.io)",
"version": "1.21.0",
"version": "1.21.1",
"license": "Apache-2.0",
"devDependencies": {
"angular": "1.5.7",
Expand Down
17 changes: 9 additions & 8 deletions src/mw-ui-components/directives/mw_tab_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ angular.module('mwUI.UiComponents')
controller: function ($scope) {
// The panes are populated by the mw-tabs-pane directive that is calling `registerPane`of this controller
// It is defined as a scope attribute so it is available in this html template
var panes = $scope.panes = [],
activePaneIndex;
var activePaneIndex;

$scope.panes = [];

var setInitialSelection = function () {
activePaneIndex = null;

// In case that no active pane is defined by setting activePaneNumber or Id the first pane will be selected
if (angular.isUndefined($scope.activePaneNumber) && angular.isUndefined($scope.activePaneId) && panes.length>0) {
$scope.select(panes[0]);
if (angular.isUndefined($scope.activePaneNumber) && angular.isUndefined($scope.activePaneId) && $scope.panes.length>0) {
$scope.select($scope.panes[0]);

// When a pane number is defined the pane with the index of activePaneNumber + 1 will be selected
// So when the second tab shall be selected set activePaneNumber to 2
Expand Down Expand Up @@ -82,8 +83,8 @@ angular.module('mwUI.UiComponents')
};

$scope.selectTabByNumber = function (number) {
if (number > 0 && number <= $scope.tabs.length) {
$scope.select(panes[number - 1]);
if (number > 0 && number <= $scope.panes.length) {
$scope.select($scope.panes[number - 1]);
}
};

Expand Down Expand Up @@ -111,13 +112,13 @@ angular.module('mwUI.UiComponents')
});

this.registerPane = function (pane) {
panes.push(pane);
$scope.panes.push(pane);
throttledSetInitialSelection();
};

this.unRegisterPane = function (pane) {
if (pane) {
var indexOfExistingPane = _.indexOf(panes, pane);
var indexOfExistingPane = _.indexOf($scope.panes, pane);
if (indexOfExistingPane !== -1) {
$scope.panes.splice(indexOfExistingPane, 1);
}
Expand Down

0 comments on commit 1684e54

Please sign in to comment.