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
def show
@product_backlog = Backlog.product_backlog(@project)
@owner_backlogs = Backlog.owner_backlogs(@project)
@sprint_backlogs = Backlog.sprint_backlogs(@project)
last_updates = @sprint_backlogs.map &:updated_on
last_updates << @product_backlog.updated_on
@last_update = last_updates.compact.max
@last_update = (@sprint_backlogs + @owner_backlogs).map(&:updated_on).compact.max
render :layout => "rb"
end

@ -1,20 +1,12 @@
module RbMasterBacklogsHelper
unloadable
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)
is_sprint?(backlog) ? backlog.id : ""
end
def render_backlog_menu(backlog)
items = backlog_menu_items_for(backlog)
is_sprint = backlog.sprint_backlog?
def backlog_menu(is_sprint, items = [])
html = %{
<div class="menu">
<div class="icon ui-icon ui-icon-carat-1-s"></div>
@ -33,29 +25,67 @@ module RbMasterBacklogsHelper
</div>
}
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 = {})
# options[:class] = "pureCssMenui"
link_to(label, options)
end
def name_or_default(backlog)
is_sprint?(backlog) ? backlog.name : l(:label_Product_backlog)
end
def stories(backlog)
backlog[:stories] || backlog.stories
def backlog_menu_items_for(backlog)
[
{
:item => "<a href='#' class='add_new_story'>New Story</a>",
:for => :both
},
{
:item => link_to(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 => 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

@ -1,9 +1,12 @@
class Backlog
unloadable
attr_accessor :sprint
attr_accessor :stories
def self.product_backlog(project, limit = nil)
new(:stories => Story.backlog(project, nil, :limit => limit))
def self.owner_backlogs(project, limit = nil)
stories = Story.backlog(project, nil, :limit => limit)
[new(:stories => stories, :owner_backlog => true)]
end
def self.sprint_backlogs(project)
@ -14,9 +17,18 @@ class Backlog
options = options.with_indifferent_access
@sprint = options['sprint']
@stories = options['stories']
@owner_backlog = options['owner_backlog']
end
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

@ -1,13 +1,13 @@
<div class="backlog">
<div class="header">
<%= render :partial => "menu", :locals => {:backlog => backlog} %>
<%- if backlog.sprint %>
<%= render_backlog_menu backlog %>
<% if backlog.sprint_backlog? %>
<%= render :partial => "rb_sprints/sprint", :object => backlog.sprint %>
<div class="velocity"> </div>
<%- else %>
<% else %>
<div class="label"><%=l(:label_product_backlog).titleize %></div>
<a class="add_new_story" href="#">New Story</a>
<%- end %>
<% end %>
</div>
<ul class="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 %>
<div id="backlogs_container">
<div id="owner_backlogs_container">
<%= render :partial => 'backlog', :object => @product_backlog %>
<%= render :partial => 'backlog', :collection => @owner_backlogs %>
</div>
<div id="sprint_backlogs_container">
<%= render :partial => 'backlog', :collection => @sprint_backlogs %>

Loading…
Cancel
Save