Feature #465 » 33-add_versions_inheritance-0.4.0.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
menu_item :new_issue, :only => :new
|
||
|
|
||
|
before_filter :find_issue, :only => [:show, :edit, :reply]
|
||
|
before_filter :check_issue_perms, :only => [:show, :edit]
|
||
|
before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
|
||
|
before_filter :find_project, :only => [:new, :update_form, :preview]
|
||
|
before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :update_form, :context_menu]
|
||
| ... | ... | |
|
:conditions => @query.statement,
|
||
|
:limit => limit,
|
||
|
:offset => @issue_pages.current.offset
|
||
|
@issues.map!{ |issue| issue_without_hidden_fields(issue) } # don't show forbidden fields
|
||
|
respond_to do |format|
|
||
|
format.html {
|
||
|
if @query.grouped?
|
||
| ... | ... | |
|
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
|
||
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||
|
@issue = issue_without_hidden_fields(@issue)
|
||
|
@journals = journals_without_hidden_entries(@journals)
|
||
|
@priorities = IssuePriority.all
|
||
|
@time_entry = TimeEntry.new
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
events += Version.find(:all, :include => :project,
|
||
|
:conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
|
||
|
|
||
|
events += @project.related_versions.select { |v| ((v.project.id != @project.id) && (@gantt.date_from..@gantt.date_to).include?(v.effective_date)) }
|
||
|
@gantt.events = events
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
)
|
||
|
events += Version.find(:all, :include => :project,
|
||
|
:conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
|
||
|
|
||
|
events += @project.related_versions.select { |v| ((v.project.id != @project.id) && (@calendar.startdt..@calendar.enddt).include?(v.effective_date)) }
|
||
|
|
||
|
@calendar.events = events
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
render_404
|
||
|
end
|
||
|
|
||
|
def issue_fixed_version_allowed?(issue)
|
||
|
((not issue.fixed_version) ||
|
||
|
(User.current.allowed_to?(:view_issues,
|
||
|
issue.fixed_version.project)))
|
||
|
end
|
||
|
def check_issue_perms
|
||
|
@forbidden_fixed_version = (not issue_fixed_version_allowed?(@issue))
|
||
|
end
|
||
|
## Filter journals to remove non allowed entries. We want here
|
||
|
## to handle the _specific case_ of a user 'Joe' browsing 'Project
|
||
|
## B' issues. 'Project B' is a subproject of 'Project A' and
|
||
|
## inherits its versions. Joe can't see 'Project A, but issue
|
||
|
## fixed_versions has been set at some point to a version belonging
|
||
|
## to 'Project A', by an other member of 'Project B'. Joe should not
|
||
|
## see this sensitive information.
|
||
|
def journals_without_hidden_entries(journals)
|
||
|
p = @project
|
||
|
forbidden_parents = []
|
||
|
while p = p.parent do
|
||
|
forbidden_parents.push p.id unless User.current.allowed_to?(:view_issues, p)
|
||
|
end
|
||
|
unless (journals.empty? || forbidden_parents.empty?)
|
||
|
journals = journals.dup
|
||
|
journals.delete_if do |j|
|
||
|
j.details.map{ |d| (d.property == 'attr' &&
|
||
|
d.prop_key == 'fixed_version_id' &&
|
||
|
(
|
||
|
(d.old_value && forbidden_parents.include?(Version.find(d.old_value.to_i).project_id)) ||
|
||
|
(d.value && forbidden_parents.include?(Version.find(d.value.to_i).project_id))
|
||
|
)
|
||
|
) }.include?(true)
|
||
|
end
|
||
|
end
|
||
|
journals
|
||
|
end
|
||
|
## Filter issue to remove non allowed fields. For more information,
|
||
|
## see documentation of journals_without_hidden_entries
|
||
|
def issue_without_hidden_fields(issue)
|
||
|
unless issue_fixed_version_allowed?(issue)
|
||
|
issue = issue.dup
|
||
|
issue.fixed_version = nil
|
||
|
end
|
||
|
issue
|
||
|
end
|
||
|
|
||
|
# Retrieve query from session or build a new query
|
||
|
def retrieve_query
|
||
|
if !params[:query_id].blank?
|
||
| app/controllers/projects_controller.rb | ||
|---|---|---|
|
def add_file
|
||
|
if request.post?
|
||
|
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
||
|
container = (params[:version_id].blank? ? @project : @project.related_versions.find { |v| v.id.to_s == params[:version_id] })
|
||
|
attachments = attach_files(container, params[:attachments])
|
||
|
if !attachments.empty? && Setting.notified_events.include?('file_added')
|
||
|
Mailer.deliver_attachments_added(attachments)
|
||
| ... | ... | |
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
||
|
return
|
||
|
end
|
||
|
@versions = @project.versions.sort
|
||
|
@versions = @project.related_versions.sort
|
||
|
end
|
||
|
|
||
|
def list_files
|
||
| ... | ... | |
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||
|
|
||
|
@containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
|
||
|
@containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
|
||
|
@containers += Version.find(:all, :include => :attachments, :order => sort_clause, :conditions => ['versions.id IN (?)', @project.related_versions.map {|v| v.id}]).sort.reverse
|
||
|
render :layout => !request.xhr?
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
def changelog
|
||
|
@trackers = @project.trackers.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
|
||
|
retrieve_selected_tracker_ids(@trackers)
|
||
|
@versions = @project.versions.sort
|
||
|
@versions = @project.related_versions.sort
|
||
|
end
|
||
|
def roadmap
|
||
|
@trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true])
|
||
|
retrieve_selected_tracker_ids(@trackers)
|
||
|
@versions = @project.versions.sort
|
||
|
@versions = @versions.select {|v| !v.completed? } unless params[:completed]
|
||
|
@versions = retrieve_related_versions
|
||
|
end
|
||
|
|
||
|
def activity
|
||
| ... | ... | |
|
render_404
|
||
|
end
|
||
|
def retrieve_related_versions
|
||
|
related_versions=@project.related_versions
|
||
|
# should this test be moved to projects_helper.rb : version_visible_issues ?
|
||
|
params[:completed] ? related_versions : related_versions.select {|v| !v.completed? }
|
||
|
end
|
||
|
def retrieve_selected_tracker_ids(selectable_trackers)
|
||
|
if ids = params[:tracker_ids]
|
||
|
@selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
|
||
| app/controllers/reports_controller.rb | ||
|---|---|---|
|
render :template => "reports/issue_report_details"
|
||
|
when "version"
|
||
|
@field = "fixed_version_id"
|
||
|
@rows = @project.versions.sort
|
||
|
@rows = @project.related_versions.sort
|
||
|
@data = issues_by_version
|
||
|
@report_title = l(:field_version)
|
||
|
render :template => "reports/issue_report_details"
|
||
| ... | ... | |
|
render :template => "reports/issue_report_details"
|
||
|
else
|
||
|
@trackers = @project.trackers
|
||
|
@versions = @project.versions.sort
|
||
|
@versions = @project.related_versions.sort
|
||
|
@priorities = IssuePriority.all
|
||
|
@categories = @project.issue_categories
|
||
|
@assignees = @project.members.collect { |m| m.user }
|
||
| app/controllers/versions_controller.rb | ||
|---|---|---|
|
menu_item :roadmap
|
||
|
before_filter :find_project, :authorize
|
||
|
helper :projects
|
||
|
include ProjectsHelper
|
||
|
def show
|
||
|
@issues = version_visible_issues(@version,@project,@project.trackers.collect { |x| x.id.to_s })
|
||
|
end
|
||
|
|
||
|
def edit
|
||
| app/helpers/projects_helper.rb | ||
|---|---|---|
|
]
|
||
|
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
||
|
end
|
||
|
## return an array of the issues attached to version that a user should see
|
||
|
## As a convenience, allow limitation by trackers with Array of tracker_ids
|
||
|
def version_visible_issues(version,project,tracker_ids=[],user=User.current)
|
||
|
# Returns void when user can not see issues or if tracker_ids is void
|
||
|
return [] if ((not user.allowed_to?(:view_issues,
|
||
|
version.project)) or
|
||
|
tracker_ids.empty?)
|
||
|
# user can see project issues, carry on, retrieve them ...
|
||
|
issues = version.
|
||
|
fixed_issues.find(:all,
|
||
|
:include => [:status, :tracker],
|
||
|
:conditions => ["tracker_id in (#{tracker_ids.join(',')})"],
|
||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id")
|
||
|
# Only keep issues from self, parent or children,
|
||
|
related_projects = project.self_and_descendants.map { |t_item| t_item.id }
|
||
|
# do we need parents at all?
|
||
|
p = project
|
||
|
while p = p.parent do
|
||
|
related_projects.push p.id
|
||
|
end
|
||
|
related_projects = related_projects.select{|x| user.allowed_to?(:view_issues, Project.find(x))}
|
||
|
|
||
|
# now only keep related issues. (issues from brother projects are discarded)
|
||
|
issues.select {|x| related_projects.include?(x.project.id) }
|
||
|
end
|
||
|
def grouped_versions_for_select(versions_list)
|
||
|
return [] if versions_list == nil
|
||
|
grouped_structure = []
|
||
|
versions_list.each do |prj, ver|
|
||
|
grouped_structure.push [prj.name, ver.collect { |v| [v.name, v.id] }]
|
||
|
end
|
||
|
grouped_structure
|
||
|
end
|
||
|
|
||
|
def parent_project_select_tag(project)
|
||
|
options = '<option></option>' + project_tree_options_for_select(project.possible_parents, :selected => project.parent)
|
||
| app/models/project.rb | ||
|---|---|---|
|
members.select {|m| m.mail_notification? || m.user.mail_notification?}.collect {|m| m.user.mail}
|
||
|
end
|
||
|
|
||
|
## Return versions attached to self, and to parents if relevant.
|
||
|
## Sorting is done in the SQL request to take advantage of cache
|
||
|
def related_versions(user=User.current)
|
||
|
p = self
|
||
|
parent_ids = [self.id]
|
||
|
while p = p.parent do
|
||
|
parent_ids.push p.id if user.allowed_to?(:view_issues, p)
|
||
|
end
|
||
|
Version.find(:all,
|
||
|
:conditions => {:project_id => parent_ids},
|
||
|
:order => "effective_date ASC, name ASC ")
|
||
|
end
|
||
|
|
||
|
def grouped_versions(version_list=nil, user=User.current)
|
||
|
version_list ||= related_versions(user)
|
||
|
p, i = self, 0
|
||
|
parent_nesting = {}
|
||
|
parent_nesting[p.id] = i
|
||
|
while p = p.parent do
|
||
|
i += 1
|
||
|
parent_nesting[p.id] = i
|
||
|
end
|
||
|
version_list.group_by(&:project).sort_by { |item| parent_nesting[item.first.id] }
|
||
|
end
|
||
|
# Returns an array of all custom fields enabled for project issues
|
||
|
# (explictly associated custom fields and custom fields enabled for all projects)
|
||
|
def all_issue_custom_fields
|
||
| app/models/query.rb | ||
|---|---|---|
|
@@operators_by_filter_type = { :list => [ "=", "!" ],
|
||
|
:list_status => [ "o", "=", "!", "c", "*" ],
|
||
|
:list_optional => [ "=", "!", "!*", "*" ],
|
||
|
:list_grouped => [ "=", "!", "!*", "*" ],
|
||
|
:list_subprojects => [ "*", "!*", "=" ],
|
||
|
:date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
|
||
|
:date_past => [ ">t-", "<t-", "t-", "t", "w" ],
|
||
| ... | ... | |
|
]
|
||
|
cattr_reader :available_columns
|
||
|
|
||
|
include ProjectsHelper
|
||
|
def initialize(attributes = nil)
|
||
|
super attributes
|
||
|
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
|
||
| ... | ... | |
|
unless @project.issue_categories.empty?
|
||
|
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
||
|
end
|
||
|
unless @project.versions.empty?
|
||
|
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
||
|
unless @project.related_versions.empty?
|
||
|
@available_filters["fixed_version_id"] = { :type => :list_grouped,
|
||
|
:order => 7,
|
||
|
:values => grouped_versions_for_select(@project.grouped_versions) }
|
||
|
end
|
||
|
unless @project.descendants.active.empty?
|
||
|
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.descendants.visible.collect{|s| [s.name, s.id.to_s] } }
|
||
| app/views/issues/_form.rhtml | ||
|---|---|---|
|
{:controller => 'projects', :action => 'add_issue_category', :id => @project},
|
||
|
:class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
|
||
|
<% end %>
|
||
|
<%= content_tag('p', f.select(:fixed_version_id,
|
||
|
(@project.versions.sort.collect {|v| [v.name, v.id]}),
|
||
|
{ :include_blank => true })) unless @project.versions.empty? %>
|
||
|
<% unless (@project.related_versions.empty? || @forbidden_fixed_version) then %>
|
||
|
<%= content_tag('p', f.select_ex(:fixed_version_id,
|
||
|
grouped_versions_for_select(@project.grouped_versions),
|
||
|
{ :include_blank => true})) %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<div class="splitcontentright">
|
||
| app/views/issues/_form_update.rhtml | ||
|---|---|---|
|
</div>
|
||
|
<div class="splitcontentright">
|
||
|
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
|
||
|
<%= content_tag('p', f.select(:fixed_version_id,
|
||
|
(@project.versions.sort.collect {|v| [v.name, v.id]}),
|
||
|
{ :include_blank => true })) unless @project.versions.empty? %>
|
||
|
<%= unless (@issue.fixed_version &&
|
||
|
(not User.current.allowed_to?(:view_issues,
|
||
|
@issue.fixed_version.project)) ||
|
||
|
@project.related_versions.empty?) then
|
||
|
content_tag('p', f.select_ex(:fixed_version_id,
|
||
|
grouped_versions_for_select(@project.grouped_versions),
|
||
|
{ :include_blank => true }))
|
||
|
end %>
|
||
|
</div>
|
||
|
</div>
|
||
| app/views/issues/bulk_edit.rhtml | ||
|---|---|---|
|
<label><%= l(:field_fixed_version) %>:
|
||
|
<%= select_tag('fixed_version_id', content_tag('option', l(:label_no_change_option), :value => '') +
|
||
|
content_tag('option', l(:label_none), :value => 'none') +
|
||
|
options_from_collection_for_select(@project.versions.sort, :id, :name)) %></label>
|
||
|
grouped_options_for_select(grouped_versions_for_select(@project.grouped_versions))) %></label>
|
||
|
</p>
|
||
|
<p>
|
||
| app/views/issues/context_menu.rhtml | ||
|---|---|---|
|
<% end -%>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<% unless @project.nil? || @project.versions.empty? -%>
|
||
|
<% unless @project.nil? || @project.related_versions.empty? -%>
|
||
|
<li class="folder">
|
||
|
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
|
||
|
<ul>
|
||
|
<% @project.versions.sort.each do |v| -%>
|
||
|
<li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post,
|
||
|
:selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
|
||
|
<% end -%>
|
||
|
<% @project.grouped_versions.each do |p, vv| -%>
|
||
|
<li class="<%= "folder" unless @project.id == p.id %>">
|
||
|
<% unless @project.id == p.id %>
|
||
|
<a href="#" class="submenu"><%= p.name %></a>
|
||
|
<ul>
|
||
|
<% end %>
|
||
|
<% vv.each do |v| %>
|
||
|
<li><%= context_menu_link v.name, {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => v, :back_to => @back}, :method => :post, :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:update] %></li>
|
||
|
<% end %>
|
||
|
<% unless @project.id == p.id %>
|
||
|
</ul>
|
||
|
<% end %>
|
||
|
</li>
|
||
|
<% end -%>
|
||
|
<li><%= context_menu_link l(:label_none), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), 'fixed_version_id' => 'none', :back_to => @back}, :method => :post,
|
||
|
:selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:update] %></li>
|
||
|
</ul>
|
||
| app/views/projects/add_file.rhtml | ||
|---|---|---|
|
<% if @versions.any? %>
|
||
|
<p><label for="version_id"><%=l(:field_version)%></label>
|
||
|
<%= select_tag "version_id", content_tag('option', '') +
|
||
|
options_from_collection_for_select(@versions, "id", "name") %></p>
|
||
|
grouped_options_for_select(grouped_versions_for_select(@project.grouped_versions)) %></p>
|
||
|
<% end %>
|
||
|
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||
| app/views/projects/roadmap.rhtml | ||
|---|---|---|
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||
|
<% else %>
|
||
|
<div id="roadmap">
|
||
|
<% @versions.each do |version| %>
|
||
|
<% grouped_versions = @project.grouped_versions(@versions) %>
|
||
|
<% grouped_versions.each do |projects, versions_in_project| %>
|
||
|
<% unless @project.id == projects.id %>
|
||
|
<fieldset>
|
||
|
<legend><h3><%= l(:label_project) %>: <%= link_to h(projects.name), :controller => 'projects', :action => 'show', :id => projects, :jump => 'roadmap' %></h3></legend>
|
||
|
<% end %>
|
||
|
<% versions_in_project.each do |version| %>
|
||
|
<% issues = version_visible_issues(version,@project,@selected_tracker_ids) %>
|
||
|
<%= tag 'a', :name => version.name %>
|
||
|
<h3 class="icon22 icon22-package"><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></h3>
|
||
|
<%= render :partial => 'versions/overview', :locals => {:version => version} %>
|
||
|
<%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
|
||
|
<% issues = version.fixed_issues.find(:all,
|
||
|
:include => [:status, :tracker],
|
||
|
:conditions => ["tracker_id in (#{@selected_tracker_ids.join(',')})"],
|
||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") unless @selected_tracker_ids.empty?
|
||
|
issues ||= []
|
||
|
%>
|
||
|
<% if issues.size > 0 %>
|
||
|
<fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
|
||
|
<ul>
|
||
|
<%- issues.each do |issue| -%>
|
||
|
<li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
|
||
|
<li><%= link_to_issue(issue) %>: <%=h issue.subject %> <%= (" <em>(<b>" + l(:label_project) + "</b>: " + issue.project.name + ")</em>") unless issue.project.id == @project.id %></li>
|
||
|
<%- end -%>
|
||
|
</ul>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
|
<%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
|
||
|
<% end %>
|
||
|
<% unless @project.id == projects.id %>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<% end %>
|
||
| app/views/queries/_filters.rhtml | ||
|---|---|---|
|
<td>
|
||
|
<div id="div_values_<%= field %>" style="display:none;">
|
||
|
<% case options[:type]
|
||
|
when :list, :list_optional, :list_status, :list_subprojects %>
|
||
|
when :list, :list_optional, :list_grouped, :list_status, :list_subprojects %>
|
||
|
<select <%= "multiple=true" if query.values_for(field) and query.values_for(field).length > 1 %> name="values[<%= field %>][]" id="values_<%= field %>" class="select-small" style="vertical-align: top;">
|
||
|
<% if options[:type] == :list_grouped %>
|
||
|
<%= grouped_options_for_select options[:values], query.values_for(field) %>
|
||
|
<% else %>
|
||
|
<%= options_for_select options[:values], query.values_for(field) %>
|
||
|
<% end %>
|
||
|
</select>
|
||
|
<%= link_to_function image_tag('bullet_toggle_plus.png'), "toggle_multi_select('#{field}');", :style => "vertical-align: bottom;" %>
|
||
|
<% when :date, :date_past %>
|
||
| app/views/versions/show.rhtml | ||
|---|---|---|
|
<%= render :partial => 'versions/overview', :locals => {:version => @version} %>
|
||
|
<%= render(:partial => "wiki/content", :locals => {:content => @version.wiki_page.content}) if @version.wiki_page %>
|
||
|
<% issues = @version.fixed_issues.find(:all,
|
||
|
:include => [:status, :tracker],
|
||
|
:order => "#{Tracker.table_name}.position, #{Issue.table_name}.id") %>
|
||
|
<% if issues.size > 0 %>
|
||
|
<% if @issues.size > 0 %>
|
||
|
<fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
|
||
|
<ul>
|
||
|
<% issues.each do |issue| -%>
|
||
|
<li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
|
||
|
<% @issues.each do |issue| -%>
|
||
|
<li><%= link_to_issue(issue) %>: <%=h issue.subject %> <%= (" <em>(" + issue.project.name + ")</em>") unless issue.project.id == @project.id %></li>
|
||
|
<% end -%>
|
||
|
</ul>
|
||
|
</fieldset>
|
||
| lib/redmine.rb | ||
|---|---|---|
|
menu.push :overview, { :controller => 'projects', :action => 'show' }
|
||
|
menu.push :activity, { :controller => 'projects', :action => 'activity' }
|
||
|
menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' },
|
||
|
:if => Proc.new { |p| p.versions.any? }
|
||
|
:if => Proc.new { |p| p.related_versions.any? }
|
||
|
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
|
||
|
menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
|
||
|
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
|
||
| lib/redmine/core_ext/form_builder.rb | ||
|---|---|---|
|
require 'action_view/helpers/form_helper'
|
||
|
module ActionView::Helpers
|
||
|
module FormOptionsHelper
|
||
|
def select_ex(object, method, choices, options = {}, html_options = {})
|
||
|
InstanceTag.new(object, method, self, options.delete(:object)).to_select_tag_ex(choices, options, html_options)
|
||
|
end
|
||
|
def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil)
|
||
|
body = ''
|
||
|
body << content_tag(:option, prompt, :value => "") if prompt
|
||
|
grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
|
||
|
grouped_options.each do |group|
|
||
|
body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
|
||
|
end
|
||
|
body
|
||
|
end
|
||
|
end
|
||
|
class InstanceTag
|
||
|
def to_select_tag_ex(choices, options, html_options)
|
||
|
html_options = html_options.stringify_keys
|
||
|
add_default_name_and_id(html_options)
|
||
|
value = value(object)
|
||
|
selected_value = options.has_key?(:selected) ? options[:selected] : value
|
||
|
content_tag(
|
||
|
"select",
|
||
|
add_options(
|
||
|
grouped_options_for_select(choices, selected_value),
|
||
|
options,
|
||
|
selected_value
|
||
|
),
|
||
|
html_options
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
class FormBuilder
|
||
|
def select_ex(method, choices, options = {}, html_options = {})
|
||
|
@template.select_ex(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options))
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| lib/redmine/export/pdf.rb | ||
|---|---|---|
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.Cell(190,5, l(:label_history), "B")
|
||
|
pdf.Ln
|
||
|
for journal in issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
||
|
for journal in @journals
|
||
|
pdf.SetFontStyle('B',8)
|
||
|
pdf.Cell(190,5, format_time(journal.created_on) + " - " + journal.user.name)
|
||
|
pdf.Ln
|
||
| lib/tabular_form_builder.rb | ||
|---|---|---|
|
def select(field, choices, options = {}, html_options = {})
|
||
|
label_for_field(field, options) + super
|
||
|
end
|
||
|
def select_ex(field, choices, options = {}, html_options = {})
|
||
|
label_for_field(field, options) + super
|
||
|
end
|
||
|
|
||
|
# Returns a label tag for the given field
|
||
|
def label_for_field(field, options = {})
|
||