diff --git a/app/models/deliverable.rb b/app/models/deliverable.rb
index c7084ae..d7386b6 100644
--- a/app/models/deliverable.rb
+++ b/app/models/deliverable.rb
@@ -12,7 +12,7 @@ class Deliverable < ActiveRecord::Base
has_many :issues, :dependent => :nullify
accepts_nested_attributes_for :labor_budgets, :allow_destroy => true
- accepts_nested_attributes_for :overhead_budgets
+ accepts_nested_attributes_for :overhead_budgets, :allow_destroy => true
accepts_nested_attributes_for :fixed_budgets
# Validations
diff --git a/app/views/deliverables/_finance_form.html.erb b/app/views/deliverables/_finance_form.html.erb
index 9f8db24..1268082 100644
--- a/app/views/deliverables/_finance_form.html.erb
+++ b/app/views/deliverables/_finance_form.html.erb
@@ -4,6 +4,12 @@
<% end %>
+
+
<% form.inputs :name => label, :class => "deliverable-finances #{fieldset_class}" do %>
@@ -27,8 +33,8 @@
<% form.fields_for :overhead_budgets, overhead_budgets.sort_by(&:id) do |overhead_budget| %>
<%= render :partial => 'overhead_budget_form', :locals => {:overhead_budget => overhead_budget} %>
-
<% end %>
+
diff --git a/app/views/deliverables/_overhead_budget_form.html.erb b/app/views/deliverables/_overhead_budget_form.html.erb
index 73468c3..89f7ddb 100644
--- a/app/views/deliverables/_overhead_budget_form.html.erb
+++ b/app/views/deliverables/_overhead_budget_form.html.erb
@@ -1,4 +1,4 @@
-
+
|
<%= overhead_budget.hidden_field(:year) %>
<%= overhead_budget.hidden_field(:month) %>
@@ -14,7 +14,9 @@
<%= overhead_budget.label(:budget, l(:text_dollar_sign)) %>
<%= overhead_budget.text_field(:budget, :value => format_deliverable_value_fields(overhead_budget.object.budget), :class => 'financial') %>
|
-
- <%= release(3, "Green Add button for multiple records") %>
+ |
+ <%= overhead_budget.hidden_field "_destroy", :class=> "delete-flag" %>
+ <%= link_to_function(l(:button_delete), 'deleteDeliverableFinance(this)', :class => 'delete icon icon-del') %>
+ <%= link_to_function(l(:button_add), 'addNewDeliverableOverheadItem()', :class => 'add icon icon-add', :style => 'display:none;') %>
|
diff --git a/assets/javascripts/contracts.js b/assets/javascripts/contracts.js
index df422ba..991b12b 100644
--- a/assets/javascripts/contracts.js
+++ b/assets/javascripts/contracts.js
@@ -68,13 +68,20 @@ jQuery(function($) {
}
},
- showDeliverableAddButton = function() {
- var addLinks = $('table.deliverable_finance_table .add-labor a.add')
- if (addLinks.length == 0) {
+ showDeliverableAddButtons = function() {
+ var laborLinks = $('table.deliverable_finance_table .add-labor a.add')
+ if (laborLinks.length == 0) {
// No link, add a blank form
addNewDeliverableLaborItem();
} else {
- addLinks.hide().last().show();
+ laborLinks.hide().last().show();
+ }
+ var overheadLinks = $('table.deliverable_finance_table .add-overhead a.add')
+ if (overheadLinks.length == 0) {
+ // No link, add a blank form
+ addNewDeliverableOverheadItem();
+ } else {
+ overheadLinks.hide().last().show();
}
},
@@ -85,6 +92,13 @@ jQuery(function($) {
'labor-budget-form');
},
+ addNewDeliverableOverheadItem = function() {
+ addNewDeliverableFinance('#overhead-budget-template',
+ '#deliverable-overhead tbody',
+ $("tr.overhead-budget-form").size(),
+ 'overhead-budget-form');
+ },
+
addNewDeliverableFinance = function(templateSelector, appendTemplateTo, countOfExisting, rowClass) {
var t = $(templateSelector).tmpl({});
if (t.length > 0) {
@@ -92,7 +106,7 @@ jQuery(function($) {
var newContent = t.html().replace(/\[0\]/g, "[" + recordLocation + "]");
$("" + newContent + '
').appendTo(appendTemplateTo);
- showDeliverableAddButton();
+ showDeliverableAddButtons();
}
},
@@ -111,11 +125,11 @@ jQuery(function($) {
parent(). //
parent().hide()
); // |
- showDeliverableAddButton();
+ showDeliverableAddButtons();
}
},
- showDeliverableAddButton();
+ showDeliverableAddButtons();
toggleSpecificDeliverableFields($('form.deliverable'));
$('select#deliverable_type').change(function() {
diff --git a/test/integration/deliverables_edit_test.rb b/test/integration/deliverables_edit_test.rb
index b679b11..5759470 100644
--- a/test/integration/deliverables_edit_test.rb
+++ b/test/integration/deliverables_edit_test.rb
@@ -426,6 +426,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
# * overhead hidden month
# * overhead hours
# * overhead amount
+ # * overhead deleted (hidden)
# * fixed hidden year
# * fixed hidden month
# * fixed title
@@ -435,7 +436,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
# * fixed paid hidden field
# * total (hidden)
assert_select ".date-2010-01" do
- assert_select "input", :count => 17
+ assert_select "input", :count => 18
assert_select "textarea.wiki-edit", :count => 1 # Fixed description
end