##// END OF EJS Templates
Don't add the inclusion error when tracker is not set, the blank error is enough....
Don't add the inclusion error when tracker is not set, the blank error is enough. git-svn-id: http://svn.redmine.org/redmine/trunk@15492 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r15110:90d14b71b365
Show More
custom_fields_helper.rb
176 lines | 6.6 KiB | text/x-ruby | RubyLexer
/ app / helpers / custom_fields_helper.rb
Jean-Philippe Lang
Added encoding comment to helpers (#9792)....
r8090 # encoding: utf-8
#
Jean-Philippe Lang
Fixed: unknown custom field format causes error when editing/bulk editing (#7985)....
r5094 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # 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.
module CustomFieldsHelper
Jean-Philippe Lang
Moved CUSTOM_FIELDS_TABS out of the model....
r11847 CUSTOM_FIELDS_TABS = [
{:name => 'IssueCustomField', :partial => 'custom_fields/index',
:label => :label_issue_plural},
{:name => 'TimeEntryCustomField', :partial => 'custom_fields/index',
:label => :label_spent_time},
{:name => 'ProjectCustomField', :partial => 'custom_fields/index',
:label => :label_project_plural},
{:name => 'VersionCustomField', :partial => 'custom_fields/index',
:label => :label_version_plural},
Jean-Philippe Lang
Adds custom fields to documents (#7249)....
r13622 {:name => 'DocumentCustomField', :partial => 'custom_fields/index',
:label => :label_document_plural},
Jean-Philippe Lang
Moved CUSTOM_FIELDS_TABS out of the model....
r11847 {:name => 'UserCustomField', :partial => 'custom_fields/index',
:label => :label_user_plural},
{:name => 'GroupCustomField', :partial => 'custom_fields/index',
:label => :label_group_plural},
{:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index',
:label => TimeEntryActivity::OptionName},
{:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index',
:label => IssuePriority::OptionName},
{:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index',
:label => DocumentCategory::OptionName}
]
Jean-Philippe Lang
Show tabs for existing custom field types only and adds a view for choosing the type when adding a new custom field....
r12574 def render_custom_fields_tabs(types)
tabs = CUSTOM_FIELDS_TABS.select {|h| types.include?(h[:name]) }
render_tabs tabs
end
def custom_field_type_options
CUSTOM_FIELDS_TABS.map {|h| [l(h[:label]), h[:name]]}
Jean-Philippe Lang
Do not use javascript to hide tabs content on page loading and make tabs work with javascript disabled....
r1278 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
Helper method for custom field title....
r14369 def custom_field_title(custom_field)
items = []
items << [l(:label_custom_field_plural), custom_fields_path]
items << [l(custom_field.type_name), custom_fields_path(:tab => custom_field.class.name)] if custom_field
items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name)
title(*items)
end
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 def render_custom_field_format_partial(form, custom_field)
partial = custom_field.format.form_partial
if partial
render :partial => custom_field.format.form_partial, :locals => {:f => form, :custom_field => custom_field}
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 def custom_field_tag_name(prefix, custom_field)
name = "#{prefix}[custom_field_values][#{custom_field.id}]"
name << "[]" if custom_field.multiple?
name
end
def custom_field_tag_id(prefix, custom_field)
"#{prefix}_custom_field_values_#{custom_field.id}"
end
# Return custom field html tag corresponding to its format
def custom_field_tag(prefix, custom_value)
custom_value.custom_field.format.edit_tag self,
custom_field_tag_id(prefix, custom_value.custom_field),
custom_field_tag_name(prefix, custom_value.custom_field),
custom_value,
:class => "#{custom_value.custom_field.field_format}_cf"
end
Jean-Philippe Lang
Include custom fields description in project settings and issue view (#19296)....
r13772 # Return custom field name tag
def custom_field_name_tag(custom_field)
title = custom_field.description.presence
Jean-Philippe Lang
Help cursor showing up on span tags with title (#20633)....
r14170 css = title ? "field-description" : nil
content_tag 'span', custom_field.name, :title => title, :class => css
Jean-Philippe Lang
Include custom fields description in project settings and issue view (#19296)....
r13772 end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # Return custom field label tag
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 def custom_field_label_tag(name, custom_value, options={})
required = options[:required] || custom_value.custom_field.is_required?
Jean-Philippe Lang
Include custom fields description in project settings and issue view (#19296)....
r13772 content = custom_field_name_tag custom_value.custom_field
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 content_tag "label", content +
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 (required ? " <span class=\"required\">*</span>".html_safe : ""),
:for => "#{name}_custom_field_values_#{custom_value.custom_field.id}"
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # Return custom field tag with its label tag
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 def custom_field_tag_with_label(name, custom_value, options={})
custom_field_label_tag(name, custom_value, options) + custom_field_tag(name, custom_value)
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 # Returns the custom field tag for when bulk editing objects
def custom_field_tag_for_bulk_edit(prefix, custom_field, objects=nil, value='')
custom_field.format.bulk_edit_tag self,
custom_field_tag_id(prefix, custom_field),
custom_field_tag_name(prefix, custom_field),
custom_field,
objects,
value,
:class => "#{custom_field.field_format}_cf"
Jean-Philippe Lang
Allow bulk edit custom fields of any type (#461)....
r3164 end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330
# Return a string used to display a custom value
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 def show_value(custom_value, html=true)
format_object(custom_value, html)
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # Return a string used to display a custom value
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 def format_value(value, custom_field)
format_object(custom_field.format.formatted_value(self, custom_field, value, false), false)
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
# Return an array of custom field formats which can be used in select_tag
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 def custom_field_formats_for_select(custom_field)
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 Redmine::FieldFormat.as_select(custom_field.class.customized_class.name)
Jean-Philippe Lang
0.3 unstable...
r10 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/custom_fields_helper.rb....
r6582
Jean-Philippe Lang
Fixed: Custom field is rendered, even if its value is empty (for multiple) (#18654)....
r13482 # Yields the given block for each custom field value of object that should be
# displayed, with the custom field and the formatted value as arguments
def render_custom_field_values(object, &block)
object.visible_custom_field_values.each do |custom_value|
formatted = show_value(custom_value)
if formatted.present?
yield custom_value.custom_field, formatted
end
end
end
Jean-Philippe Lang
Fixed: error when serializing back objects with custom fields using ActiveResource (#6403)....
r4366 # Renders the custom_values in api views
def render_api_custom_values(custom_values, api)
api.array :custom_fields do
custom_values.each do |custom_value|
Jean-Philippe Lang
Adds support for multiselect custom fields (#1189)....
r8601 attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name}
attrs.merge!(:multiple => true) if custom_value.custom_field.multiple?
api.custom_field attrs do
if custom_value.value.is_a?(Array)
api.array :value do
custom_value.value.each do |value|
api.value value unless value.blank?
end
end
else
api.value custom_value.value
end
Jean-Philippe Lang
Fixed: error when serializing back objects with custom fields using ActiveResource (#6403)....
r4366 end
end
end unless custom_values.empty?
end
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125
Jean-Philippe Lang
Option to render boolean custom fields as a single check box or radio buttons (#17003)....
r12941 def edit_tag_style_tag(form, options={})
select_options = [[l(:label_drop_down_list), ''], [l(:label_checkboxes), 'check_box']]
if options[:include_radio]
select_options << [l(:label_radio_buttons), 'radio']
end
form.select :edit_tag_style, select_options, :label => :label_display
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 end
Jean-Philippe Lang
Initial commit...
r2 end