[#4180] Hide the total field on Hourly forms.

This commit is contained in:
Eric Davis
2010-07-02 12:08:13 -07:00
parent 5074667b28
commit 6f204fff5a
6 changed files with 20 additions and 12 deletions
+6 -2
View File
@@ -1,6 +1,10 @@
<% form.inputs do %>
<%= form.input :title, :required => true %>
<%= form.input(:type, :required => true, :as => :select, :collection => [["Fixed", "FixedDeliverable"],["Hourly", "HourlyDeliverable"]], :include_blank => false) if resource.new_record? %>
<% if resource.new_record? %>
<%= form.input(:type, :required => true, :as => :select, :collection => [["Fixed", "FixedDeliverable"],["Hourly", "HourlyDeliverable"]], :include_blank => false, :input_html => {:class => 'type'}) %>
<% else %>
<%= form.input :type, :as => :hidden, :class => 'type' %>
<% end %>
<%= form.input :manager, :required => true, :collection => @project.users %>
<%= 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') %>
@@ -17,7 +21,7 @@
</li>
<% end %>
<%= form.input :total, :input_html => {:size => 10} %>
<%= form.input :total, :input_html => {:size => 10}, :wrapper_html => {:class => 'deliverable_total_input'} %>
<% end %>
<% form.buttons do %>
<%= form.commit_button :label => l(:button_save) %>
+1 -1
View File
@@ -1,5 +1,5 @@
<%= content_tag(:h2, h(resource.title)) %>
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverable_path(@project, @contract, resource), :html => {:class => 'tabular'} do |form| %>
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverable_path(@project, @contract, resource), :html => {:class => 'deliverable tabular'} do |form| %>
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, @contract)} %>
<% end %>
+1 -1
View File
@@ -1,5 +1,5 @@
<%= content_tag(:h2, l(:text_new_deliverable)) %>
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverables_path(@project, @contract), :html => {:class => 'tabular'} do |form| %>
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverables_path(@project, @contract), :html => {:class => 'deliverable tabular'} do |form| %>
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, @contract)} %>
<% end %>
+7 -7
View File
@@ -1,19 +1,19 @@
jQuery(function($) {
toggleSpecificDeliverableFields = function() {
var deliverableType = $('select#deliverable_type option:selected').val();
toggleSpecificDeliverableFields = function(form) {
var deliverableType = form.find('.type').val();
if (deliverableType == 'FixedDeliverable') {
$('#deliverable_total_input').show();
$('.deliverable_total_input').show();
} else {
$('#deliverable_total_input').
children('#deliverable_total').val('').end().
$('.deliverable_total_input').
children('input').val('').end().
hide();
}
},
toggleSpecificDeliverableFields();
toggleSpecificDeliverableFields($('form.deliverable'));
$('select#deliverable_type').change(function() {
toggleSpecificDeliverableFields();
toggleSpecificDeliverableFields($('form.deliverable'));
});
});
+1
View File
@@ -15,6 +15,7 @@ html>body .tabular li {overflow:hidden;}
.tabular li.required label { color: #484848; }
.tabular li.required label span.required {color: #bb0000;}
.tabular li.hidden { height: 0; padding: 0; margin: 0; }
/* End tabular */
a.contract-delete {color: red; }
+4 -1
View File
@@ -25,6 +25,8 @@ class DeliverablesEditTest < ActionController::IntegrationTest
end
assert_select "select#fixed_deliverable_type", :count => 0 # Not editable
assert js("jQuery('#fixed_deliverable_total_input').is(':visible')"), "Total is hidden when it should be visible"
fill_in "Title", :with => 'An updated title'
check "Feature Sign Off"
@@ -52,7 +54,8 @@ class DeliverablesEditTest < ActionController::IntegrationTest
end
assert_select "select#hourly_deliverable_type", :count => 0 # Not editable
assert js("jQuery('#hourly_deliverable_total_input').is(':hidden')"), "Total is visible when it should be hidden"
fill_in "Title", :with => 'An updated title'
check "Feature Sign Off"
check "Warranty Sign Off"