##// END OF EJS Templates
Added an active field track if an Enumeration is active on the frontend view....
Eric Davis -
r2832:e76d4c5c4c3f
parent child
Show More
@@ -0,0 +1,9
1 class AddActiveFieldToEnumerations < ActiveRecord::Migration
2 def self.up
3 add_column :enumerations, :active, :boolean, :default => true, :null => false
4 end
5
6 def self.down
7 remove_column :enumerations, :active
8 end
9 end
@@ -25,11 +25,18 module TimelogHelper
25 25 links << link_to_issue(@issue) if @issue
26 26 breadcrumb links
27 27 end
28
29 def activity_collection_for_select_options
30 activities = TimeEntryActivity.all
28
29 # Returns a collection of activities for a select field. time_entry
30 # is optional and will be used to check if the selected TimeEntryActivity
31 # is active.
32 def activity_collection_for_select_options(time_entry=nil)
33 activities = TimeEntryActivity.active
31 34 collection = []
32 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
35 if time_entry && !time_entry.activity.active?
36 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ]
37 else
38 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
39 end
33 40 activities.each { |a| collection << [a.name, a.id] }
34 41 collection
35 42 end
@@ -53,9 +53,17 class Enumeration < ActiveRecord::Base
53 53 find(:first, :conditions => { :is_default => true })
54 54 end
55 55 end
56 # End backwards compatiblity named_scopes
56 57
57 58 named_scope :all, :order => 'position'
58 59
60 named_scope :active, lambda {
61 {
62 :conditions => {:active => true},
63 :order => 'position'
64 }
65 }
66
59 67 def self.default
60 68 # Creates a fake default scope so Enumeration.default will check
61 69 # it's type. STI subclasses will automatically add their own
@@ -6,6 +6,9
6 6 <p><label for="enumeration_name"><%=l(:field_name)%></label>
7 7 <%= text_field 'enumeration', 'name' %></p>
8 8
9 <p><label for="enumeration_active"><%=l(:field_active)%></label>
10 <%= check_box 'enumeration', 'active' %></p>
11
9 12 <p><label for="enumeration_is_default"><%=l(:field_is_default)%></label>
10 13 <%= check_box 'enumeration', 'is_default' %></p>
11 14 <!--[eoform:optvalue]-->
@@ -13,4 +16,4
13 16 <% @enumeration.custom_field_values.each do |value| %>
14 17 <p><%= custom_field_tag_with_label :enumeration, value %></p>
15 18 <% end %>
16 </div> No newline at end of file
19 </div>
@@ -6,10 +6,18
6 6 <% enumerations = klass.all %>
7 7 <% if enumerations.any? %>
8 8 <table class="list">
9 <tr>
10 <th><%= l(:field_name) %></th>
11 <th style="width:15%;"><%= l(:field_is_default) %></th>
12 <th style="width:15%;"><%= l(:field_active) %></th>
13 <th style="width:15%;"></th>
14 <th align="center" style="width:10%;"> </th>
15 </tr>
9 16 <% enumerations.each do |enumeration| %>
10 17 <tr class="<%= cycle('odd', 'even') %>">
11 18 <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
12 19 <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
20 <td style="width:15%;"><%= image_tag('true.png') if enumeration.active? %></td>
13 21 <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
14 22 <td class="buttons">
15 23 <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration },
@@ -9,7 +9,7
9 9 <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
10 10 <p><%= f.text_field :hours, :size => 6, :required => true %></p>
11 11 <p><%= f.text_field :comments, :size => 100 %></p>
12 <p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
12 <p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
13 13 <% @time_entry.custom_field_values.each do |value| %>
14 14 <p><%= custom_field_tag_with_label :time_entry, value %></p>
15 15 <% end %>
@@ -748,6 +748,8 en:
748 748 status_active: active
749 749 status_registered: registered
750 750 status_locked: locked
751
752 field_active: Active
751 753
752 754 text_select_mail_notifications: Select actions for which email notifications should be sent.
753 755 text_regexp_info: eg. ^[A-Z0-9]+$
@@ -4,66 +4,85 enumerations_001:
4 4 id: 1
5 5 opt: DCAT
6 6 type: DocumentCategory
7 active: true
7 8 enumerations_002:
8 9 name: User documentation
9 10 id: 2
10 11 opt: DCAT
11 12 type: DocumentCategory
13 active: true
12 14 enumerations_003:
13 15 name: Technical documentation
14 16 id: 3
15 17 opt: DCAT
16 18 type: DocumentCategory
19 active: true
17 20 enumerations_004:
18 21 name: Low
19 22 id: 4
20 23 opt: IPRI
21 24 type: IssuePriority
25 active: true
22 26 enumerations_005:
23 27 name: Normal
24 28 id: 5
25 29 opt: IPRI
26 30 type: IssuePriority
27 31 is_default: true
32 active: true
28 33 enumerations_006:
29 34 name: High
30 35 id: 6
31 36 opt: IPRI
32 37 type: IssuePriority
38 active: true
33 39 enumerations_007:
34 40 name: Urgent
35 41 id: 7
36 42 opt: IPRI
37 43 type: IssuePriority
44 active: true
38 45 enumerations_008:
39 46 name: Immediate
40 47 id: 8
41 48 opt: IPRI
42 49 type: IssuePriority
50 active: true
43 51 enumerations_009:
44 52 name: Design
45 53 id: 9
46 54 opt: ACTI
47 55 type: TimeEntryActivity
56 active: true
48 57 enumerations_010:
49 58 name: Development
50 59 id: 10
51 60 opt: ACTI
52 61 type: TimeEntryActivity
53 62 is_default: true
63 active: true
54 64 enumerations_011:
55 65 name: QA
56 66 id: 11
57 67 opt: ACTI
58 68 type: TimeEntryActivity
69 active: true
59 70 enumerations_012:
60 71 name: Default Enumeration
61 72 id: 12
62 73 opt: ''
63 74 type: Enumeration
64 75 is_default: true
76 active: true
65 77 enumerations_013:
66 78 name: Another Enumeration
67 79 id: 13
68 80 opt: ''
69 81 type: Enumeration
82 active: true
83 enumerations_014:
84 name: Inactive Activity
85 id: 14
86 opt: ACTI
87 type: TimeEntryActivity
88 active: false
@@ -1,3 +1,4
1 # -*- coding: utf-8 -*-
1 2 # redMine - project management software
2 3 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 4 #
@@ -71,6 +72,28 class TimelogControllerTest < ActionController::TestCase
71 72 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/edit/2' }
72 73 end
73 74
75 def test_get_edit_should_only_show_active_time_entry_activities
76 @request.session[:user_id] = 3
77 get :edit, :project_id => 1
78 assert_response :success
79 assert_template 'edit'
80 assert_no_tag :tag => 'option', :content => 'Inactive Activity'
81
82 end
83
84 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
85 te = TimeEntry.find(1)
86 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
87 te.save!
88
89 @request.session[:user_id] = 1
90 get :edit, :project_id => 1, :id => 1
91 assert_response :success
92 assert_template 'edit'
93 # Blank option since nothing is pre-selected
94 assert_tag :tag => 'option', :content => '--- Please select ---'
95 end
96
74 97 def test_post_edit
75 98 # TODO: should POST to issues’ time log instead of project. change form
76 99 # and routing
General Comments 0
You need to be logged in to leave comments. Login now