Skip to content

Commit

Permalink
user can open its features
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Oct 25, 2012
1 parent 6ac4859 commit bea785c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web/app/config/config.js
Expand Up @@ -7,6 +7,6 @@ hbw.app.config(['$routeProvider', function($routeProvider) {
templateUrl: 'app/views/feature-detail.html'
}).
otherwise({
redirectTo: '/feature'
redirectTo: '/features'
});
}]);
13 changes: 9 additions & 4 deletions web/app/controllers/FeatureDetailController.js
@@ -1,9 +1,14 @@
function FeatureDetailController($scope, FeatureService, $http) {
$http.get('features.json').success(function(data) {
$scope.features = data;
FeatureService.setFeatures(data);
if(FeatureService && FeatureService.features.length == 0) {
$http.get('features.json').success(function(data) {
FeatureService.setFeatures(data);
$scope.features = FeatureService.getFeatures();
$scope.feature = FeatureService.getCurrentFeature();
});
} else {
$scope.features = FeatureService.features;
$scope.feature = FeatureService.getCurrentFeature();
});
}

$scope.FeatureService = FeatureService;

Expand Down
19 changes: 14 additions & 5 deletions web/app/controllers/FeatureListController.js
@@ -1,9 +1,15 @@
function FeatureListController($scope, FeatureService, $http) {
$http.get('features.json').success(function(data) {
$scope.features = data;
FeatureService.setFeatures(data);
if(FeatureService && FeatureService.features.length == 0) {
$http.get('features.json').success(function(data) {
FeatureService.setFeatures(data);
$scope.features = FeatureService.getFeatures();
$scope.feature = FeatureService.getCurrentFeature();
});
} else {
$scope.features = FeatureService.features;
$scope.feature = FeatureService.getCurrentFeature();
});
}
$scope.FeatureService = FeatureService;

$scope.criterium = {
state : null,
Expand Down Expand Up @@ -43,5 +49,8 @@ function FeatureListController($scope, FeatureService, $http) {
return true;
};



$scope.setCurrentFeature = function(feature) {
this.FeatureService.setCurrentFeature(feature);
};
}
20 changes: 18 additions & 2 deletions web/app/services/FeatureService.js
Expand Up @@ -19,13 +19,29 @@ hbw.app.service('FeatureService', function() {
*/
this.push = function(feature) {
this.features.push(feature);
// todo : notify observers
// todo : notify observers
};

this.setFeatures = function(datas) {
var i;
for(i in datas) {
this.features.push(new hbw.entity.feature(datas[i]));
}
}
};

this.getFeatures = function() {
return this.features;
};

this.setCurrentFeature = function(feature) {
var i;
for(i in this.features) {
if(this.features[i] == feature) {
this.currentFeatureIndex = i;
return;
}
}
this.features.push(feature);
this.currentFeatureIndex = this.features.length;
};
});
6 changes: 4 additions & 2 deletions web/app/views/features-list.html
Expand Up @@ -20,12 +20,14 @@

<div class="container-features">
<div class="span3 well animate-slow feature" ng-repeat="feature in features" ng-class="{'ui-hide-slide':!matchCurrentCriterium(feature)}">
<div class="feature-title"><a href="#">{{feature.title}}</a></div>
<div class=""><a class="feature-title state state-{{feature.state}}"
ng-click="setCurrentFeature(feature)"
href="#feature">{{feature.title}}</a></div>
<div class="feature-inorder"><span>In order to</span> {{feature.inorder}}</div>
<div class="feature-as"><span>As</span> {{feature.as}}</div>
<div class="feature-should"><span>I should </span> {{feature.should}}</div>

<div class="scenario" ng-repeat="scenario in feature.scenarios">
<div class="hide scenario" ng-repeat="scenario in feature.scenarios">
<span class="state state-{{scenario.state}}">{{scenario.title}}</span>
</div>

Expand Down
6 changes: 5 additions & 1 deletion web/css/style.css
Expand Up @@ -272,7 +272,8 @@ input.feature-main-title {
margin:10px 0;
}
.criterium-selected {
font-weight:bold;
-webkit-box-shadow: inset 0px 0px 5px 1px #000;
box-shadow: inset 0px 0px 5px 1px #000;
}
/* ----- Listing ---- */
.container-features .feature {
Expand All @@ -285,4 +286,7 @@ input.feature-main-title {
position:absolute;
bottom:10px;
right:10px;
}
.container-features .feature-title{
display:block;
}

0 comments on commit bea785c

Please sign in to comment.