Refactored budget panel so it can be updated by RJS when a new deliverable is added. #1278
This commit is contained in:
@@ -46,6 +46,7 @@ class DeliverablesController < ApplicationController
|
||||
end
|
||||
|
||||
@deliverable.project = @project
|
||||
@budget = Budget.new(@project.id)
|
||||
respond_to do |format|
|
||||
if @deliverable.save
|
||||
@flash = l(:notice_successful_create)
|
||||
|
||||
48
app/views/deliverables/_budget.html.erb
Normal file
48
app/views/deliverables/_budget.html.erb
Normal file
@@ -0,0 +1,48 @@
|
||||
<h2>Budget</h1>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Project Budget: <%= h number_to_currency(budget.budget, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Spent: <%= h number_to_currency(budget.spent, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Remaining: <%= h number_to_currency(budget.left, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
Progress: <%= h budget.progress %>
|
||||
</p>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Score: <%= h budget.score %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Overruns: <%= h number_to_currency(budget.overruns, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
Next Due Date: <%= h distance_of_time_in_words_to_now(budget.next_due_date) if budget.next_due_date %>
|
||||
</p>
|
||||
<p>
|
||||
Completion: <%= h distance_of_time_in_words_to_now(budget.final_due_date) if budget.final_due_date %>
|
||||
</p>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Profit: <%= h number_to_currency(budget.profit, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
@@ -4,6 +4,10 @@ page << "if ($('deliverable-list') == null) {document.location.reload()}"
|
||||
# Add deliverable to list
|
||||
page.insert_html :top, 'deliverable-list', :partial => 'deliverable', :locals => {:deliverable => @deliverable}
|
||||
|
||||
# Update budget
|
||||
page.replace_html 'budget-summary', :partial => 'budget', :object => @budget
|
||||
page.visual_effect :highlight, 'budget-summary'
|
||||
|
||||
# Remove errors if found
|
||||
page.select('#errorExplanation').each do |value|
|
||||
page.remove value
|
||||
|
||||
@@ -1,52 +1,5 @@
|
||||
<div id="budget-summary">
|
||||
<h2>Budget</h1>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Project Budget: <%= h number_to_currency(@budget.budget, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Spent: <%= h number_to_currency(@budget.spent, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Remaining: <%= h number_to_currency(@budget.left, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
Progress: <%= h @budget.progress %>
|
||||
</p>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Budget Score: <%= h @budget.score %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Overruns: <%= h number_to_currency(@budget.overruns, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
Next Due Date: <%= h distance_of_time_in_words_to_now(@budget.next_due_date) if @budget.next_due_date %>
|
||||
</p>
|
||||
<p>
|
||||
Completion: <%= h distance_of_time_in_words_to_now(@budget.final_due_date) if @budget.final_due_date %>
|
||||
</p>
|
||||
|
||||
<% if allowed_management? %>
|
||||
<p>
|
||||
Profit: <%= h number_to_currency(@budget.profit, :precision => 0) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<%= render :partial => 'budget', :object => @budget %>
|
||||
</div>
|
||||
|
||||
<% if allowed_management? %>
|
||||
|
||||
Reference in New Issue
Block a user