@@ -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 |
@@ -26,10 +26,17 module TimelogHelper | |||||
26 | breadcrumb links |
|
26 | breadcrumb links | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def activity_collection_for_select_options |
|
29 | # Returns a collection of activities for a select field. time_entry | |
30 | activities = TimeEntryActivity.all |
|
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 | collection = [] |
|
34 | collection = [] | |
|
35 | if time_entry && !time_entry.activity.active? | |||
|
36 | collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] | |||
|
37 | else | |||
32 | collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default) |
|
38 | collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default) | |
|
39 | end | |||
33 | activities.each { |a| collection << [a.name, a.id] } |
|
40 | activities.each { |a| collection << [a.name, a.id] } | |
34 | collection |
|
41 | collection | |
35 | end |
|
42 | end |
@@ -53,9 +53,17 class Enumeration < ActiveRecord::Base | |||||
53 | find(:first, :conditions => { :is_default => true }) |
|
53 | find(:first, :conditions => { :is_default => true }) | |
54 | end |
|
54 | end | |
55 | end |
|
55 | end | |
|
56 | # End backwards compatiblity named_scopes | |||
56 |
|
57 | |||
57 | named_scope :all, :order => 'position' |
|
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 | def self.default |
|
67 | def self.default | |
60 | # Creates a fake default scope so Enumeration.default will check |
|
68 | # Creates a fake default scope so Enumeration.default will check | |
61 | # it's type. STI subclasses will automatically add their own |
|
69 | # it's type. STI subclasses will automatically add their own |
@@ -6,6 +6,9 | |||||
6 | <p><label for="enumeration_name"><%=l(:field_name)%></label> |
|
6 | <p><label for="enumeration_name"><%=l(:field_name)%></label> | |
7 | <%= text_field 'enumeration', 'name' %></p> |
|
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 | <p><label for="enumeration_is_default"><%=l(:field_is_default)%></label> |
|
12 | <p><label for="enumeration_is_default"><%=l(:field_is_default)%></label> | |
10 | <%= check_box 'enumeration', 'is_default' %></p> |
|
13 | <%= check_box 'enumeration', 'is_default' %></p> | |
11 | <!--[eoform:optvalue]--> |
|
14 | <!--[eoform:optvalue]--> |
@@ -6,10 +6,18 | |||||
6 | <% enumerations = klass.all %> |
|
6 | <% enumerations = klass.all %> | |
7 | <% if enumerations.any? %> |
|
7 | <% if enumerations.any? %> | |
8 | <table class="list"> |
|
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 | <% enumerations.each do |enumeration| %> |
|
16 | <% enumerations.each do |enumeration| %> | |
10 | <tr class="<%= cycle('odd', 'even') %>"> |
|
17 | <tr class="<%= cycle('odd', 'even') %>"> | |
11 | <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td> |
|
18 | <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td> | |
12 | <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td> |
|
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 | <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td> |
|
21 | <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td> | |
14 | <td class="buttons"> |
|
22 | <td class="buttons"> | |
15 | <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, |
|
23 | <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, |
@@ -9,7 +9,7 | |||||
9 | <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p> |
|
9 | <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p> | |
10 | <p><%= f.text_field :hours, :size => 6, :required => true %></p> |
|
10 | <p><%= f.text_field :hours, :size => 6, :required => true %></p> | |
11 | <p><%= f.text_field :comments, :size => 100 %></p> |
|
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 | <% @time_entry.custom_field_values.each do |value| %> |
|
13 | <% @time_entry.custom_field_values.each do |value| %> | |
14 | <p><%= custom_field_tag_with_label :time_entry, value %></p> |
|
14 | <p><%= custom_field_tag_with_label :time_entry, value %></p> | |
15 | <% end %> |
|
15 | <% end %> |
@@ -749,6 +749,8 en: | |||||
749 | status_registered: registered |
|
749 | status_registered: registered | |
750 | status_locked: locked |
|
750 | status_locked: locked | |
751 |
|
751 | |||
|
752 | field_active: Active | |||
|
753 | ||||
752 | text_select_mail_notifications: Select actions for which email notifications should be sent. |
|
754 | text_select_mail_notifications: Select actions for which email notifications should be sent. | |
753 | text_regexp_info: eg. ^[A-Z0-9]+$ |
|
755 | text_regexp_info: eg. ^[A-Z0-9]+$ | |
754 | text_min_max_length_info: 0 means no restriction |
|
756 | text_min_max_length_info: 0 means no restriction |
@@ -4,66 +4,85 enumerations_001: | |||||
4 | id: 1 |
|
4 | id: 1 | |
5 | opt: DCAT |
|
5 | opt: DCAT | |
6 | type: DocumentCategory |
|
6 | type: DocumentCategory | |
|
7 | active: true | |||
7 | enumerations_002: |
|
8 | enumerations_002: | |
8 | name: User documentation |
|
9 | name: User documentation | |
9 | id: 2 |
|
10 | id: 2 | |
10 | opt: DCAT |
|
11 | opt: DCAT | |
11 | type: DocumentCategory |
|
12 | type: DocumentCategory | |
|
13 | active: true | |||
12 | enumerations_003: |
|
14 | enumerations_003: | |
13 | name: Technical documentation |
|
15 | name: Technical documentation | |
14 | id: 3 |
|
16 | id: 3 | |
15 | opt: DCAT |
|
17 | opt: DCAT | |
16 | type: DocumentCategory |
|
18 | type: DocumentCategory | |
|
19 | active: true | |||
17 | enumerations_004: |
|
20 | enumerations_004: | |
18 | name: Low |
|
21 | name: Low | |
19 | id: 4 |
|
22 | id: 4 | |
20 | opt: IPRI |
|
23 | opt: IPRI | |
21 | type: IssuePriority |
|
24 | type: IssuePriority | |
|
25 | active: true | |||
22 | enumerations_005: |
|
26 | enumerations_005: | |
23 | name: Normal |
|
27 | name: Normal | |
24 | id: 5 |
|
28 | id: 5 | |
25 | opt: IPRI |
|
29 | opt: IPRI | |
26 | type: IssuePriority |
|
30 | type: IssuePriority | |
27 | is_default: true |
|
31 | is_default: true | |
|
32 | active: true | |||
28 | enumerations_006: |
|
33 | enumerations_006: | |
29 | name: High |
|
34 | name: High | |
30 | id: 6 |
|
35 | id: 6 | |
31 | opt: IPRI |
|
36 | opt: IPRI | |
32 | type: IssuePriority |
|
37 | type: IssuePriority | |
|
38 | active: true | |||
33 | enumerations_007: |
|
39 | enumerations_007: | |
34 | name: Urgent |
|
40 | name: Urgent | |
35 | id: 7 |
|
41 | id: 7 | |
36 | opt: IPRI |
|
42 | opt: IPRI | |
37 | type: IssuePriority |
|
43 | type: IssuePriority | |
|
44 | active: true | |||
38 | enumerations_008: |
|
45 | enumerations_008: | |
39 | name: Immediate |
|
46 | name: Immediate | |
40 | id: 8 |
|
47 | id: 8 | |
41 | opt: IPRI |
|
48 | opt: IPRI | |
42 | type: IssuePriority |
|
49 | type: IssuePriority | |
|
50 | active: true | |||
43 | enumerations_009: |
|
51 | enumerations_009: | |
44 | name: Design |
|
52 | name: Design | |
45 | id: 9 |
|
53 | id: 9 | |
46 | opt: ACTI |
|
54 | opt: ACTI | |
47 | type: TimeEntryActivity |
|
55 | type: TimeEntryActivity | |
|
56 | active: true | |||
48 | enumerations_010: |
|
57 | enumerations_010: | |
49 | name: Development |
|
58 | name: Development | |
50 | id: 10 |
|
59 | id: 10 | |
51 | opt: ACTI |
|
60 | opt: ACTI | |
52 | type: TimeEntryActivity |
|
61 | type: TimeEntryActivity | |
53 | is_default: true |
|
62 | is_default: true | |
|
63 | active: true | |||
54 | enumerations_011: |
|
64 | enumerations_011: | |
55 | name: QA |
|
65 | name: QA | |
56 | id: 11 |
|
66 | id: 11 | |
57 | opt: ACTI |
|
67 | opt: ACTI | |
58 | type: TimeEntryActivity |
|
68 | type: TimeEntryActivity | |
|
69 | active: true | |||
59 | enumerations_012: |
|
70 | enumerations_012: | |
60 | name: Default Enumeration |
|
71 | name: Default Enumeration | |
61 | id: 12 |
|
72 | id: 12 | |
62 | opt: '' |
|
73 | opt: '' | |
63 | type: Enumeration |
|
74 | type: Enumeration | |
64 | is_default: true |
|
75 | is_default: true | |
|
76 | active: true | |||
65 | enumerations_013: |
|
77 | enumerations_013: | |
66 | name: Another Enumeration |
|
78 | name: Another Enumeration | |
67 | id: 13 |
|
79 | id: 13 | |
68 | opt: '' |
|
80 | opt: '' | |
69 | type: Enumeration |
|
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 | # redMine - project management software |
|
2 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
4 | # | |
@@ -71,6 +72,28 class TimelogControllerTest < ActionController::TestCase | |||||
71 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/edit/2' } |
|
72 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/timelog/edit/2' } | |
72 | end |
|
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 | def test_post_edit |
|
97 | def test_post_edit | |
75 | # TODO: should POST to issues’ time log instead of project. change form |
|
98 | # TODO: should POST to issues’ time log instead of project. change form | |
76 | # and routing |
|
99 | # and routing |
General Comments 0
You need to be logged in to leave comments.
Login now