Permalink
Browse files

added dashboard stats, unassigned issues assignment, inplace editing …

…for user and status
  • Loading branch information...
1 parent 68c9df2 commit 3f949b23835067d905ed202005adaf736837bc52 Marcin Jędras committed Mar 7, 2010
@@ -46,14 +46,37 @@ def new
status = done_ratio_to_status(@issue)
attach_files(@issue, params[:attachments])
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
+ @issue_statuses = IssueStatus.find(:all)
+ @project_users = User.find(:all, :joins => :members, :conditions => ["members.project_id = ?", @project.id])
render :update do |p|
- p.insert_html :bottom, "tasks_#{status}_us_#{@issue.user_story_id}", :partial => "shared/task_view", :locals => {:task => @issue}
+ p.insert_html :bottom, "tasks_#{status}_us_#{@issue.user_story_id}", :partial => "shared/task_view",
+ :locals => {:task => @issue, :issue_statuses => @issue_statuses,
+ :project_users => @project_users}
end
return
end
end
end
+ def update_task
+ obj = Object.const_get(params[:model])
+ value = nil
+ value = obj.find(params[:value]) unless params[:value].blank?
+ task = Issue.find(params[:task_id])
+ eval "task.#{params[:field]}=#{value ? value.id : "nil"}"
+ task.save!
+ @issue_statuses = IssueStatus.find(:all)
+ @project_users = User.find(:all, :joins => :members, :conditions => ["members.project_id = ?", @project.id])
+ status = done_ratio_to_status(task)
+
+ render :update do |page|
+ page.replace "task_wrap_#{task.id}", ""
+ page.insert_html :bottom, "tasks_#{ status }_us_#{task.user_story_id}", :partial => "shared/task_view",
+ :locals => {:task => task, :issue_statuses => @issue_statuses,
+ :project_users => @project_users}
+ end
+ end
+
def status_change
issue = Issue.find(params[:task_id])
@@ -64,13 +87,18 @@ def status_change
if done_ratio_to_status(issue) != params[:status_id]
issue.done_ratio = status_to_done_ratio(params[:status_id])
end
+ issue.status = issue_status(issue)
issue.user_story_id = params[:user_story_id]
issue.author = User.current
end
- if issue.save
+ if issue.save
+ @issue_statuses = IssueStatus.find(:all)
+ @project_users = User.find(:all, :joins => :members, :conditions => ["members.project_id = ?", @project.id])
render :update do |p|
- p.insert_html :bottom, "tasks_#{params[:status_id]}_us_#{issue.user_story_id}", :partial => "shared/task_view", :locals => {:task => issue}
+ p.insert_html :bottom, "tasks_#{params[:status_id]}_us_#{issue.user_story_id}", :partial => "shared/task_view",
+ :locals => {:task => issue, :issue_statuses => @issue_statuses,
+ :project_users => @project_users}
end
end
end
@@ -84,6 +112,18 @@ def find_project
render_404
end
+ def issue_status(issue)
+
+ case issue.done_ratio
+ when 0
+ IssueStatus.find_by_name("New")
+ when 100
+ IssueStatus.find_by_name("Resolved")
+ else
+ IssueStatus.find_by_name("In Progress")
+ end
+ end
+
def done_ratio_to_status(issue)
case issue.done_ratio
when 0
@@ -9,7 +9,9 @@ class SprintsController < ApplicationController
# helper TasksHelper
- helper CustomFieldsHelper
+ helper CustomFieldsHelper
+ helper SprintsHelper
+ include SprintsHelper
# GET /sprints
# GET /sprints.xml
@@ -25,6 +27,15 @@ def index
# GET /sprints/1.xml
def show
unless @sprint.nil?
+ @unassigned_tasks = Issue.find(:all,
+ :conditions => ["user_story_id IS NULL AND (fixed_version_id = ? || project_id = ?)", @sprint.id, @project.id ])
+ @issue_statuses = IssueStatus.find(:all)
+ @project_users = User.find(:all, :joins => :members, :conditions => ["members.project_id = ?", @project.id])
+
+ if defined? @sprint
+ @data = load_sprint_stats(@sprint,[])
+ end
+
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @sprint }
@@ -34,7 +45,7 @@ def show
end
end
-#
+
# # GET /sprints/new
# # GET /sprints/new.xml
def new
@@ -48,17 +59,6 @@ def new
tmp_date = Time.now.advance(:days => 14)
@sprint.effective_date = Date.new(tmp_date.year, tmp_date.month, tmp_date.day)
end
-# @sprint = Sprint.new
-# sprint = Sprint.find_by_project_id(@project, :order => 'name DESC')
-# if sprint
-# @sprint.sprint_no = sprint.sprint_no + 1
-# @sprint.start_date = sprint.start_date.advance(:days => sprint.duration)
-# @sprint.duration = sprint.duration
-# else
-# @sprint.sprint_no = 1
-# @sprint.start_date = Time.now
-# @sprint.duration = 14
-# end
render :partial => "sprints/new"
end
#
@@ -165,65 +165,6 @@ def assign_to_milestone
end
end
-# This will be replaced with burndown model
-# def graph_code
-# tasklogs = TaskLog.find(:all, :conditions => ["version_id = :sprint and created_at <= :end and created_at >= :start",
-# {:sprint => @sprint.id,
-# :end => @sprint.start_date.advance(:days => @sprint.duration),
-# :start => @sprint.start_date }],
-# :order => "created_at ASC" )
-# data = []
-# fields = []
-# date = @sprint.start_date
-# time = date.to_time
-# time + ( 23 - time.hour).hours + (59 - time.min).minutes
-# date = time.to_date
-#
-# count = 0
-# max = 0
-# while @sprint.duration > count
-# fields << date.strftime("%d.%m.%Y")
-# if date <= Date.new(Time.now.year,Time.now.month,Time.now.day)
-# data += [us_points_per_day(@sprint, tasklogs, date)]
-# max = data.last if data.last > max
-# else
-# zero = 0
-# data += [zero]
-# end
-# date = date.advance(:days => 1)
-# count += 1
-# end
-#
-# title = Title.new("Burndown chart Sprint \##{@sprint.id}")
-# title.set_style('{font-size: 12px; color: #FFFFFF; font-weight: bold;}')
-# bar = BarGlass.new
-# bar.set_values(data)
-# bar.set_colour('#ff0000')
-# chart = OpenFlashChart.new
-# y_axis = YAxis.new
-# y_axis.set_range(0, max, (max/6).ceil)
-# y_axis.set_grid_colour('#333333')
-# y_axis.set_colour('#FFFFFF')
-# x_axis = XAxis.new
-# xlebels = XAxisLabels.new
-# labset = []
-# fields.each { |item|
-# xlabel = XAxisLabel.new(item, '#BBBBE3', 16, 'vertical')
-# xlabel.hide
-# labset << xlabel
-# }
-# xlebels.labels = labset
-# x_axis.labels = xlebels
-# x_axis.set_colours('#FFFFFF', '#333333')
-# chart.y_axis = y_axis
-# chart.x_axis = x_axis
-# chart.set_title(title)
-# chart.add_element(bar)
-# chart.bg_colour = '#333333'
-#
-# render :text => chart.to_s
-# end
-
private
def validate_time_entry(time_entry, issue)
@@ -79,7 +79,9 @@ def status_change
log_task(task)
render :update do |p|
# p.replace_html("task_wrap_#{task.id}", "")
- p.insert_html :bottom, "tasks_#{task.status_id }_us_#{task.user_story_id}", :partial => "shared/task_view", :locals => {:task => task}
+ @issue_statuses = IssueStatus.find(:all)
+ p.insert_html :bottom, "tasks_#{task.status_id }_us_#{task.user_story_id}", :partial => "shared/task_view",
+ :locals => {:task => @issue, :issue_statuses => @issue_statuses}
end
end
# end
@@ -43,7 +43,6 @@ def procent_of_sprint_done( sprint )
end
end
-
def load_sprint_stats(sprint, data)
if data.size == 0
data = {:all_points => 0, :pending => 0, :in_progress => 0, :done => 0, :percent_done => 0 }
@@ -90,7 +89,7 @@ def load_project_stats(project)
end
data[:all_points] += data[:un_assign]
data[:percent_done] = (data[:done]/(data[:all_points])) * 100 if data[:all_points] != 0
-
+
data
end
View
@@ -16,14 +16,9 @@ def initialize(version)
self.dates = (start_date..end_date).inject([]) { |accum, date| accum << date }
end
- def chart
- html = ""
- sprint_data.each{|i|
- html << "-#{i}-"
- }
- print "----------------#{html}-----------------"
+ def chart(width,height)
Gchart.line(
- :size => '600x200',
+ :size => "#{width}x#{height}",
:data => data,
:axis_with_labels => 'x,y',
:axis_labels => [dates.map {|d| d.strftime("%m-%d") }],
@@ -44,49 +39,10 @@ def sprint_data
if !user_story.is_done?(date)
total_points_left += user_story.story_points
end
- print "----------------#{user_story.is_done?(date)}-----------------"
}
total_points_left
-# user_stories.inject(0) do |total_hours_left, user_story|
-# if !user_story.is_done?(date)
-# total_hours_left -= user_story.story_points
-# else
-# total_hours_left += 0
-# end
-# end
-
-# done_ratio_details = issue.journals.map(&:details).flatten.select {|detail| 'done_ratio' == detail.prop_key }
-# details_today_or_earlier = done_ratio_details.select {|a| a.journal.created_on.to_date <= date }
-# last_done_ratio_change = details_today_or_earlier.sort_by {|a| a.journal.created_on }.last
-#
-# ratio = if last_done_ratio_change
-# last_done_ratio_change.value
-# elsif done_ratio_details.size > 0
-# 0
-# else
-# issue.done_ratio.to_i
-# end
end
-
-# issues = all_issues.select {|issue| issue.created_on.to_date <= date }
-# issues.inject(0) do |total_hours_left, issue|
-# done_ratio_details = issue.journals.map(&:details).flatten.select {|detail| 'done_ratio' == detail.prop_key }
-# details_today_or_earlier = done_ratio_details.select {|a| a.journal.created_on.to_date <= date }
-#
-# last_done_ratio_change = details_today_or_earlier.sort_by {|a| a.journal.created_on }.last
-#
-# ratio = if last_done_ratio_change
-# last_done_ratio_change.value
-# elsif done_ratio_details.size > 0
-# 0
-# else
-# issue.done_ratio.to_i
-# end
-#
-# total_hours_left += (issue.estimated_hours.to_i * (100-ratio.to_i)/100)
-# end
-# end
end
def ideal_data
@@ -1,39 +1,20 @@
<div class="sprint_stats">
-<table>
- <tr>
- <th><%= l('total_points') %></th>
- <%#*<th>Oczekujące</th>%>
- <%#*<th>W trakcie wykonywania</th>%>
+<table class="unassigned_tasks">
+ <tr class="unassigned_tasks_hd">
+ <th><%= l('total_story_points') %></th>
<th><%= l('done') %></th>
<th><%= l('percent_done') %></th>
</tr>
<tr>
- <% if defined? sprint %>
- <% data = load_sprint_stats(sprint,[]) %>
- <% else %>
- <% data = load_project_stats(project) %>
- <% end %>
<td class="sprint_stats_total">
- <%= data[:all_points] %>
+ <%= @data[:all_points] %>
</td>
- <%#*<td>%>
- <%#= data[:pending] %>
- <%#*</td>%>
- <%#*<td>%>
- <%#= data[:in_progress] %>
- <%#*</td>%>
- <%#*<td>%>
- <%#= data[:done] %>
- <%#*</td>%>
<td class="sprint_stats_done">
- <%= data[:us_points_done] %>
+ <%= @data[:done] %>
</td>
<td class="sprint_stats_done">
- <%= data[:percent_done] %>
+ <%= @data[:percent_done] %>
</td>
</tr>
</table>
-<br/>
-<script type="text/javascript" src="/javascripts/swfobject.js"></script>
-<%= @graph %>
</div>
Oops, something went wrong.

0 comments on commit 3f949b2

Please sign in to comment.