Permalink
Browse files

Fixed a couple of story issues

I have fixed a couple of story issues.  1) Title field in the db was set
to 40 characters but the slug was 255. This meant that the
Story.to_param value wasn't the same as the slug which caused problems.
2) The aasm_event :back_to_new event needed from :new added to it.  Also
some minor formatting stuff.
  • Loading branch information...
Stuart Chinery
Stuart Chinery committed Aug 11, 2011
1 parent df004ab commit f7a2accab82942d1c5997b599e596014c1152a37
@@ -15,10 +15,12 @@
class StoriesController < ApplicationController
layout 'main'
+
before_filter :login_or_password_required, :only => [:show, :generate_feature]
before_filter :login_required, :except => [:show, :generate_feature]
before_filter :retrieve_iterations, :except => [:generate_feature]
before_filter :load_iteration, :except => [:generate_feature, :show]
+
in_place_edit_for :story, :title
in_place_edit_for :story, :description
in_place_edit_for :story, :points
@@ -40,6 +42,7 @@ def index
@quality_assurance_stories = Story.for_iteration(@iteration.id).in_quality_assurance
@completed_stories = Story.for_iteration(@iteration.id).completed
@total_assigned_points = 0
+
Story.for_iteration(@iteration.id).map { |s|
@total_assigned_points += s.points
}
@@ -141,12 +144,12 @@ def destroy
@story.destroy
respond_to do |format|
+ flash[:notice] = 'Story was successfully deleted.'
format.html { redirect_to iteration_stories_path(@iteration) }
format.xml { head :ok }
end
end
-
private
def retrieve_iterations
View
@@ -18,7 +18,7 @@ class Story < ActiveRecord::Base
# Validations
#
- validates_presence_of :description, :points, :title
+ validates_presence_of :title, :description, :points
validates_uniqueness_of :title
# Associations
@@ -74,7 +74,7 @@ class Story < ActiveRecord::Base
end
aasm_event :back_to_new do
- transitions :from => :in_progress, :to => :new
+ transitions :from => [:new, :in_progress], :to => :new
end
attr_protected :status
@@ -84,6 +84,7 @@ def to_param
end
private
+
def set_slug
self.slug = self.to_param
end
@@ -18,4 +18,4 @@
<h2>Burndown chart for <%= @iteration.name %></h2>
-<div id="burndown-chart"></div>
+<div id="burndown-chart"></div>
@@ -21,12 +21,14 @@
<li <%= tab_on("login") %>><%= link_to 'Log In', login_path %></li>
<% end -%>
</ul>
+ <% if logged_in? -%>
<form method="get" action="">
<fieldset>
<input type="text" name="s" id="search-text" size="15" />
<input type="submit" id="search-submit" value="GO" />
</fieldset>
</form>
+ <% end -%>
</div>
<!-- end #menu -->
</div>
@@ -15,7 +15,15 @@
<%= render :partial => "layouts/header" %>
<% if flash[:notice] %>
- <div id="flash-notice"><%= flash[:notice] %></div>
+ <div id="flash-notice">
+ <!-- Extra div needed for SlideUp effect. -->
+ <div>
+ <%= flash[:notice] %>
+ </div>
+ </div>
+ <script type="text/javascript">
+ Util.FadeFlash();
+ </script>
<% end %>
<div id="content">
@@ -1,27 +1,32 @@
+<%= error_messages_for :object => @story,
+ :header_tag => 'h3',
+ :id => "errors",
+ :class => "errors",
+ :header_message => "Whoops!",
+ :message => "We had some problems saving this story."
+-%>
+<p class="form-fields">
+ <%= f.label :title %>
+ <%= f.text_field :title, :size => 52 %>
+</p>
+<p class="form-fields">
+ <%= f.label :description %>
+ <%= f.text_area :description, :size => "60x8" %>
+</p>
+<% unless params[:action] = "new" %>
+<p class="form-fields">
+ <%= f.label :status %>
+ <%= f.select :status, ['new', 'in_progress', 'quality_assurance', 'completed'] %>
+</p>
+<% end %>
+<p class="form-fields">
+ <%= f.label :points %>
+ <%= f.select :points, (1..10).to_a %>
+</p>
+<% unless params[:action] = "new" %>
<p class="form-fields">
- <%= f.label :title %>
- <%= f.text_field :title, :size => 52 %>
+ <%= f.label :iteration %>
+ <%= f.select :iteration_id, @iterations.map {|iteration| [iteration.name, iteration.id]}.insert(0,["Not Assigned",'']) %>
</p>
- <p class="form-fields">
- <%= f.label :description %>
- <%= f.text_area :description, :size => "60x8" %>
- </p>
- <% unless params[:action] = "new" %>
- <p class="form-fields">
- <%= f.label :status %>
- <%= f.select :status, ['new', 'in_progress', 'quality_assurance', 'completed'] %>
- </p>
- <% end %>
- <p class="form-fields">
- <%= f.label :points %>
- <%= f.select :points, (1..10).to_a %>
- </p>
- <% unless params[:action] = "new" %>
- <p class="form-fields">
- <%= f.label :iteration %>
- <%= f.select :iteration_id, @iterations.map {|iteration| [iteration.name, iteration.id]}.insert(0,["Not Assigned",'']) %>
- </p>
- <% else %>
- <%=f.hidden_field :iteration_id %>
- <% end %>
+<% end %>
@@ -1,60 +1,55 @@
-<!-- stories/_story.html.erb -->
- <% @story = story -%>
- <div id="<%= element_id(story) %>" class="story">
- <div class="accordion-toggle<%= ' accordion-toggle-active' if @active %>">
- <%= in_place_editor_field 'story', 'title', {}, :url => {
- :action => "set_story_title", :id => @story.id,
- :iteration_id => @iteration.to_param } %> &nbsp;
- <%= link_to image_tag("/images/icons/delete_icon_20x19.png", :alt => "Delete"),
- iteration_story_path(@iteration, @story), :confirm => 'Delete this story?',
- :method => :delete, :class => "delete-small" %>
- <div style="clear:left">By <%=@story.author%>
- <%= clippy("branston -g -f #{@story.to_param} -b #{request.host} -p #{request.port} ", "#FFFF99") %></div>
- </div>
+<% @story = story -%>
+<div id="<%= element_id(story) %>" class="story">
+ <div class="accordion-toggle<%= ' accordion-toggle-active' if @active %>">
+ <h3><%= in_place_editor_field 'story', 'title' %> <%= clippy("branston -g -f #{@story.to_param} -b #{request.host} -p #{request.port} ", "#FFFF99") %></h3>
+ <%= link_to "Delete", iteration_story_path(@iteration, @story),
+ :confirm => 'Delete this story?', :method => :delete, :class => "delete" %>
+ </div>
- <div id="<%= element_id(story,'scenarios') %>" class="accordion-content">
- <div class="story-props">
- <% remote_form_for :story, @story, :url => "#{iteration_story_path(@iteration, @story)}.js" do |f| -%>
- <%= hidden_field_tag '_method', 'PUT' %>
- <%= hidden_field_tag 'id', @story.id %>
- <div>
- <%= f.select :points, (1..10).to_a, {}, :id => element_id(@story,'points') %> Points
- </div>
- <div>
- <%= f.label :status %>
- <%= f.select :status, ['new', 'in_progress', 'quality_assurance', 'completed'].map {
- |s| [s.capitalize.gsub('_', ' '), s]}, {},
- :id => element_id(@story, 'status') %>
- </div>
- <% unless @iterations.empty? -%>
- <div>
- <%= f.label :iteration_id, "Iteration" %>
- <%= f.select :iteration_id, @iterations.map{|i|[i.name,i.id]},
- {:prompt => "Assign Iteration"}, :id => element_id(@story,'iterations') %>
- </div>
- <% end -%>
- <% end -%>
- </div>
+ <div id="<%= element_id(story,'scenarios') %>" class="accordion-content">
+ <div class="story-props">
+ <% remote_form_for :story, @story, :url => "#{iteration_story_path(@iteration, @story)}.js" do |f| -%>
+ <%= hidden_field_tag '_method', 'PUT' %>
+ <%= hidden_field_tag 'id', @story.id %>
<p>
- <%= in_place_editor_field 'story', 'description' %>
+ <%= f.label :points %>
+ <%= f.select :points, (1..10).to_a, {}, :id => element_id(@story,'points') %>
</p>
-
- <div>
- <%= link_to_remote "Scenarios &raquo;", :method => 'GET',
- :url => iteration_story_scenarios_path(@iteration, @story) %>
- </div>
- </div>
+ <p>
+ <%= f.label :status %>
+ <%= f.select :status, ['new', 'in_progress', 'quality_assurance', 'completed'].map {
+ |s| [s.capitalize.gsub('_', ' '), s]}, {},
+ :id => element_id(@story, 'status') %>
+ </p>
+ <% unless @iterations.empty? -%>
+ <p>
+ <%= f.label :iteration_id, "Iteration" %>
+ <%= f.select :iteration_id, @iterations.map{|i|[i.name,i.id]},
+ {:prompt => "Assign Iteration"}, :id => element_id(@story,'iterations') %>
+ </p>
+ <% end -%>
+ <% end -%>
</div>
+ <p>
+ <%= in_place_editor_field 'story', 'description' %>
+ </p>
+
+ <p>
+ <%= link_to_remote "Scenarios &raquo;", :method => 'GET',
+ :url => iteration_story_scenarios_path(@iteration, @story) %>
+ </p>
+ </div>
+</div>
<% content_for :page_end do -%>
<script type="text/javascript">
-document.observe("dom:loaded", function() {
- $("<%= element_id(@story, 'points') %>").observe("change", Util.Form.selectChange);
- <% unless @iterations.empty? %>
- $("<%= element_id(@story, 'iterations') %>").observe("change", Util.Form.selectChange);
- <% end %>
- $("<%= element_id(@story, 'status') %>").observe("change", Util.Form.selectChange);
-});
+ document.observe("dom:loaded", function() {
+ $("<%= element_id(@story, 'points') %>").observe("change", Util.Form.selectChange);
+ <% unless @iterations.empty? %>
+ $("<%= element_id(@story, 'iterations') %>").observe("change", Util.Form.selectChange);
+ <% end %>
+ $("<%= element_id(@story, 'status') %>").observe("change", Util.Form.selectChange);
+ });
</script>
<% end -%>
@@ -1,14 +1,14 @@
-<h1>Editing story</h1>
+<h2>Editing story</h2>
-<% form_for @story, :url => iteration_story_path(@iteration, @story) do |f| %>
- <%= f.error_messages %>
+<div id="actions">
+ <ul>
+ <li><%= link_to 'Back', iteration_stories_path(@iteration) %></li>
+ <li><%= link_to 'Show', iteration_story_path(@iteration, @story) %></li>
+ </ul>
+</div>
+<% form_for @story, :url => iteration_story_path(@iteration, @story) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
-
- <p class="form-navigation">
- <%= link_to 'Show', iteration_story_path(@iteration, @story) %>
- <%= link_to 'Back', iteration_stories_path(@iteration), :class => "back" %>
- <%= f.submit 'Update' %>
- </p>
+ <p><%= f.submit 'Update' %></p>
<% end %>
Oops, something went wrong.

0 comments on commit f7a2acc

Please sign in to comment.