[#6441] Hide and disable unassignable deliverables from the issue
* Hide - Closed deliverables * Hide - Closed contract deliverables * Disable - Locked deliverables * Disable - Locked contract deliverables
This commit is contained in:
1 parent
f70ade5011
commit
e019a9435e
8 files changed
+103
-14
No files matched your search
@@ -24,6 +24,21 @@ module ContractsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def grouped_deliverable_options_for_select(project, selected_key=nil)
|
||||
project.contracts.with_status(["open","locked"]).inject([]) do |html, contract|
|
||||
options = contract.deliverables.with_status(["open","locked"]).collect do |deliverable|
|
||||
option_attributes = {}
|
||||
option_attributes[:value] = h(deliverable.id)
|
||||
option_attributes[:selected] = "selected" if selected_key.to_i == deliverable.id
|
||||
option_attributes[:disabled] = "disabled" if deliverable.locked? || contract.locked?
|
||||
|
||||
content_tag(:option, h(deliverable.title), option_attributes)
|
||||
end
|
||||
|
||||
html << content_tag(:optgroup, options.join("\n"), :label => h(contract.name))
|
||||
end.join('\n')
|
||||
end
|
||||
|
||||
def deliverable_options_for_contract(contract)
|
||||
contract.deliverables.collect {|d| [d.title, d.id]}
|
||||
end
|
||||
|
||||
@@ -38,7 +38,12 @@ class Contract < ActiveRecord::Base
|
||||
attr_accessible :status
|
||||
|
||||
named_scope :by_name, {:order => "#{Contract.table_name}.name ASC"}
|
||||
|
||||
named_scope :with_status, lambda {|statuses|
|
||||
{
|
||||
:conditions => ["#{Contract.table_name}.status IN (?)", statuses]
|
||||
}
|
||||
}
|
||||
|
||||
[:contract_type,
|
||||
:discount_spent, :discount_budget
|
||||
].each do |mthd|
|
||||
@@ -304,7 +309,7 @@ class Contract < ActiveRecord::Base
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :name, :method => :next_name
|
||||
generator_for :name, :start => "Contract 0000"
|
||||
generator_for :executed => true
|
||||
generator_for(:start_date) { Date.yesterday }
|
||||
generator_for(:end_date) { Date.tomorrow }
|
||||
@@ -314,11 +319,7 @@ class Contract < ActiveRecord::Base
|
||||
generator_for :client_point_of_contact, ''
|
||||
generator_for :client_ap_contact_information, ''
|
||||
generator_for :po_number, ''
|
||||
|
||||
def self.next_name
|
||||
@last_name ||= 'Contract 0000'
|
||||
@last_name.succ!
|
||||
end
|
||||
generator_for :status, 'open'
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -46,6 +46,11 @@ class Deliverable < ActiveRecord::Base
|
||||
end
|
||||
|
||||
named_scope :by_title, {:order => "#{Deliverable.table_name}.title ASC"}
|
||||
named_scope :with_status, lambda {|statuses|
|
||||
{
|
||||
:conditions => ["#{Deliverable.table_name}.status IN (?)", statuses]
|
||||
}
|
||||
}
|
||||
|
||||
def short_type
|
||||
''
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<% if project.module_enabled?(:contracts) && User.current.allowed_to?(:assign_deliverable_to_issue, project) %>
|
||||
<p>
|
||||
<%= label_tag(:deliverable_id, l(:field_deliverable)) %>
|
||||
<% options = project.contracts.inject([]) {|data, contract|
|
||||
data << [contract.name, contract.deliverables.collect {|d| [d.title, d.id]} ]
|
||||
} %>
|
||||
|
||||
<%= select_tag('deliverable_id',
|
||||
content_tag('option', l(:label_no_change_option), :value => '') +
|
||||
content_tag('option', l(:label_none), :value => 'none') +
|
||||
grouped_options_for_select(options)) %>
|
||||
grouped_deliverable_options_for_select(project)) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% if project.module_enabled?(:contracts) && User.current.allowed_to?(:assign_deliverable_to_issue, project) %>
|
||||
<p>
|
||||
<%= form.select(:deliverable_id, grouped_options_for_select(deliverable_options(project), issue.deliverable_id), {:include_blank => true}) %>
|
||||
<%= form.select(:deliverable_id, grouped_deliverable_options_for_select(project, issue.deliverable_id), {:include_blank => true}) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
Reference in new issue
Block a user