@@ -38,7 +38,7 module TimelogHelper | |||||
38 | def activity_collection_for_select_options(time_entry=nil, project=nil) |
|
38 | def activity_collection_for_select_options(time_entry=nil, project=nil) | |
39 | project ||= @project |
|
39 | project ||= @project | |
40 | if project.nil? |
|
40 | if project.nil? | |
41 | activities = TimeEntryActivity.active |
|
41 | activities = TimeEntryActivity.shared.active | |
42 | else |
|
42 | else | |
43 | activities = project.activities |
|
43 | activities = project.activities | |
44 | end |
|
44 | end |
@@ -16,6 +16,8 | |||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class Enumeration < ActiveRecord::Base |
|
18 | class Enumeration < ActiveRecord::Base | |
|
19 | default_scope :order => "#{Enumeration.table_name}.position ASC" | |||
|
20 | ||||
19 | belongs_to :project |
|
21 | belongs_to :project | |
20 |
|
22 | |||
21 | acts_as_list :scope => 'type = \'#{type}\'' |
|
23 | acts_as_list :scope => 'type = \'#{type}\'' | |
@@ -58,14 +60,8 class Enumeration < ActiveRecord::Base | |||||
58 | end |
|
60 | end | |
59 | # End backwards compatiblity named_scopes |
|
61 | # End backwards compatiblity named_scopes | |
60 |
|
62 | |||
61 |
named_scope : |
|
63 | named_scope :shared, :conditions => { :project_id => nil } | |
62 |
|
64 | named_scope :active, :conditions => { :active => true } | ||
63 | named_scope :active, lambda { |
|
|||
64 | { |
|
|||
65 | :conditions => {:active => true, :project_id => nil}, |
|
|||
66 | :order => 'position' |
|
|||
67 | } |
|
|||
68 | } |
|
|||
69 |
|
65 | |||
70 | def self.default |
|
66 | def self.default | |
71 | # Creates a fake default scope so Enumeration.default will check |
|
67 | # Creates a fake default scope so Enumeration.default will check |
@@ -21,11 +21,7 class Project < ActiveRecord::Base | |||||
21 | STATUS_ARCHIVED = 9 |
|
21 | STATUS_ARCHIVED = 9 | |
22 |
|
22 | |||
23 | # Specific overidden Activities |
|
23 | # Specific overidden Activities | |
24 |
has_many :time_entry_activities |
|
24 | has_many :time_entry_activities | |
25 | def active |
|
|||
26 | find(:all, :conditions => {:active => true}) |
|
|||
27 | end |
|
|||
28 | end |
|
|||
29 | has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}" |
|
25 | has_many :members, :include => [:user, :roles], :conditions => "#{User.table_name}.type='User' AND #{User.table_name}.status=#{User::STATUS_ACTIVE}" | |
30 | has_many :member_principals, :class_name => 'Member', |
|
26 | has_many :member_principals, :class_name => 'Member', | |
31 | :include => :principal, |
|
27 | :include => :principal, | |
@@ -572,7 +568,7 class Project < ActiveRecord::Base | |||||
572 | overridden_activity_ids = self.time_entry_activities.active.collect(&:parent_id) |
|
568 | overridden_activity_ids = self.time_entry_activities.active.collect(&:parent_id) | |
573 |
|
569 | |||
574 | if overridden_activity_ids.empty? |
|
570 | if overridden_activity_ids.empty? | |
575 | return TimeEntryActivity.active |
|
571 | return TimeEntryActivity.shared.active | |
576 | else |
|
572 | else | |
577 | return system_activities_and_project_overrides |
|
573 | return system_activities_and_project_overrides | |
578 | end |
|
574 | end | |
@@ -584,7 +580,7 class Project < ActiveRecord::Base | |||||
584 | overridden_activity_ids = self.time_entry_activities.collect(&:parent_id) |
|
580 | overridden_activity_ids = self.time_entry_activities.collect(&:parent_id) | |
585 |
|
581 | |||
586 | if overridden_activity_ids.empty? |
|
582 | if overridden_activity_ids.empty? | |
587 |
return TimeEntryActivity. |
|
583 | return TimeEntryActivity.shared | |
588 | else |
|
584 | else | |
589 | return system_activities_and_project_overrides(true) |
|
585 | return system_activities_and_project_overrides(true) | |
590 | end |
|
586 | end | |
@@ -593,12 +589,12 class Project < ActiveRecord::Base | |||||
593 | # Returns the systemwide active activities merged with the project specific overrides |
|
589 | # Returns the systemwide active activities merged with the project specific overrides | |
594 | def system_activities_and_project_overrides(include_inactive=false) |
|
590 | def system_activities_and_project_overrides(include_inactive=false) | |
595 | if include_inactive |
|
591 | if include_inactive | |
596 |
return TimeEntryActivity. |
|
592 | return TimeEntryActivity.shared. | |
597 | find(:all, |
|
593 | find(:all, | |
598 | :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) + |
|
594 | :conditions => ["id NOT IN (?)", self.time_entry_activities.collect(&:parent_id)]) + | |
599 | self.time_entry_activities |
|
595 | self.time_entry_activities | |
600 | else |
|
596 | else | |
601 | return TimeEntryActivity.active. |
|
597 | return TimeEntryActivity.shared.active. | |
602 | find(:all, |
|
598 | find(:all, | |
603 | :conditions => ["id NOT IN (?)", self.time_entry_activities.active.collect(&:parent_id)]) + |
|
599 | :conditions => ["id NOT IN (?)", self.time_entry_activities.active.collect(&:parent_id)]) + | |
604 | self.time_entry_activities.active |
|
600 | self.time_entry_activities.active |
@@ -3,7 +3,7 | |||||
3 | <% Enumeration.get_subclasses.each do |klass| %> |
|
3 | <% Enumeration.get_subclasses.each do |klass| %> | |
4 | <h3><%= l(klass::OptionName) %></h3> |
|
4 | <h3><%= l(klass::OptionName) %></h3> | |
5 |
|
5 | |||
6 |
<% enumerations = klass. |
|
6 | <% enumerations = klass.shared %> | |
7 | <% if enumerations.any? %> |
|
7 | <% if enumerations.any? %> | |
8 | <table class="list"> |
|
8 | <table class="list"> | |
9 | <tr> |
|
9 | <tr> |
General Comments 0
You need to be logged in to leave comments.
Login now