summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2009-10-21 22:34:28 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2009-10-21 22:34:28 +0000
commite76d4c5c4c3f2beb8be1f441148e4627a14d37d1 (patch)
tree8f1ea0620882ad97d3804018d109f8a35f1ed4a0 /app
parentac4937a76755de2f9b6a83f6160efa0fde2d03aa (diff)
downloadredmine-e76d4c5c4c3f2beb8be1f441148e4627a14d37d1.tar.gz
redmine-e76d4c5c4c3f2beb8be1f441148e4627a14d37d1.zip
Added an active field track if an Enumeration is active on the frontend view.
* Changed TimelogHelper#activity_collection_for_select_options to only use active TimeEntryActivities. * Changed TimelogHelper#activity_collection_for_select_options to return a blank option if the time_entry's current activity is inactive. #4077 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2946 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/timelog_helper.rb15
-rw-r--r--app/models/enumeration.rb8
-rw-r--r--app/views/enumerations/_form.rhtml5
-rw-r--r--app/views/enumerations/list.rhtml8
-rw-r--r--app/views/timelog/edit.rhtml2
5 files changed, 32 insertions, 6 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb
index 861c2acc7..0c3e7e6b6 100644
--- a/app/helpers/timelog_helper.rb
+++ b/app/helpers/timelog_helper.rb
@@ -25,11 +25,18 @@ module TimelogHelper
links << link_to_issue(@issue) if @issue
breadcrumb links
end
-
- def activity_collection_for_select_options
- activities = TimeEntryActivity.all
+
+ # Returns a collection of activities for a select field. time_entry
+ # is optional and will be used to check if the selected TimeEntryActivity
+ # is active.
+ def activity_collection_for_select_options(time_entry=nil)
+ activities = TimeEntryActivity.active
collection = []
- collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
+ if time_entry && !time_entry.activity.active?
+ collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ]
+ else
+ collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
+ end
activities.each { |a| collection << [a.name, a.id] }
collection
end
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb
index 4fb7d6d07..436e82373 100644
--- a/app/models/enumeration.rb
+++ b/app/models/enumeration.rb
@@ -53,9 +53,17 @@ class Enumeration < ActiveRecord::Base
find(:first, :conditions => { :is_default => true })
end
end
+ # End backwards compatiblity named_scopes
named_scope :all, :order => 'position'
+ named_scope :active, lambda {
+ {
+ :conditions => {:active => true},
+ :order => 'position'
+ }
+ }
+
def self.default
# Creates a fake default scope so Enumeration.default will check
# it's type. STI subclasses will automatically add their own
diff --git a/app/views/enumerations/_form.rhtml b/app/views/enumerations/_form.rhtml
index 741bbc5d9..21b948166 100644
--- a/app/views/enumerations/_form.rhtml
+++ b/app/views/enumerations/_form.rhtml
@@ -6,6 +6,9 @@
<p><label for="enumeration_name"><%=l(:field_name)%></label>
<%= text_field 'enumeration', 'name' %></p>
+<p><label for="enumeration_active"><%=l(:field_active)%></label>
+<%= check_box 'enumeration', 'active' %></p>
+
<p><label for="enumeration_is_default"><%=l(:field_is_default)%></label>
<%= check_box 'enumeration', 'is_default' %></p>
<!--[eoform:optvalue]-->
@@ -13,4 +16,4 @@
<% @enumeration.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :enumeration, value %></p>
<% end %>
-</div> \ No newline at end of file
+</div>
diff --git a/app/views/enumerations/list.rhtml b/app/views/enumerations/list.rhtml
index 3ae144487..817751ab2 100644
--- a/app/views/enumerations/list.rhtml
+++ b/app/views/enumerations/list.rhtml
@@ -6,10 +6,18 @@
<% enumerations = klass.all %>
<% if enumerations.any? %>
<table class="list">
+<tr>
+ <th><%= l(:field_name) %></th>
+ <th style="width:15%;"><%= l(:field_is_default) %></th>
+ <th style="width:15%;"><%= l(:field_active) %></th>
+ <th style="width:15%;"></th>
+ <th align="center" style="width:10%;"> </th>
+</tr>
<% enumerations.each do |enumeration| %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
<td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
+ <td style="width:15%;"><%= image_tag('true.png') if enumeration.active? %></td>
<td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
<td class="buttons">
<%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration },
diff --git a/app/views/timelog/edit.rhtml b/app/views/timelog/edit.rhtml
index a0ff860f8..00d0a77c0 100644
--- a/app/views/timelog/edit.rhtml
+++ b/app/views/timelog/edit.rhtml
@@ -9,7 +9,7 @@
<p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
<p><%= f.text_field :hours, :size => 6, :required => true %></p>
<p><%= f.text_field :comments, :size => 100 %></p>
-<p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
+<p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
<% @time_entry.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :time_entry, value %></p>
<% end %>