[#4420] Added some Javascript to prompt the user if they try to create a Retainer without a date range.

This commit is contained in:
Eric Davis
2010-09-01 18:44:30 -07:00
parent 918561d667
commit e5853100d5
3 changed files with 21 additions and 3 deletions
+6 -3
View File
@@ -1,3 +1,6 @@
<%= javascript_tag("var i18nStartDateEmpty = '#{l(:text_start_date_empty)}'") %>
<%= javascript_tag("var i18nEndDateEmpty = '#{l(:text_end_date_empty)}'") %>
<div class="box tabular">
<% form.inputs :name => l(:text_deliverable_details_legend) do %>
<%= form.input :title, :required => true %>
@@ -12,8 +15,8 @@
<%= form.input :type, :as => :hidden, :class => 'type' %>
<% end %>
<%= form.input :manager, :required => true, :collection => @project.users.sort %>
<%= form.input :start_date, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('deliverable_start_date') %>
<%= form.input :end_date, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('deliverable_end_date') %>
<%= form.input :start_date, :as => :string, :input_html => {:size => 10, :class => 'start-date'}, :hint => calendar_for('deliverable_start_date') %>
<%= form.input :end_date, :as => :string, :input_html => {:size => 10, :class => 'end-date'}, :hint => calendar_for('deliverable_end_date') %>
<%= form.input :notes, :input_html => {:class => 'wiki-edit', :rows => '5'} %>
<% unless resource.new_record? %>
@@ -28,7 +31,7 @@
<% end %>
<% end %>
<% if resource.retainer? %>
<% if resource.retainer? && resource.respond_to?(:months) %>
<% resource.months.each do |month| %>
<%= render :partial => 'finance_form', :locals => {:form => form, :labor_budgets => resource.labor_budgets_for_date(month), :overhead_budgets => resource.overhead_budgets_for_date(month), :label => l(:text_deliverable_finances_date, :date => month.strftime("%B, %Y")), :fieldset_class => 'date-' + month.strftime('%Y-%m') } %>
<% end %>
+13
View File
@@ -60,6 +60,19 @@ jQuery(function($) {
$('select#deliverable_type').change(function() {
toggleSpecificDeliverableFields($('form.deliverable'));
});
$('form.deliverable').submit(function() {
var deliverableType = $('form.deliverable').find('.type').val();
if (deliverableType == 'RetainerDeliverable') {
if ($('form.deliverable .start-date[value!=""]').length == 0) {
return confirm(i18nStartDateEmpty);
}
if ($('form.deliverable .end-date[value!=""]').length == 0) {
return confirm(i18nEndDateEmpty);
}
}
});
});
/* Jquery Table Expander Plugin */
+2
View File
@@ -64,3 +64,5 @@ en:
field_frequency: "Frequency"
text_monthly: "Monthly"
text_quarterly: "Quarterly"
text_start_date_empty: "The start date is empty. If this form is submitted, no budget items will be created."
text_end_date_empty: "The end date is empty. If this form is submitted, no budget items will be created."