Merge "Fix bug that prevent saving layout"

This commit is contained in:
Jenkins 2015-08-12 15:21:44 +00:00 committed by Gerrit Code Review
commit bc982cabde
4 changed files with 22 additions and 27 deletions

View File

@ -8,18 +8,16 @@
{ {
"type": "tabpanel", "type": "tabpanel",
"attributes": { "attributes": {
"navigation": [ "navigation": {
{ "openProblems" : {
"title": "Open problems", "title": "Open problems",
"panelId": "openProblems",
"provider": "nbServicesHostsOpenProblems" "provider": "nbServicesHostsOpenProblems"
}, },
{ "allProblems": {
"title": "All problems", "title": "All problems",
"panelId": "allProblems",
"provider": "nbServicesHostsProblems" "provider": "nbServicesHostsProblems"
} }
] }
}, },
"components": [ "components": [
{ {
@ -74,18 +72,16 @@
{ {
"type": "tabpanel", "type": "tabpanel",
"attributes": { "attributes": {
"navigation": [ "navigation": {
{ "openProblems": {
"title": "Open Problems", "title": "Open Problems",
"panelId": "openProblems",
"provider": "nbServicesHostsOpenProblems" "provider": "nbServicesHostsOpenProblems"
}, },
{ "allProblems": {
"title": "All Problems", "title": "All Problems",
"panelId": "allProblems",
"provider": "nbServicesHostsOpenProblemsDoubleCount" "provider": "nbServicesHostsOpenProblemsDoubleCount"
} }
] }
}, },
"components": [ "components": [
{ {

View File

@ -1,5 +1,5 @@
<div role="tabpanel" class="tab-pane" data-ng-class="{active: parent.currentPanel === index }" <div role="tabpanel" class="tab-pane" data-ng-class="{active: parent.currentPanel === options.attributes.panelId }"
id="{{options.attributes.panelId}}" data-ng-show="parent.currentPanel === index"> id="{{options.attributes.panelId}}" data-ng-show="parent.currentPanel === options.attributes.panelId">
<section class="main__content tabpanel"> <section class="main__content tabpanel">
<bansho-components components="options.components"></bansho-components> <bansho-components components="options.components"></bansho-components>
</section> </section>

View File

@ -1,9 +1,9 @@
<section class="main__content tabpanel"> <section class="main__content tabpanel">
<nav> <nav>
<ul class="tablist clearfix"> <ul class="tablist clearfix">
<li role="presentation" class="tablist__item" data-ng-repeat="(index, panel) in navigation" <li role="presentation" class="tablist__item" data-ng-repeat="(key, panel) in options.attributes.navigation"
ng-class="{active: currentPanel === index }"> ng-class="{active: currentPanel === key}">
<a ng-click="setIsShown(index)" <a ng-click="setIsShown(key)"
class="tabpanel__tab" class="tabpanel__tab"
aria-expanded="true" aria-expanded="true"
role="tab" role="tab"

View File

@ -11,16 +11,12 @@ angular.module('bansho.tabpanel', [])
link: function (scope) { link: function (scope) {
scope.navigation = scope.options.attributes.navigation; scope.navigation = scope.options.attributes.navigation;
scope.currentPanel = 0; scope.currentPanel = Object.keys(scope.navigation)[0];
scope.setIsShown = function (index) { scope.setIsShown = function (panelId) {
scope.currentPanel = index; scope.currentPanel = panelId;
}; };
angular.forEach(scope.options.components, function (panel, index) { angular.forEach(scope.navigation, function (panel) {
panel.attributes.index = index;
});
angular.forEach(scope.options.attributes.navigation, function (panel, index) {
panel.right = sharedData.getData(panel.provider, function (data) { panel.right = sharedData.getData(panel.provider, function (data) {
panel.right = data; panel.right = data;
}); });
@ -39,11 +35,14 @@ angular.module('bansho.tabpanel', [])
link: function (scope) { link: function (scope) {
if (scope.$parent.$parent.currentPanel !== undefined) { if (scope.$parent.$parent.currentPanel !== undefined) {
scope.parent = scope.$parent.$parent; scope.parent = scope.$parent.$parent;
scope.index = scope.options.attributes.index;
} else { } else {
scope.parent = {}; scope.parent = {};
scope.parent.currentPanel = 0; scope.parent.currentPanel = 0;
scope.index = 0;
if (!scope.options.attributes) {
scope.options.attributes = {};
}
scope.options.attributes.panelId = 0;
} }
} }
}; };