Fix bug that prevent saving layout

Change-Id: I4479d02b25d1047d6d28ca764ecdaa3d3722e2ae
This commit is contained in:
Vincent Fournier 2015-08-09 11:05:44 -04:00
parent 521f748087
commit 6ed04419a9
4 changed files with 22 additions and 27 deletions

View File

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

View File

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

View File

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

View File

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