From 944cade84161cea2a4cdc703e290d1f95ac3ab3c Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 21 Apr 2009 13:44:31 -0700 Subject: [PATCH] [#2281] Hooked up the cascaded selects to the Billing Status select. --- ...overhead_time_entry_activity_controller.rb | 2 + .../_values.html.erb | 2 +- .../settings/_overhead_settings.html.erb | 42 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/controllers/overhead_time_entry_activity_controller.rb b/app/controllers/overhead_time_entry_activity_controller.rb index fa0111e..289d4ee 100644 --- a/app/controllers/overhead_time_entry_activity_controller.rb +++ b/app/controllers/overhead_time_entry_activity_controller.rb @@ -9,6 +9,8 @@ class OverheadTimeEntryActivityController < ApplicationController @values = select_values_for_field(@field) end @values ||= [] + + @selected = params[:selected] || '' render :partial => 'values' end diff --git a/app/views/overhead_time_entry_activity/_values.html.erb b/app/views/overhead_time_entry_activity/_values.html.erb index 78f7bf4..af04c5c 100644 --- a/app/views/overhead_time_entry_activity/_values.html.erb +++ b/app/views/overhead_time_entry_activity/_values.html.erb @@ -1 +1 @@ -<%= options_for_select(@values) %> +<%= options_for_select(@values, @selected) %> diff --git a/app/views/settings/_overhead_settings.html.erb b/app/views/settings/_overhead_settings.html.erb index 81e7a99..734e6f3 100644 --- a/app/views/settings/_overhead_settings.html.erb +++ b/app/views/settings/_overhead_settings.html.erb @@ -4,19 +4,55 @@

- <%= select_tag('setting[custom_field]', + <%= select_tag('settings[custom_field]', '' + options_from_collection_for_select(activity_fields, :id, :name, @settings['custom_field'].to_i)) %>

- TODO + <%= select_tag('settings[billable_value]', '') %>

- TODO + <%= select_tag('settings[overhead_value]', '') %>

+ +<%# TODO: optimize JavaScript below to not use multiple requests. %> + +<%= observe_field(:settings_custom_field, + :url => { :controller => 'overhead_time_entry_activity', :action => 'index'}, + :with => 'custom_field', + :update => :settings_billable_value) %> + +<%= observe_field(:settings_custom_field, + :url => { :controller => 'overhead_time_entry_activity', :action => 'index'}, + :with => 'custom_field', + :update => :settings_overhead_value) %> + +