[#6441] Refactor logic in view to helpers
This commit is contained in:
@@ -17,6 +17,16 @@ module ContractsHelper
|
||||
grouped_contracts["closed"] ||= []
|
||||
grouped_contracts
|
||||
end
|
||||
|
||||
def deliverable_options(project)
|
||||
project.contracts.inject([]) do |data, contract|
|
||||
data << [contract.name, deliverable_options_for_contract(contract)]
|
||||
end
|
||||
end
|
||||
|
||||
def deliverable_options_for_contract(contract)
|
||||
contract.deliverables.collect {|d| [d.title, d.id]}
|
||||
end
|
||||
|
||||
# Simple helper to show the values of a field on an object in a standard format
|
||||
#
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<% if project.module_enabled?(:contracts) && User.current.allowed_to?(:assign_deliverable_to_issue, project) %>
|
||||
<p>
|
||||
<% options = project.contracts.inject([]) {|data, contract|
|
||||
data << [contract.name, contract.deliverables.collect {|d| [d.title, d.id]} ]
|
||||
} %>
|
||||
<%= form.select(:deliverable_id, grouped_options_for_select(options, issue.deliverable_id), {:include_blank => true}) %>
|
||||
<%= form.select(:deliverable_id, grouped_options_for_select(deliverable_options(project), issue.deliverable_id), {:include_blank => true}) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -102,6 +102,9 @@ Dispatcher.to_prepare :redmine_contracts do
|
||||
unless Query.available_columns.collect(&:name).include?(:contract_name)
|
||||
Query.add_available_column(QueryColumn.new(:contract_name, :sortable => "#{Contract.table_name}.name", :groupable => 'contracts.name'))
|
||||
end
|
||||
|
||||
require_dependency 'application_controller'
|
||||
ApplicationController.send(:helper, :contracts)
|
||||
end
|
||||
|
||||
require 'redmine_contracts/hooks/view_layouts_base_html_head_hook'
|
||||
|
||||
Reference in New Issue
Block a user