diff --git a/app/controllers/deliverables_controller.rb b/app/controllers/deliverables_controller.rb
index 72fee9e..61567d1 100644
--- a/app/controllers/deliverables_controller.rb
+++ b/app/controllers/deliverables_controller.rb
@@ -27,7 +27,11 @@ class DeliverablesController < InheritedResources::Base
end
def show
- redirect_to contract_url(@project, @contract)
+ if show_partial?
+ render :partial => 'deliverables/details_row', :locals => {:contract => @contract, :deliverable => @contract.deliverables.find(params[:id])}
+ else
+ redirect_to contract_url(@project, @contract)
+ end
end
def destroy
@@ -39,6 +43,11 @@ class DeliverablesController < InheritedResources::Base
def begin_of_association_chain
@contract
end
+
+ # Is only a partial requested?
+ def show_partial?
+ params[:format] == 'js' && params[:as] == 'deliverable_details_row'
+ end
private
diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb
index 78f8d6d..48fe286 100644
--- a/app/views/contracts/show.html.erb
+++ b/app/views/contracts/show.html.erb
@@ -108,115 +108,7 @@
<% end %>
-
-
-
-
-
- <%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %>
- <%= link_to(l(:button_delete), contract_deliverable_path(@project, resource, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
-
-
- <%= textilizable(deliverable, :notes) %>
-
- <% if deliverable.retainer? %>
-
- <% end %>
-
-
- <%= show_field(deliverable, :current_period, :html_options => {:class => 'deliverable-current-period'}) if deliverable.retainer? %>
- <%= show_field(deliverable, :start_date, :format => :format_date, :html_options => {:class => 'deliverable-start-date'}) %>
- <%= show_field(deliverable, :end_date, :format => :format_date, :html_options => {:class => 'deliverable-end-date'}) %>
-
-
-
-
- <%# TODO: Release 2, skinning port %>
-
-
-
-
- | |
- Spent |
- Budget |
- Hours |
-
-
-
-
- |
- |
- |
- |
-
-
-
-
- | Labor |
- <%= h(format_value_field_for_contracts(deliverable.labor_budget_spent)) %> |
- <%= h(format_value_field_for_contracts(deliverable.labor_budget_total)) %> |
- TODO: Release 2 / TODO hrs |
-
-
- | Overhead |
- <%= h(format_value_field_for_contracts(deliverable.overhead_spent)) %> |
- <%= h(format_value_field_for_contracts(deliverable.overhead_budget_total)) %> |
- TODO: Release 2 / TODO hrs |
-
- <%# TODO: Release 2, Fixed %>
- <%# TODO: Release 2, Markup %>
-
- | Profit |
- <%= h(format_value_field_for_contracts(deliverable.profit_left)) %> |
- <%= h(format_value_field_for_contracts(deliverable.profit_budget)) %> |
- |
-
-
- | Total: |
- <%= h(format_value_field_for_contracts(deliverable.total_spent)) %> |
- <%= h(format_value_field_for_contracts(deliverable.total)) %> |
- TODO: Release 2 |
-
-
-
-
-
-
-
-
-
- | <%= l(:label_issue_status_plural) %> |
-
-
- <%# TODO: Release 2 Issue status counters
-
- | Proposed |
- 1 |
-
-
- | On Hold |
- 1 |
-
-
- | Complete |
- 14 |
-
-
- | All |
- 16 |
-
- %>
-
-
-
-
- |
+ <%= render :partial => 'deliverables/details_row', :locals => {:deliverable => deliverable, :contract => resource} %>
<% end %>
diff --git a/app/views/deliverables/_details_row.html.erb b/app/views/deliverables/_details_row.html.erb
new file mode 100644
index 0000000..ffa832e
--- /dev/null
+++ b/app/views/deliverables/_details_row.html.erb
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+ <%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, contract, deliverable), :class => 'icon icon-edit') %>
+ <%= link_to(l(:button_delete), contract_deliverable_path(@project, contract, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
+
+
+ <%= textilizable(deliverable, :notes) %>
+
+ <% if deliverable.retainer? %>
+
+ <% end %>
+
+
+ <%= show_field(deliverable, :current_period, :html_options => {:class => 'deliverable-current-period'}) if deliverable.retainer? %>
+ <%= show_field(deliverable, :start_date, :format => :format_date, :html_options => {:class => 'deliverable-start-date'}) %>
+ <%= show_field(deliverable, :end_date, :format => :format_date, :html_options => {:class => 'deliverable-end-date'}) %>
+
+
+
+
+ <%# TODO: Release 2, skinning port %>
+
+
+
+
+ | |
+ Spent |
+ Budget |
+ Hours |
+
+
+
+
+ |
+ |
+ |
+ |
+
+
+
+
+ | Labor |
+ <%= h(format_value_field_for_contracts(deliverable.labor_budget_spent)) %> |
+ <%= h(format_value_field_for_contracts(deliverable.labor_budget_total)) %> |
+ TODO: Release 2 / TODO hrs |
+
+
+ | Overhead |
+ <%= h(format_value_field_for_contracts(deliverable.overhead_spent)) %> |
+ <%= h(format_value_field_for_contracts(deliverable.overhead_budget_total)) %> |
+ TODO: Release 2 / TODO hrs |
+
+ <%# TODO: Release 2, Fixed %>
+ <%# TODO: Release 2, Markup %>
+
+ | Profit |
+ <%= h(format_value_field_for_contracts(deliverable.profit_left)) %> |
+ <%= h(format_value_field_for_contracts(deliverable.profit_budget)) %> |
+ |
+
+
+ | Total: |
+ <%= h(format_value_field_for_contracts(deliverable.total_spent)) %> |
+ <%= h(format_value_field_for_contracts(deliverable.total)) %> |
+ TODO: Release 2 |
+
+
+
+
+
+
+
+
+
+
+ | <%= l(:label_issue_status_plural) %> |
+
+
+ <%# TODO: Release 2 Issue status counters
+
+ | Proposed |
+ 1 |
+
+
+ | On Hold |
+ 1 |
+
+
+ | Complete |
+ 14 |
+
+
+ | All |
+ 16 |
+
+ %>
+
+
+
+
+ |
+
diff --git a/assets/javascripts/contracts.js b/assets/javascripts/contracts.js
index 4aa5eda..247b391 100644
--- a/assets/javascripts/contracts.js
+++ b/assets/javascripts/contracts.js
@@ -1,4 +1,6 @@
jQuery(function($) {
+ $("#ajax-indicator").ajaxStart(function(){ $(this).show(); });
+ $("#ajax-indicator").ajaxStop(function(){ $(this).hide(); });
var right_align = $('#contract-terms .finance tr td:nth-child ~ td, .c_overview table.right tr td:nth-child ~ td, #deliverables table tr.click td:nth-child(5) ~ td, .deliverable_finance_table tr.aright td:nth-child ~ td');
@@ -83,6 +85,11 @@ jQuery(function($) {
}
});
+
+ $('select.retainer_period_change').live('change', function() {
+ var deliverable_url = $(this).closest('form').attr('action');
+ $(this).closest('tr').load(deliverable_url, this.form.serialize());
+ });
});
/* Jquery Table Expander Plugin */
diff --git a/test/integration/deliverable_details_test.rb b/test/integration/deliverable_details_test.rb
new file mode 100644
index 0000000..6dd33c9
--- /dev/null
+++ b/test/integration/deliverable_details_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class DeliverableDetailsShowTest < ActionController::IntegrationTest
+ include Redmine::I18n
+
+ def setup
+ @project = Project.generate!(:identifier => 'main').reload
+ @contract = Contract.generate!(:project => @project)
+ @manager = User.generate!
+ @deliverable1 = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
+ end
+
+ context "for a JS request" do
+ should "render the details for the deliverable" do
+ visit "/projects/#{@project.id}/contracts/#{@contract.id}/deliverables/#{@deliverable1.id}", :get, {:format => 'js', :as => 'deliverable_details_row'}
+
+ assert_response :success
+ assert_select ".deliverable_details_outer_wrapper_#{@deliverable1.id}"
+ assert_select "table#deliverables", :count => 0 # Not the full table
+ assert_select "tr#deliverable_details_#{@deliverable1.id}", :count => 0 # Not the wrapper tr
+
+ end
+
+ end
+end