Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add buttons to change status of story from story list

  • Loading branch information...
commit a20c6bc61dda24db9c158a57a6a6742abe529730 1 parent bc329bf
@bkeepers authored
View
3  .gitignore
@@ -1,2 +1,3 @@
.sass-cache
-testrepo/
+testrepo/
+chromedriver.log
View
7 app/assets/javascripts/controllers/story_list_item_controller.js
@@ -1,4 +1,6 @@
var StoryListItemController = Spine.Controller.create({
+ events: {'click button': 'update'},
+
init: function() {
this.story.bind("update", this.proxy(this.render));
this.story.bind("destroy", this.proxy(this.remove));
@@ -19,5 +21,10 @@ var StoryListItemController = Spine.Controller.create({
remove: function(){
this.el.remove();
+ },
+
+ update: function(e) {
+ this.story.updateAttribute('status', $(e.target).val());
+ return false;
}
});
View
32 app/assets/javascripts/helpers/story_helper.js
@@ -10,3 +10,35 @@ Handlebars.registerHelper('statuses', function(fn) {
return new Handlebars.SafeString(result);
});
+
+// There's got to be an easier way to do all this :(
+Handlebars.registerHelper('isPending', function(fn) {
+ if (this.status == 'pending') {
+ return fn(this);
+ }
+});
+Handlebars.registerHelper('isStarted', function(fn) {
+ if (this.status == 'started') {
+ return fn(this);
+ }
+});
+Handlebars.registerHelper('isCompleted', function(fn) {
+ if (this.status == 'completed') {
+ return fn(this);
+ }
+});
+Handlebars.registerHelper('isDelivered', function(fn) {
+ if (this.status == 'delivered') {
+ return fn(this);
+ }
+});
+Handlebars.registerHelper('isRejected', function(fn) {
+ if (this.status == 'rejected') {
+ return fn(this);
+ }
+});
+Handlebars.registerHelper('isApproved', function(fn) {
+ if (this.status == 'approved') {
+ return fn(this);
+ }
+});
View
1  app/assets/stylesheets/base.scss
@@ -21,6 +21,7 @@ body {
}
@import 'mixins/css3';
+@import 'mixins/buttons';
@import 'classes/icons';
@import 'classes/labels';
@import 'elements/header';
View
7 app/assets/stylesheets/classes/labels.scss
@@ -21,10 +21,15 @@
display: inline-block;
line-height:24px;
padding:0 10px;
- text-shadow:rgba(0,0,0,0.5) 0px 1px 1px;
+ text-shadow:rgba(0,0,0,0.3) 0px 1px 1px;
text-transform:uppercase;
background: -webkit-linear-gradient(top, rgb(80,175,237) 0%, rgb(2,128,201) 80%);
margin:0;
font-size:11px;
font-weight:bold;
}
+
+.button.destroy, button.destroy {
+ background: -webkit-linear-gradient(top, rgb(150,150,150) 0%, rgb(130,130,130) 80%);
+ color: #ddd;
+}
View
2  app/assets/stylesheets/elements/header.scss
@@ -1,6 +1,6 @@
header, footer {
background: -webkit-linear-gradient(top, rgb(229,229,229) 0%, rgb(186,186,186) 80%);
- border-bottom:1px solid rgb(79,79,79);
+ border-bottom:1px solid rgb(150,150,150);
position:relative;
height:35px;
h2 {
View
36 app/assets/stylesheets/elements/list.scss
@@ -28,7 +28,7 @@
width:70%;
}
a {
- padding:0.8em 0 0.7em 40px;
+ padding:0.8em 100px 0.7em 40px;
display:block;
color:inherit;
text-decoration:none;
@@ -55,12 +55,44 @@
&.active {
border-bottom:1px solid rgb(5,110,178);
- border-top: 1px solid rgb(5,110,178);
+ border-top: 1px solid rgb(25,130,208);
margin-top: -1px;
}
+
+ form {
+ position:absolute;
+ right:10px;
+ top:8px;
+ }
+
+ button {
+ font-size:0.9em;
+ line-height:20px;
+ padding:0 8px;
+ }
+
+ button.start, button.restart {
+ @include button(rgb(230,230,230));
+ color:#666;
+ text-shadow: 0px 1px 1px rgba(255,255,255,0.5);
+ }
+
+ button.deliver {
+ @include button(rgb(240, 145, 20));
+ }
+
+ button.accept {
+ @include button(rgb(100, 145, 20));
+ }
+
+ button.reject {
+ @include button(rgb(165, 35, 60));
+ }
}
&.milestone {
}
+
+
}
}
View
4 app/assets/stylesheets/mixins/buttons.scss
@@ -0,0 +1,4 @@
+@mixin button($color) {
+ background: $color;
+ background: -webkit-linear-gradient(top, lighten($color, 5%) 0%, darken($color, 3%) 80%);
+}
View
18 features/stories.feature
@@ -41,3 +41,21 @@ Feature: Stories
When I go to the home page
Then I should not see "A stupid story"
+
+ @selenium # not sure why this fails webkit
+ Scenario: Changing status of a story
+ Given the following story exists:
+ | description |
+ | Get something done |
+ When I go to the home page
+ And I press "Start" within the story "Get something done"
+ And I press "Finish" within the story "Get something done"
+ And I press "Deliver" within the story "Get something done"
+ And I press "Reject" within the story "Get something done"
+ And I press "Restart" within the story "Get something done"
+ And I press "Finish" within the story "Get something done"
+ And I press "Deliver" within the story "Get something done"
+ And I press "Approve" within the story "Get something done"
+
+ And I follow "Get something done"
+ Then the "status" field should contain "approved"
View
20 views/templates/story.handlebars
@@ -1,6 +1,24 @@
<li id="story-{{id}}" class="story {{status}}">
<a href="#/stories/{{id}}">
{{description}}
- <span class="status">({{status}})</span>
+
+ <form>
+ {{#isPending}}
+ <button name="status" value="started" class="start">Start</button>
+ {{/isPending}}
+ {{#isStarted}}
+ <button name="status" value="completed" class="finish">Finish</button>
+ {{/isStarted}}
+ {{#isCompleted}}
+ <button name="status" value="delivered" class="deliver">Deliver</button>
+ {{/isCompleted}}
+ {{#isDelivered}}
+ <button name="status" value="rejected" class="reject">Reject</button>
+ <button name="status" value="approved" class="accept">Approve</button>
+ {{/isDelivered}}
+ {{#isRejected}}
+ <button name="status" value="started" class="restart">Restart</button>
+ {{/isRejected}}
+ </form>
</a>
</li>
Please sign in to comment.
Something went wrong with that request. Please try again.