-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setting to chooze custom field for time limit
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<% | ||
default = Setting.available_settings[SETTINGS_NAME.to_s]['default'] | ||
%> | ||
<table> | ||
<tbody> | ||
|
||
<tr> | ||
<th align="right"><%= t 'use_custom_field' %></th> | ||
<td colspan="2"> | ||
<%=check_box_tag("settings[estimated_field_use]",1, settings['estimated_field_use']) %> | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<th align="right"><%= t 'estimation_limit_custom_field' %></th> | ||
<td colspan="2"> | ||
<%= select_tag("settings[estimated_field]", | ||
options_from_collection_for_select(IssueCustomField.where(field_format: 'float').all, "id", "name", settings['estimated_field'])) %> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require_dependency 'issue' | ||
|
||
module IssuePatch | ||
|
||
def self.included(base) # :nodoc: | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
unloadable # Send unloadable so it will not be unloaded in development | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def estimated_internal | ||
use = Setting[SETTINGS_NAME]['estimated_field_use'] | ||
if (use.nil? || use == false) | ||
return estimated_hours | ||
end | ||
|
||
@custom_field_estimated_id ||= CustomField.find(Setting[SETTINGS_NAME]['estimated_field']).id | ||
@estimated_internal ||= custom_field_values.select{|item| item.custom_field_id == @custom_field_estimated_id}.shift | ||
@estimated_internal.nil? ? 0.to_f : @estimated_internal.value.to_f | ||
end | ||
|
||
def estimated_internal=(value) | ||
@estimated_internal.value = value.to_f if !@estimated_internal.nil? | ||
end | ||
end | ||
end | ||
|
||
|
||
Issue.send(:include, IssuePatch) |