Feature #1953 ยป issue_1953.diff
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
require 'date'
|
||
|
class IssuesController < ApplicationController
|
||
|
menu_item :new_issue, :only => :new
|
||
| ... | ... | |
|
UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
|
||
|
|
||
|
def edit
|
||
|
if ! manage_issue_due_date params
|
||
|
flash[:error] = l(:error_update_due_date_fields_required)
|
||
|
redirect_to(params[:back_to] || {:action => 'show', :id => @issue}) and return
|
||
|
end
|
||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||
|
@priorities = IssuePriority.all
|
||
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
private
|
||
|
def manage_issue_due_date(params)
|
||
|
if params[:issue][:update_due_date_based_on_estimated_hours].to_i == 1
|
||
|
if params[:issue][:estimated_hours].blank? or params[:issue][:start_date].blank?
|
||
|
return false
|
||
|
else
|
||
|
additional_days = 0
|
||
|
if params[:issue][:estimated_hours].to_f % Setting.hours_in_work_day.to_f != 0 && params[:issue][:estimated_hours].to_f > Setting.hours_in_work_day.to_f
|
||
|
additional_days += 1
|
||
|
end
|
||
|
work_days_needed = (params[:issue][:estimated_hours].to_f / Setting.hours_in_work_day.to_f).to_i
|
||
|
work_days_needed += additional_days
|
||
|
params[:issue][:due_date] = (Date.parse(params[:issue][:start_date]) + work_days_needed-1)
|
||
|
# In the span from start date to due date, add additional days for every non-work day
|
||
|
number_of_non_work_days = 0
|
||
|
(Date.parse(params[:issue][:start_date])..params[:issue][:due_date]).each do |date|
|
||
|
if ! Setting.days_in_work_week.include?(Date::DAYNAMES[date.wday].downcase)
|
||
|
number_of_non_work_days += 1
|
||
|
end
|
||
|
end
|
||
|
params[:issue][:due_date] = params[:issue][:due_date] + number_of_non_work_days
|
||
|
# Now make sure our end date isn't a non-work day...
|
||
|
while ! Setting.days_in_work_week.include?(Date::DAYNAMES[params[:issue][:due_date].wday].downcase)
|
||
|
params[:issue][:due_date] = params[:issue][:due_date] + 1
|
||
|
end
|
||
|
params[:issue][:due_date] = params[:issue][:due_date].strftime('%Y-%m-%d')
|
||
|
end
|
||
|
end
|
||
|
return true
|
||
|
end
|
||
|
def find_issue
|
||
|
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
|
||
|
@project = @issue.project
|
||
| app/models/issue.rb | ||
|---|---|---|
|
before_save :update_done_ratio_from_issue_status
|
||
|
after_save :create_journal
|
||
|
attr_accessor :update_due_date_based_on_estimated_hours
|
||
|
|
||
|
# Returns true if usr or current user is allowed to view the issue
|
||
|
def visible?(usr=nil)
|
||
| app/views/issues/_attributes.rhtml | ||
|---|---|---|
|
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
|
||
|
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
|
||
|
<p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
|
||
|
<p><%= f.check_box :update_due_date_based_on_estimated_hours %></p>
|
||
|
<% if Issue.use_field_for_done_ratio? %>
|
||
|
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||
|
<% end %>
|
||
| app/views/settings/_issues.rhtml | ||
|---|---|---|
|
<%= select_tag 'settings[issue_done_ratio]',
|
||
|
options_for_select(Issue::DONE_RATIO_OPTIONS.collect {|i| [l("setting_issue_done_ratio_#{i}"), i]}, Setting.issue_done_ratio) %></p>
|
||
|
<p><label><%= l(:setting_hours_in_work_day) %></label>
|
||
|
<%= text_field_tag 'settings[hours_in_work_day]', Setting.hours_in_work_day, :size => 2 %></p>
|
||
|
<p><label><%= l(:setting_issues_export_limit) %></label>
|
||
|
<%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
|
||
|
</div>
|
||
|
<fieldset class="box settings"><legend><%= l(:setting_days_in_work_week) %></legend>
|
||
|
<%= hidden_field_tag 'settings[days_in_work_week][]', '' %>
|
||
|
<% l('date.day_names').map{|d| d.downcase}.each do |day| %>
|
||
|
<label><%= check_box_tag 'settings[days_in_work_week][]', day, Setting.days_in_work_week.include?(day) %>
|
||
|
<%= day.capitalize %></label><br />
|
||
|
<% end %>
|
||
|
</fieldset>
|
||
|
<fieldset class="box settings"><legend><%= l(:setting_issue_list_default_columns) %></legend>
|
||
|
<%= hidden_field_tag 'settings[issue_list_default_columns][]', '' %>
|
||
|
<% Query.new.available_columns.each do |column| %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
error_issue_done_ratios_not_updated: "Issue done ratios not updated."
|
||
|
error_workflow_copy_source: 'Please select a source tracker or role'
|
||
|
error_workflow_copy_target: 'Please select target tracker(s) and role(s)'
|
||
|
error_update_due_date_fields_required: Start date and estimated time are required in order to update due date based on estimated hours.
|
||
|
|
||
|
warning_attachments_not_saved: "{{count}} file(s) could not be saved."
|
||
|
|
||
| ... | ... | |
|
field_content: Content
|
||
|
field_group_by: Group results by
|
||
|
field_sharing: Sharing
|
||
|
field_update_due_date_based_on_estimated_hours: Update Due Date Based On Estimated Hours
|
||
|
|
||
|
setting_app_title: Application title
|
||
|
setting_app_subtitle: Application subtitle
|
||
| ... | ... | |
|
setting_issue_done_ratio_issue_field: Use the issue field
|
||
|
setting_issue_done_ratio_issue_status: Use the issue status
|
||
|
setting_start_of_week: Start calendars on
|
||
|
setting_hours_in_work_day: Hours in work day
|
||
|
setting_days_in_work_week: Days in work week
|
||
|
|
||
|
permission_add_project: Create project
|
||
|
permission_edit_project: Edit project
|
||
| config/settings.yml | ||
|---|---|---|
|
default: 0
|
||
|
mail_handler_api_key:
|
||
|
default:
|
||
|
days_in_work_week:
|
||
|
default:
|
||
|
- monday
|
||
|
- tuesday
|
||
|
- wednesday
|
||
|
- thursday
|
||
|
- friday
|
||
|
issue_list_default_columns:
|
||
|
serialized: true
|
||
|
default:
|
||
| ... | ... | |
|
default: 1
|
||
|
issue_done_ratio:
|
||
|
default: 'issue_field'
|
||
|
hours_in_work_day:
|
||
|
default: 8
|
||
|
default_projects_public:
|
||
|
default: 1
|
||
|
default_projects_modules:
|
||