Basic deliverable table implemented. #1135
This commit is contained in:
@@ -3,8 +3,24 @@ class DeliverablesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :authorize, :get_settings
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
|
||||
def index
|
||||
@deliverables = Deliverable.find_all_by_project_id(@project.id)
|
||||
sort_init "#{Deliverable.table_name}.id", "desc"
|
||||
sort_update
|
||||
limit = per_page_option
|
||||
@deliverable_count = Deliverable.count(:conditions => { :project_id => @project.id })
|
||||
@deliverable_pages = Paginator.new self, @deliverable_count, limit, params['page']
|
||||
@deliverables = Deliverable.find(:all,
|
||||
:order => sort_clause,
|
||||
:conditions => { :project_id => @project.id },
|
||||
:limit => limit,
|
||||
:offset => @deliverable_pages.current.offset)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'index', :layout => !request.xhr? }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
class Deliverable < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
|
||||
# TODO: mocked
|
||||
def score
|
||||
0
|
||||
end
|
||||
|
||||
# TODO: mocked
|
||||
def spent
|
||||
0
|
||||
end
|
||||
|
||||
# TODO: mocked
|
||||
def progress
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<% form_tag({}) do -%>
|
||||
<table class="list deliverables">
|
||||
<thead><tr>
|
||||
<%# TODO: Other sorts %>
|
||||
<%= sort_header_tag("#{Deliverable.table_name}.id", :caption => '#', :default_order => 'desc') %>
|
||||
<%= content_tag('th', "Score") %>
|
||||
<%= sort_header_tag("#{Deliverable.table_name}.subject", :caption => 'Subject') %>
|
||||
<%= sort_header_tag("#{Deliverable.table_name}.cost", :caption => 'Budget') %>
|
||||
<%= content_tag('th', "Spent") %>
|
||||
<%= sort_header_tag("#{Deliverable.table_name}.due_date", :caption => 'Due') %>
|
||||
<%= content_tag('th', "Progress") %>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% deliverables.each do |deliverable| -%>
|
||||
<tr id="deliverable-<%= deliverable.id %>" class="deliverable <%= cycle('odd', 'even') %>">
|
||||
<%= content_tag(:td, deliverable.id) %>
|
||||
<%= content_tag(:td, deliverable.score) %>
|
||||
<%= content_tag(:td, deliverable.subject) %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.cost)) %>
|
||||
<%= content_tag(:td, number_to_currency(deliverable.spent)) %>
|
||||
<%= content_tag(:td, format_date(deliverable.due_date)) %>
|
||||
<%= content_tag(:td, progress_bar(deliverable.progress, :width => '80px')) %>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end -%>
|
||||
@@ -35,8 +35,13 @@
|
||||
</div>
|
||||
|
||||
<div id="budget-list">
|
||||
|
||||
<% if @deliverables.empty? %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% else %>
|
||||
<%= render :partial => 'list', :locals => { :deliverables => @deliverables} %>
|
||||
<p class="pagination"><%# TODO: pagination_links_full @issue_pages, @issue_count %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => 'deliverables/sidebar' %>
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
#budget-summary { background-color:#507AAA;padding:10px; }
|
||||
#budget-list { }
|
||||
|
||||
table.list.deliverables { margin-top: 10px; }
|
||||
tr.deliverable { text-align: center; white-space: nowrap; }
|
||||
tr.deliverable td.subject, tr.deliverable td.category { white-space: normal; }
|
||||
tr.deliverable td.subject { text-align: left; }
|
||||
tr.deliverable td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
|
||||
|
||||
@@ -12,7 +12,10 @@ end
|
||||
describe DeliverablesController,"#index when logged in" do
|
||||
before(:each) do
|
||||
@project = mock_model(Project)
|
||||
Deliverable.stub!(:find_all_by_project_id).and_return([])
|
||||
|
||||
Deliverable.stub!(:count).and_return(0)
|
||||
Deliverable.stub!(:find).and_return([])
|
||||
|
||||
Project.should_receive(:find).with(@project.to_param).and_return(@project)
|
||||
controller.stub!(:authorize).and_return(true)
|
||||
end
|
||||
@@ -28,7 +31,9 @@ describe DeliverablesController,"#index when logged in" do
|
||||
end
|
||||
|
||||
it "should only show the deliverables for the current project only" do
|
||||
Deliverable.should_receive(:find_all_by_project_id).with(@project.id)
|
||||
# TODO: Get spec working for full finder
|
||||
Deliverable.should_receive(:find)
|
||||
get :index, :id => @project.id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user