diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb
index 3a03ee4..f837f2a 100644
--- a/app/views/deliverables/_form.html.erb
+++ b/app/views/deliverables/_form.html.erb
@@ -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 @@
<% 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) %>
diff --git a/app/views/deliverables/edit.html.erb b/app/views/deliverables/edit.html.erb
index c315d2a..8526537 100644
--- a/app/views/deliverables/edit.html.erb
+++ b/app/views/deliverables/edit.html.erb
@@ -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 %>
diff --git a/app/views/deliverables/new.html.erb b/app/views/deliverables/new.html.erb
index 5d5ec69..d48e99e 100644
--- a/app/views/deliverables/new.html.erb
+++ b/app/views/deliverables/new.html.erb
@@ -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 %>
diff --git a/assets/javascripts/contracts.js b/assets/javascripts/contracts.js
index 87fb5e9..937dd56 100644
--- a/assets/javascripts/contracts.js
+++ b/assets/javascripts/contracts.js
@@ -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'));
});
});
diff --git a/assets/stylesheets/redmine_contracts.css b/assets/stylesheets/redmine_contracts.css
index 7be6e1d..33e24f5 100644
--- a/assets/stylesheets/redmine_contracts.css
+++ b/assets/stylesheets/redmine_contracts.css
@@ -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; }
diff --git a/test/integration/deliverables_edit_test.rb b/test/integration/deliverables_edit_test.rb
index 05e47b1..10c16d9 100644
--- a/test/integration/deliverables_edit_test.rb
+++ b/test/integration/deliverables_edit_test.rb
@@ -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"