[#2281] Hooked up the cascaded selects to the Billing Status select.

This commit is contained in:
Eric Davis committed 2009-04-21 13:44:31 -07:00
1 parent bcba8262b3
commit 944cade841
3 files changed
+42 -4

No files matched your search

@@ -9,6 +9,8 @@ class OverheadTimeEntryActivityController < ApplicationController
@values = select_values_for_field(@field) @values = select_values_for_field(@field)
end end
@values ||= [] @values ||= []
@selected = params[:selected] || ''
render :partial => 'values' render :partial => 'values'
end end
@@ -1 +1 @@
<%= options_for_select(@values) %> <%= options_for_select(@values, @selected) %>
+39 -3
View File
@@ -4,19 +4,55 @@
<p> <p>
<label><%= l(:overhead_field_billing_status) %></label> <label><%= l(:overhead_field_billing_status) %></label>
<%= select_tag('setting[custom_field]', <%= select_tag('settings[custom_field]',
'<option value="">(Select one)</option>' + '<option value="">(Select one)</option>' +
options_from_collection_for_select(activity_fields, :id, :name, @settings['custom_field'].to_i)) %> options_from_collection_for_select(activity_fields, :id, :name, @settings['custom_field'].to_i)) %>
</p> </p>
<p> <p>
<label><%= l(:overhead_field_billable_value) %></label> <label><%= l(:overhead_field_billable_value) %></label>
TODO <%= select_tag('settings[billable_value]', '') %>
</p> </p>
<p> <p>
<label><%= l(:overhead_field_overhead_value) %></label> <label><%= l(:overhead_field_overhead_value) %></label>
TODO <%= select_tag('settings[overhead_value]', '') %>
</p> </p>
</fieldset> </fieldset>
<%# 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) %>
<script type="text/javascript">
//<![CDATA[
function loadOverheadValues() {
new Ajax.Updater('settings_billable_value',
'/overhead_time_entry_activity',
{
asynchronous:true,
evalScripts:true,
parameters:'custom_field=' + encodeURIComponent($('settings_custom_field').value) + '&selected=' + encodeURIComponent('<%= @settings['billable_value'] %>')
});
new Ajax.Updater('settings_overhead_value',
'/overhead_time_entry_activity',
{
asynchronous:true,
evalScripts:true,
parameters:'custom_field=' + encodeURIComponent($('settings_custom_field').value) + '&selected=' + encodeURIComponent('<%= @settings['overhead_value'] %>')
});
}
Event.observe(window, 'load', function() { loadOverheadValues() });
//]]>
</script>