[#6574] Confirm removal in JS and handle removing the last labor item

This commit is contained in:
Eric Davis
2011-10-11 13:49:49 -07:00
parent d633b32b30
commit 2653e80a5f
3 changed files with 21 additions and 12 deletions
+18 -10
View File
@@ -69,7 +69,13 @@ jQuery(function($) {
},
showDeliverableAddButton = function() {
$('table .add-labor a.add').hide().last().show();
var addLinks = $('table .add-labor a.add')
if (addLinks.length == 0) {
// No link, add a blank form
addNewDeliverableFinance("labor");
} else {
addLinks.hide().last().show();
}
},
addNewDeliverableFinance = function(financeType) {
@@ -83,15 +89,17 @@ jQuery(function($) {
},
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();
if (confirm(i18nAreYouSure)) {
// 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();
}
},
showDeliverableAddButton();