[#6574] Confirm removal in JS and handle removing the last labor item
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<%= javascript_tag("var i18nStartDateEmpty = '#{l(:text_start_date_empty)}'") %>
|
||||
<%= javascript_tag("var i18nEndDateEmpty = '#{l(:text_end_date_empty)}'") %>
|
||||
<%= javascript_tag("var i18nChangedPeriodMessage = '#{l(:text_changed_period_message)}'") %>
|
||||
<%= javascript_tag("var i18nAreYouSure = '#{l(:text_are_you_sure)}'") %>
|
||||
|
||||
<% if resource.locked? || resource.closed? || resource.contract_locked? || resource.contract_closed? %>
|
||||
<div class="error_msg">
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</td>
|
||||
<td class="add-labor">
|
||||
<%= labor_budget.hidden_field "_destroy", :class=> "delete-flag" %>
|
||||
<%= link_to_function("Remove", 'deleteDeliverableFinance(this)', :class => 'delete icon icon-del') %>
|
||||
<%= link_to_function("Add", 'addNewDeliverableFinance("labor")', :class => 'add icon icon-add', :style => 'display:none;') %>
|
||||
<%= link_to_function(l(:button_delete), 'deleteDeliverableFinance(this)', :class => 'delete icon icon-del') %>
|
||||
<%= link_to_function(l(:button_add), 'addNewDeliverableFinance("labor")', :class => 'add icon icon-add', :style => 'display:none;') %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user