Skip to content

Commit

Permalink
Resolve link issues associated with shared MenuItems across multiple …
Browse files Browse the repository at this point in the history
…projects
  • Loading branch information
nanego committed Jan 10, 2024
1 parent cde9d6e commit 55ca75a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/views/projects/_overview_templates.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<% @project.issue_templates.displayed_on_overview.includes(:tracker).order('trackers.position desc, issue_templates.template_title desc').each do |template| %>
<% if Issue.allowed_target_trackers(@project).include?(template.tracker) && template.template_projects.include?(@project) %>
<div onclick="document.location.href='<%= new_project_issue_path(project: @project, template_id: template.id) %>'" class="template_card">
<div onclick="document.location.href='<%= new_project_issue_path(project_id: @project, template_id: template.id) %>'" class="template_card">
<div class="template-logo">
<% begin %>
<%= template.template_image.present? ? octicon(template.template_image, :height => 48, :class => "right left", :"aria-label" => "hi") : octicon('repo-template', :height => 48, :class => "right left", :"aria-label" => "hi") %>
Expand Down
11 changes: 6 additions & 5 deletions lib/redmine_templates/menu_manager_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ module RedmineTemplates
module MenuManagerPatch
def render_menu(menu, current_project = nil)

if (current_project.present? &&
if current_project.present? &&
current_project.issue_templates.present? &&
(Issue.allowed_target_trackers(current_project) & current_project.issue_templates.map(&:tracker)).any?)
(Issue.allowed_target_trackers(current_project) & current_project.issue_templates.map(&:tracker)).any?
Redmine::MenuManager.map :project_menu do |project_menu|
current_project.issue_templates.includes(:tracker).reorder('trackers.position asc, issue_templates.template_title asc').each do |template|
unless project_menu.find("new_issue_template_#{template.id}".to_sym)
project_menu.push "new_issue_template_#{template.id}".to_sym,
new_project_issue_path(project: current_project, template_id: template.id),
menu_item_name = "new_issue_template_#{template.id}".to_sym
unless project_menu.find(menu_item_name)
project_menu.push menu_item_name,
{ :controller => 'issues', :action => 'new', :template_id => template.id },
:param => :project_id,
:caption => Proc.new {
template.reload unless template.has_been_deleted?
Expand Down

0 comments on commit 55ca75a

Please sign in to comment.