Feature #24577 » settings_to_make_issue_id_comment_fields_mandatory_v2.patch
| app/helpers/settings_helper.rb | ||
|---|---|---|
|
{:name => 'api', :partial => 'settings/api', :label => :label_api},
|
||
|
{:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
|
||
|
{:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
|
||
|
{:name => 'timelog', :partial => 'settings/timelog', :label => :label_time_tracking},
|
||
|
{:name => 'attachments', :partial => 'settings/attachments', :label => :label_attachment_plural},
|
||
|
{:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
|
||
|
{:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
|
||
| app/models/time_entry.rb | ||
|---|---|---|
|
:scope => joins(:project).preload(:project)
|
||
|
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||
|
validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fields.include?('issue_id') }
|
||
|
validates_presence_of :comments, :if => lambda { Setting.timelog_required_fields.include?('comments') }
|
||
|
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
|
||
|
validates_length_of :comments, :maximum => 1024, :allow_nil => true
|
||
|
validates :spent_on, :date => true
|
||
| app/views/settings/_timelog.html.erb | ||
|---|---|---|
|
<%= form_tag({:action => 'edit', :tab => 'timelog'}) do %>
|
||
|
<div class="box tabular settings">
|
||
|
<p><%= setting_multiselect(:timelog_required_fields,
|
||
|
[[l(:field_issue), 'issue_id'], [l(:field_comments), 'comments'] ]) %></p>
|
||
|
</div>
|
||
|
<%= submit_tag l(:button_save) %>
|
||
|
<% end %>
|
||
| app/views/timelog/_form.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
<% end %>
|
||
|
<p>
|
||
|
<%= f.text_field :issue_id, :size => 6 %>
|
||
|
<%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
|
||
|
<span id="time_entry_issue">
|
||
|
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
|
||
|
</span>
|
||
|
</p>
|
||
|
<p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
|
||
|
<p><%= f.hours_field :hours, :size => 6, :required => true %></p>
|
||
|
<p><%= f.text_field :comments, :size => 100, :maxlength => 1024 %></p>
|
||
|
<p><%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %></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>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
setting_attachment_extensions_allowed: Allowed extensions
|
||
|
setting_attachment_extensions_denied: Disallowed extensions
|
||
|
setting_new_item_menu_tab: Project menu tab for creating new objects
|
||
|
setting_timelog_required_fields: Required fields for time logs
|
||
|
permission_add_project: Create project
|
||
|
permission_add_subprojects: Create subprojects
|
||
| config/settings.yml | ||
|---|---|---|
|
- '7'
|
||
|
new_item_menu_tab:
|
||
|
default: 2
|
||
|
timelog_required_fields:
|
||
|
serialized: true
|
||
|
default: ''
|
||
| test/unit/time_entry_test.rb | ||
|---|---|---|
|
:activity => activity)
|
||
|
assert_equal project.id, te.project.id
|
||
|
end
|
||
|
def test_create_with_required_issue_id_and_comment_should_be_validated
|
||
|
with_settings :timelog_required_fields => ['issue_id' , 'comments'] do
|
||
|
entry = TimeEntry.new(:project => Project.find(1), :spent_on => Date.today, :user => User.find(1), :activity => TimeEntryActivity.first, :hours => 1)
|
||
|
assert !entry.save
|
||
|
assert_equal ["Comment cannot be blank", "Issue cannot be blank"], entry.errors.full_messages.sort
|
||
|
end
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- 3
- Next »