Preparing for multiple owner backlogs

ref #2891
pull/6827/head
Gregor Schmidt 14 years ago
parent d32a1e67c5
commit a5663b87ee
  1. 7
      app/controllers/rb_master_backlogs_controller.rb
  2. 100
      app/helpers/rb_master_backlogs_helper.rb
  3. 18
      app/models/backlog.rb
  4. 8
      app/views/rb_master_backlogs/_backlog.html.erb
  5. 62
      app/views/rb_master_backlogs/_menu.html.erb
  6. 2
      app/views/rb_master_backlogs/show.html.erb

@ -2,13 +2,10 @@ class RbMasterBacklogsController < RbApplicationController
unloadable unloadable
def show def show
@product_backlog = Backlog.product_backlog(@project) @owner_backlogs = Backlog.owner_backlogs(@project)
@sprint_backlogs = Backlog.sprint_backlogs(@project) @sprint_backlogs = Backlog.sprint_backlogs(@project)
last_updates = @sprint_backlogs.map &:updated_on @last_update = (@sprint_backlogs + @owner_backlogs).map(&:updated_on).compact.max
last_updates << @product_backlog.updated_on
@last_update = last_updates.compact.max
render :layout => "rb" render :layout => "rb"
end end

@ -1,20 +1,12 @@
module RbMasterBacklogsHelper module RbMasterBacklogsHelper
unloadable unloadable
include Redmine::I18n include Redmine::I18n
def backlog_html_class(backlog)
is_sprint?(backlog) ? "sprint backlog" : "product backlog"
end
def backlog_html_id(backlog)
is_sprint?(backlog) ? "sprint_#{backlog.id}" : "product_backlog"
end
def backlog_id_or_empty(backlog) def render_backlog_menu(backlog)
is_sprint?(backlog) ? backlog.id : "" items = backlog_menu_items_for(backlog)
end is_sprint = backlog.sprint_backlog?
def backlog_menu(is_sprint, items = [])
html = %{ html = %{
<div class="menu"> <div class="menu">
<div class="icon ui-icon ui-icon-carat-1-s"></div> <div class="icon ui-icon ui-icon-carat-1-s"></div>
@ -33,29 +25,67 @@ module RbMasterBacklogsHelper
</div> </div>
} }
end end
def date_or_nil(date)
date.blank? ? '' : date.strftime('%Y-%m-%d')
end
def editable_if_sprint(backlog)
"editable" if is_sprint?(backlog)
end
def is_sprint?(backlog)
backlog.class.to_s.downcase=='sprint'
end
def menu_link(label, options = {}) def backlog_menu_items_for(backlog)
# options[:class] = "pureCssMenui" [
link_to(label, options) {
end :item => "<a href='#' class='add_new_story'>New Story</a>",
:for => :both
def name_or_default(backlog) },
is_sprint?(backlog) ? backlog.name : l(:label_Product_backlog) {
end :item => link_to(l(:label_task_board), {
:controller => 'rb_taskboards',
def stories(backlog) :action => 'show',
backlog[:stories] || backlog.stories :sprint_id => backlog.sprint }),
:for => :sprint
},
{
:item => "<a href='#' class='show_burndown_chart'>Burndown chart</a>",
:for => :sprint,
:condition => backlog.sprint && backlog.sprint.has_burndown
},
{
:item => link_to(l(:label_stories_tasks), {
:controller => 'rb_queries',
:action => 'show',
:project_id => @project,
:sprint_id => backlog.sprint }),
:for => :sprint
},
{
:item => link_to(l(:label_stories), {
:controller => 'rb_queries',
:action => 'show',
:project_id => @project }),
:for => :product
},
{
:item => link_to(l(:label_sprint_cards), {
:controller => 'rb_stories',
:action => 'index',
:project_id => @project,
:sprint_id => backlog.sprint,
:format => :pdf }),
:for => :sprint,
:condition => Cards::TaskboardCards.selected_label
},
{
:item => link_to(l(:label_product_cards), {
:controller => 'rb_stories',
:action => 'index',
:project_id => @project,
:format => :pdf }),
:for => :product
},
{
:item => link_to(l(:label_wiki), {
:controller => 'rb_wikis',
:action => 'edit',
:project_id => @project.id,
:sprint_id => backlog.sprint }),
:for => :sprint,
:condition => @project.module_enabled?("wiki")
}
]
end end
end end

@ -1,9 +1,12 @@
class Backlog class Backlog
unloadable
attr_accessor :sprint attr_accessor :sprint
attr_accessor :stories attr_accessor :stories
def self.product_backlog(project, limit = nil) def self.owner_backlogs(project, limit = nil)
new(:stories => Story.backlog(project, nil, :limit => limit)) stories = Story.backlog(project, nil, :limit => limit)
[new(:stories => stories, :owner_backlog => true)]
end end
def self.sprint_backlogs(project) def self.sprint_backlogs(project)
@ -14,9 +17,18 @@ class Backlog
options = options.with_indifferent_access options = options.with_indifferent_access
@sprint = options['sprint'] @sprint = options['sprint']
@stories = options['stories'] @stories = options['stories']
@owner_backlog = options['owner_backlog']
end end
def updated_on def updated_on
@stories.max_by { |s| s.updated_on }.try(:updated_on) @stories.max_by(&:updated_on).try(:updated_on)
end
def owner_backlog?
!!@owner_backlog
end
def sprint_backlog?
!owner_backlog?
end end
end end

@ -1,13 +1,13 @@
<div class="backlog"> <div class="backlog">
<div class="header"> <div class="header">
<%= render :partial => "menu", :locals => {:backlog => backlog} %> <%= render_backlog_menu backlog %>
<%- if backlog.sprint %> <% if backlog.sprint_backlog? %>
<%= render :partial => "rb_sprints/sprint", :object => backlog.sprint %> <%= render :partial => "rb_sprints/sprint", :object => backlog.sprint %>
<div class="velocity"> </div> <div class="velocity"> </div>
<%- else %> <% else %>
<div class="label"><%=l(:label_product_backlog).titleize %></div> <div class="label"><%=l(:label_product_backlog).titleize %></div>
<a class="add_new_story" href="#">New Story</a> <a class="add_new_story" href="#">New Story</a>
<%- end %> <% end %>
</div> </div>
<ul class="stories"> <ul class="stories">
<%= render :partial => "rb_stories/story", :collection => backlog.stories %> <%= render :partial => "rb_stories/story", :collection => backlog.stories %>

@ -1,62 +0,0 @@
<%= backlog_menu backlog.sprint,
[
{
:item => "<a href='#' class='add_new_story'>New Story</a>",
:for => :both
},
{
:item => menu_link(l(:label_task_board), {
:controller => 'rb_taskboards',
:action => 'show',
:sprint_id => backlog.sprint }),
:for => :sprint
},
{
:item => "<a href='#' class='show_burndown_chart'>Burndown chart</a>",
:for => :sprint,
:condition => backlog.sprint && backlog.sprint.has_burndown
},
{
:item => menu_link(l(:label_stories_tasks), {
:controller => 'rb_queries',
:action => 'show',
:project_id => @project,
:sprint_id => backlog.sprint }),
:for => :sprint
},
{
:item => menu_link(l(:label_stories), {
:controller => 'rb_queries',
:action => 'show',
:project_id => @project }),
:for => :product
},
{
:item => menu_link(l(:label_sprint_cards), {
:controller => 'rb_stories',
:action => 'index',
:project_id => @project,
:sprint_id => backlog.sprint,
:format => :pdf }),
:for => :sprint,
:condition => Cards::TaskboardCards.selected_label
},
{
:item => menu_link(l(:label_product_cards), {
:controller => 'rb_stories',
:action => 'index',
:project_id => @project,
:format => :pdf }),
:for => :product
},
{
:item => menu_link(l(:label_wiki), {
:controller => 'rb_wikis',
:action => 'edit',
:project_id => @project.id,
:sprint_id => backlog.sprint }),
:for => :sprint,
:condition => @project.enabled_modules.any? {|m| m.name=="wiki" }
}
]
%>

@ -20,7 +20,7 @@
<%- content_for :main do %> <%- content_for :main do %>
<div id="backlogs_container"> <div id="backlogs_container">
<div id="owner_backlogs_container"> <div id="owner_backlogs_container">
<%= render :partial => 'backlog', :object => @product_backlog %> <%= render :partial => 'backlog', :collection => @owner_backlogs %>
</div> </div>
<div id="sprint_backlogs_container"> <div id="sprint_backlogs_container">
<%= render :partial => 'backlog', :collection => @sprint_backlogs %> <%= render :partial => 'backlog', :collection => @sprint_backlogs %>

Loading…
Cancel
Save