Feature #2096 » group-field.patch
| app/helpers/issues_helper.rb (working copy) | ||
|---|---|---|
|
n = 0
|
||
|
ordered_values.compact.each do |value|
|
||
|
s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
|
||
|
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
|
||
|
s << "\t<th>#{ h(value.custom_field.name) }:</th><td>"
|
||
|
s << value.custom_field.field_format == "group_list" ? show_value_on_view(value) : simple_format_without_paragraph(h(show_value(value)))
|
||
|
s << "</td>\n"
|
||
|
n += 1
|
||
|
end
|
||
|
s << "</tr>\n"
|
||
|
s
|
||
|
return s
|
||
|
end
|
||
|
|
||
|
def sidebar_queries
|
||
| ... | ... | |
|
|
||
|
unless no_html
|
||
|
label = content_tag('strong', label)
|
||
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||
|
if !custom_field.nil? && custom_field.field_format == 'group_list'
|
||
|
old_value = content_tag("i", old_value) if detail.old_value
|
||
|
else
|
||
|
old_value = content_tag("i", h(old_value)) if detail.old_value
|
||
|
end
|
||
|
old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
|
||
|
if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
|
||
|
# Link to the attachment if it has not been removed
|
||
|
value = link_to_attachment(a)
|
||
|
elsif !custom_field.nil? && custom_field.field_format == 'group_list'
|
||
|
value = content_tag("i", value) if value
|
||
|
else
|
||
|
value = content_tag("i", h(value)) if value
|
||
|
end
|
||
| app/helpers/custom_fields_helper.rb (working copy) | ||
|---|---|---|
|
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
||
|
'<option></option>'
|
||
|
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
|
||
|
when 'group_list'
|
||
|
groups = @project.principals
|
||
|
groups.delete_if { |group| group.type != 'Group' }
|
||
|
custom_field.possible_values.clear()
|
||
|
groups.each { |group| custom_field.possible_values << group if group.type == 'Group' }
|
||
|
blank_option = custom_field.is_required? ?
|
||
|
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
|
||
|
'<option></option>'
|
||
|
select_tag(field_name, blank_option + options_for_select(groups.collect { |x| [x.lastname, x.id] }, custom_value.value), :id => field_id)
|
||
|
else
|
||
|
text_field_tag(field_name, custom_value.value, :id => field_id)
|
||
|
end
|
||
| ... | ... | |
|
begin; format_date(value.to_date); rescue; value end
|
||
|
when "bool"
|
||
|
l(value == "1" ? :general_text_Yes : :general_text_No)
|
||
|
when 'group_list':
|
||
|
link_to_group(Group.find(:first, :conditions => [ 'id = ?', value]))
|
||
|
else
|
||
|
value
|
||
|
end
|
||
| ... | ... | |
|
def custom_field_formats_for_select
|
||
|
CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
|
||
|
end
|
||
|
# Return a string used to display a custom value on the issues view
|
||
|
def format_value_for_view(value, field_format)
|
||
|
return "-" unless value && !value.empty?
|
||
|
case field_format
|
||
|
when 'group_list'
|
||
|
link_to_group(Group.find(:first, :conditions => [ 'id = ?', value]))
|
||
|
else
|
||
|
format_value(value, field_format)
|
||
|
end
|
||
|
end
|
||
|
def show_value_on_view(custom_value)
|
||
|
return "" unless custom_value
|
||
|
format_value_for_view(custom_value.value, custom_value.custom_field.field_format)
|
||
|
end
|
||
|
end
|
||
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
# Displays a link to the group
|
||
|
def link_to_group(group, options={})
|
||
|
if group.is_a?(Group)
|
||
|
link_to group.lastname, :controller => 'groups', :action => 'show', :id => group
|
||
|
else
|
||
|
h(group.to_s)
|
||
|
end
|
||
|
end
|
||
|
# Displays a link to +issue+ with its subject.
|
||
|
# Examples:
|
||
|
#
|
||
| app/models/issue.rb (working copy) | ||
|---|---|---|
|
# Author and assignee are always notified unless they have been locked
|
||
|
notified << author if author && author.active?
|
||
|
notified << assigned_to if assigned_to && assigned_to.active?
|
||
|
## EEH: TODO: add Group-email addresses here at some point
|
||
|
notified.uniq!
|
||
|
# Remove users that can not view the issue
|
||
|
notified.reject! {|user| !visible?(user)}
|
||
| app/models/custom_field.rb (working copy) | ||
|---|---|---|
|
"int" => { :name => :label_integer, :order => 3 },
|
||
|
"float" => { :name => :label_float, :order => 4 },
|
||
|
"list" => { :name => :label_list, :order => 5 },
|
||
|
"date" => { :name => :label_date, :order => 6 },
|
||
|
"bool" => { :name => :label_boolean, :order => 7 }
|
||
|
"date" => { :name => :label_date, :order => 6 },
|
||
|
"bool" => { :name => :label_boolean, :order => 7 },
|
||
|
"group_list" => { :name => :label_group_list, :order => 8 },
|
||
|
}.freeze
|
||
|
validates_presence_of :name, :field_format
|
||
| app/views/custom_fields/_form.rhtml (working copy) | ||
|---|---|---|
|
if (p_searchable) Element.show(p_searchable.parentNode);
|
||
|
Element.show(p_values);
|
||
|
break;
|
||
|
case 'group_list':
|
||
|
p_default.setAttribute('type','combolist');
|
||
|
Element.hide(p_length.parentNode);
|
||
|
Element.hide(p_regexp.parentNode);
|
||
|
if (p_searchable) Element.show(p_searchable.parentNode);
|
||
|
Element.hide(p_values);
|
||
|
break;
|
||
|
case "bool":
|
||
|
p_default.setAttribute('type','checkbox');
|
||
|
Element.hide(p_length.parentNode);
|
||
| app/views/projects/show.rhtml (working copy) | ||
|---|---|---|
|
<% end %>
|
||
|
<% @project.custom_values.each do |custom_value| %>
|
||
|
<% if !custom_value.value.blank? %>
|
||
|
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
||
|
<li><%= custom_value.custom_field.name%>: <%= custom_value.custom_field.field_format == "group_list" ? h(show_value_on_view(custom_value)) : h(show_value(custom_value)) %></li>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</ul>
|
||
| config/locales/en.yml (working copy) | ||
|---|---|---|
|
label_and_its_subprojects: "{{value}} and its subprojects"
|
||
|
label_min_max_length: Min - Max length
|
||
|
label_list: List
|
||
|
## EEH: TODO: Translation
|
||
|
label_group_list: Group List
|
||
|
label_date: Date
|
||
|
label_integer: Integer
|
||
|
label_float: Float
|
||