-
Notifications
You must be signed in to change notification settings - Fork 459
/
Copy pathrb_master_backlogs_controller.rb
126 lines (110 loc) · 5.95 KB
/
rb_master_backlogs_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
include RbCommonHelper
class RbMasterBacklogsController < RbApplicationController
unloadable
def show
product_backlog_stories = RbStory.product_backlog(@project)
@product_backlog = { :sprint => nil, :stories => product_backlog_stories }
#collect all sprints which are sharing into @project
sprints = @project.open_shared_sprints
@sprint_backlogs = RbStory.backlogs_by_sprint(@project, sprints)
releases = @project.open_releases_by_date
@release_backlogs = RbStory.backlogs_by_release(@project, releases)
@last_update = [product_backlog_stories,
@sprint_backlogs.map{|s| s[:stories]},
@release_backlogs.map{|r| r[:releases]}
].flatten.compact.map{|s| s.updated_on}.sort.last
respond_to do |format|
format.html { render :layout => "rb"}
end
end
def _menu_new
links = []
label_new = :label_new_story
add_class = 'add_new_story'
if @settings[:sharing_enabled]
# FIXME: (pa sharing) usability is bad, menu is inconsistent. Sometimes we have a submenu with one entry, sometimes we have non-sharing behavior without submenu
if @sprint #menu for sprint
return [] unless @sprint.status == 'open' #closed/locked versions are not assignable versions
projects = @sprint.shared_to_projects(@project)
elsif @release #menu for release
projects = @release.shared_to_projects(@project)
else #menu for product backlog
projects = @project.projects_in_shared_product_backlog
end
projects.select!{ |p| User.current.allowed_to?(:create_stories, p) }
#make the submenu or single link
if !projects.empty?
if projects.length > 1
links << {:label => l(label_new), :url => '#', :sub => []}
projects.each{|project|
links.first[:sub] << {:label => project.name, :url => '#', :classname => "#{add_class} project_id_#{project.id}"}
}
else
links << {:label => l(label_new), :url => '#', :classname => "#{add_class} project_id_#{projects[0].id}"}
end
end
else #no sharing, only own project in the menu
links << {:label => l(label_new), :url => '#', :classname => add_class}
end
return links
end
def menu
links = []
links += _menu_new if User.current.allowed_to?(:create_stories, @project)
links << {:label => l(:label_new_sprint), :url => '#', :classname => 'add_new_sprint'
} unless @sprint || !User.current.allowed_to?(:create_sprints, @project)
links << {:label => l(:label_task_board),
:url => url_for(:controller => 'rb_taskboards', :action => 'show', :sprint_id => @sprint, :only_path => true)
} if @sprint && @sprint.stories.size > 0 && Backlogs.task_workflow(@project) && User.current.allowed_to?(:view_taskboards, @project)
links << {:label => l(:label_burndown),
:url => '#',
:classname => 'show_burndown_chart'
} if @sprint && @sprint.stories.size > 0 && @sprint.has_burndown?
links << {:label => l(:label_stories_tasks),
:url => url_for(:controller => 'rb_queries', :action => 'show', :project_id => @project.id, :sprint_id => @sprint, :only_path => true)
} if @sprint && @sprint.stories.size > 0
links << {:label => l(:label_stories),
:url => url_for(:controller => 'rb_queries', :action => 'show', :project_id => @project, :only_path => true)
} unless @sprint || @release
links << {:label => l(:label_sprint_cards),
:url => url_for(:controller => 'rb_stories', :action => 'index', :project_id => @project.identifier, :sprint_id => @sprint, :format => 'pdf', :only_path => true)
} if @sprint && BacklogsPrintableCards::CardPageLayout.selected && @sprint.stories.size > 0
links << {:label => l(:label_product_cards),
:url => url_for(:controller => 'rb_stories', :action => 'index', :project_id => @project.identifier, :format => 'pdf', :only_path => true)
} unless @sprint || @release
links << {:label => l(:label_wiki),
:url => url_for(:controller => 'rb_wikis', :action => 'show', :sprint_id => @sprint, :only_path => true)
} if @sprint && @project.enabled_modules.any? {|m| m.name=="wiki" }
links << {:label => l(:label_download_sprint),
:url => url_for(:controller => 'rb_sprints', :action => 'download', :sprint_id => @sprint, :format => 'xml', :only_path => true)
} if @sprint && @sprint.has_burndown?
links << {:label => l(:label_reset),
:url => url_for(:controller => 'rb_sprints', :action => 'reset', :sprint_id => @sprint, :only_path => true),
:warning => view_context().escape_javascript(l(:warning_reset_sprint)).gsub(/\/n/, "\n")
} if @sprint && @sprint.sprint_start_date && User.current.allowed_to?(:reset_sprint, @project)
links << {:label => l(:label_version),
:url => url_for(:controller => 'versions', :action => 'show', :id => @sprint, :target => '_blank', :only_path => true)
} if @sprint
links << {:label => l(:label_release),
:url => url_for(:controller => 'rb_releases', :action => 'show', :release_id => @release, :target => '_blank', :only_path => true)
} if @release
links << {:label => l(:label_sprint_close),
:url => url_for(:controller => 'rb_sprints', :action => 'close', :sprint_id => @sprint, :only_path => true)
} if @sprint && @sprint.open? && @sprint.stories.open.none? && User.current.allowed_to?(:update_sprints, @project)
respond_to do |format|
format.html { render :json => links }
end
end
if Rails::VERSION::MAJOR < 3
def view_context
@template
end
end
def closed_sprints
c_sprints = @project.closed_shared_sprints
@backlogs = RbStory.backlogs_by_sprint(@project, c_sprints)
respond_to do |format|
format.html { render :partial => 'closedbacklog', :collection => @backlogs }
end
end
end