##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r14856:cda9c63d9c21
r15741:f8df935dcada
Show More
workflows_helper.rb
95 lines | 3.4 KiB | text/x-ruby | RubyLexer
/ app / helpers / workflows_helper.rb
Jean-Philippe Lang
Added encoding comment to helpers (#9792)....
r8090 # encoding: utf-8
#
Jean-Philippe Lang
Adds a workflow overview screen....
r1912 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Adds a workflow overview screen....
r1912 #
# 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/workflows_helper.rb....
r6820 #
Jean-Philippe Lang
Adds a workflow overview screen....
r1912 # 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/workflows_helper.rb....
r6820 #
Jean-Philippe Lang
Adds a workflow overview screen....
r1912 # 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 WorkflowsHelper
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 def options_for_workflow_select(name, objects, selected, options={})
option_tags = ''.html_safe
multiple = false
if selected
if selected.size == objects.size
selected = 'all'
else
selected = selected.map(&:id)
if selected.size > 1
multiple = true
end
end
else
selected = objects.first.try(:id)
end
all_tag_options = {:value => 'all', :selected => (selected == 'all')}
if multiple
all_tag_options.merge!(:style => "display:none;")
end
Jean-Philippe Lang
Removed hard-coded strings (#16164)....
r12653 option_tags << content_tag('option', l(:label_all), all_tag_options)
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 option_tags << options_from_collection_for_select(objects, "id", "name", selected)
select_tag name, option_tags, {:multiple => multiple}.merge(options)
end
Jean-Philippe Lang
Don't show "Required" option for standard/custom fields that are always required....
r9827 def field_required?(field)
Jean-Philippe Lang
Do not let is_private be required....
r9859 field.is_a?(CustomField) ? field.is_required? : %w(project_id tracker_id subject priority_id is_private).include?(field)
Jean-Philippe Lang
Don't show "Required" option for standard/custom fields that are always required....
r9827 end
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 def field_permission_tag(permissions, status, field, roles)
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 name = field.is_a?(CustomField) ? field.id.to_s : field
Jean-Philippe Lang
Don't show "Required" option for standard/custom fields that are always required....
r9827 options = [["", ""], [l(:label_readonly), "readonly"]]
options << [l(:label_required), "required"] unless field_required?(field)
Jean-Philippe Lang
Role-based issue custom field visibility (#5037)....
r11782 html_options = {}
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649
if perm = permissions[status.id][name]
if perm.uniq.size > 1 || perm.size < @roles.size * @trackers.size
options << [l(:label_no_change_option), "no_change"]
selected = 'no_change'
else
selected = perm.first
end
end
hidden = field.is_a?(CustomField) &&
!field.visible? &&
!roles.detect {|role| role.custom_fields.to_a.include?(field)}
Jean-Philippe Lang
No blank option for custom fields marked as required on workflow settings....
r9818
Jean-Philippe Lang
Role-based issue custom field visibility (#5037)....
r11782 if hidden
options[0][0] = l(:label_hidden)
selected = ''
html_options[:disabled] = true
end
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 select_tag("permissions[#{status.id}][#{name}]", options_for_select(options, selected), html_options)
end
def transition_tag(workflows, old_status, new_status, name)
Jean-Philippe Lang
Makes new issue initial status settable in workflow (#5816)....
r14076 w = workflows.select {|w| w.old_status == old_status && w.new_status == new_status}.size
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649
Jean-Philippe Lang
Makes new issue initial status settable in workflow (#5816)....
r14076 tag_name = "transitions[#{ old_status.try(:id) || 0 }][#{new_status.id}][#{name}]"
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 if w == 0 || w == @roles.size * @trackers.size
Jean-Philippe Lang
Removed duplicate element ids....
r13262 hidden_field_tag(tag_name, "0", :id => nil) +
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 check_box_tag(tag_name, "1", w != 0,
Jean-Philippe Lang
Makes new issue initial status settable in workflow (#5816)....
r14076 :class => "old-status-#{old_status.try(:id) || 0} new-status-#{new_status.id}")
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 else
select_tag tag_name,
Jean-Philippe Lang
Removed hard-coded strings (#16164)....
r12653 options_for_select([
[l(:general_text_Yes), "1"],
[l(:general_text_No), "0"],
[l(:label_no_change_option), "no_change"]
], "no_change")
Jean-Philippe Lang
Bulk edit workflows for multiple trackers/roles (#16164)....
r12649 end
Jean-Philippe Lang
Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521)....
r9794 end
Jean-Philippe Lang
Adds a workflow overview screen....
r1912 end