[#6574] Allow removing labor budgets

This commit is contained in:
Eric Davis
2011-10-11 11:44:16 -07:00
parent 7d0abc641a
commit d633b32b30
3 changed files with 20 additions and 5 deletions
+15 -3
View File
@@ -69,16 +69,28 @@ jQuery(function($) {
},
showDeliverableAddButton = function() {
$('.add-labor a.add').hide().last().show();
$('table .add-labor a.add').hide().last().show();
},
addNewDeliverableFinance = function(financeType) {
var t = $('#labor-budget-template').tmpl({});
var countOfExisting = $("#deliverable-labor tbody tr").size();
var countOfExisting = $("tr.labor-budget-form").size();
var recordLocation = countOfExisting + 1; // increments the Rails [n] placeholder
var newContent = t.html().replace(/\[0\]/g, "[" + recordLocation + "]");
$("<tr>" + newContent + '</tr>').appendTo('#deliverable-labor tbody');
$("<tr class='labor-budget-form'>" + newContent + '</tr>').appendTo('#deliverable-labor tbody');
showDeliverableAddButton();
},
deleteDeliverableFinance = function(deleteLink) {
// Set the deleted flag for Rails and move it out of the row
$(deleteLink).parent().find('.delete-flag').val('1')
$(deleteLink).closest("form").
append(
$(deleteLink). // <a>
parent(). // <td>
parent().hide()
) // <tr>
showDeliverableAddButton();
},