[#2279] Populated the Timesheet filter with the values from the Billable field
using the OverheadHelper.
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
<%= l(:overhead_field_billing_status) %>
|
<%= l(:overhead_field_billing_status) %>
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
<%= select_tag('timesheet[billable][]','', {:multiple => true, :size => list_size}) %>
|
<%= select_tag('timesheet[billable][]',
|
||||||
|
options_for_select(billable_values),
|
||||||
|
{:multiple => true, :size => list_size}) %>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class OverheadTimesheetHook < Redmine::Hook::ViewListener
|
class OverheadTimesheetHook < Redmine::Hook::ViewListener
|
||||||
|
include OverheadHelper
|
||||||
|
|
||||||
# Adds a table header "Billable" to the report results
|
# Adds a table header "Billable" to the report results
|
||||||
def plugin_timesheet_views_timesheet_group_header(context={})
|
def plugin_timesheet_views_timesheet_group_header(context={})
|
||||||
@@ -22,11 +23,13 @@ class OverheadTimesheetHook < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Added a new field for filtering based on "billable?"
|
# Added a new field for filtering based on "billable?"
|
||||||
def plugin_timesheet_views_timesheet_form(context={})
|
def plugin_timesheet_views_timesheet_form(context={})
|
||||||
|
billable_values = select_values_for_field(TimeEntryActivity.billable_custom_field)
|
||||||
context[:controller].send(:render_to_string,
|
context[:controller].send(:render_to_string,
|
||||||
:partial => 'timesheet/overhead_form',
|
:partial => 'timesheet/overhead_form',
|
||||||
:layout => false,
|
:layout => false,
|
||||||
:locals => {
|
:locals => {
|
||||||
:list_size => context[:list_size] || 5
|
:list_size => context[:list_size] || 5,
|
||||||
|
:billable_values => billable_values
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -63,5 +63,19 @@ describe OverheadTimesheetHook, "#plugin_timesheet_views_timesheet_form", :type
|
|||||||
response.should have_tag('select[name=?][multiple=multiple]', 'timesheet[billable][]')
|
response.should have_tag('select[name=?][multiple=multiple]', 'timesheet[billable][]')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should populate the select field with the possible options of the custom data field' do
|
||||||
|
@custom_field = mock_model(TimeEntryActivityCustomField,
|
||||||
|
:possible_values => ['A','B','Nil'],
|
||||||
|
:field_format => 'list')
|
||||||
|
TimeEntryActivity.should_receive(:billable_custom_field).and_return(@custom_field)
|
||||||
|
|
||||||
|
response = call_hook(:plugin_timesheet_views_timesheet_form, {})
|
||||||
|
response.should have_tag('select') do
|
||||||
|
with_tag('option[value=?]','A','A')
|
||||||
|
with_tag('option[value=?]','B','B')
|
||||||
|
with_tag('option[value=?]','Nil','none')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should pre-select the values from the submission'
|
it 'should pre-select the values from the submission'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user