Project

General

Profile

Actions

Maintenance #3044

closed

xmera Omnia - Collection #3083: Update to RM 5.1.7

Check queries_controller

Added by liaham 26 days ago. Updated 22 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
03/17/2025
Due date:
03/17/2025
% Done:

100%

Estimated time:
Compatible Redmine Version:
5.1.z

Description

diff --git a/app/controllers/queries_controller.rb b/app/controllers/queries_controller.rb
index db5d785f9..696b0589c 100644
--- a/app/controllers/queries_controller.rb
+++ b/app/controllers/queries_controller.rb
@@ -19,6 +19,8 @@
 
 class QueriesController < ApplicationController
   menu_item :issues
+  layout :query_layout
+
   before_action :find_query, :only => [:edit, :update, :destroy]
   before_action :find_optional_project, :only => [:new, :create]
 
@@ -52,7 +54,6 @@ class QueriesController < ApplicationController
     @query.user = User.current
     @query.project = @project
     @query.build_from_params(params)
-    render :layout => 'admin' if params[:admin_projects]
   end
 
   def create
@@ -63,14 +64,13 @@ class QueriesController < ApplicationController
 
     if @query.save
       flash[:notice] = l(:notice_successful_create)
-      redirect_to_items(:query_id => @query, :admin_projects => params[:admin_projects])
+      redirect_to_items(:query_id => @query)
     else
       render :action => 'new', :layout => !request.xhr?
     end
   end
 
   def edit
-    render :layout => 'admin' if params[:admin_projects]
   end
 
   def update
@@ -78,7 +78,7 @@ class QueriesController < ApplicationController
 
     if @query.save
       flash[:notice] = l(:notice_successful_update)
-      redirect_to_items(:query_id => @query, :admin_projects => params[:admin_projects])
+      redirect_to_items(:query_id => @query)
     else
       render :action => 'edit'
     end
@@ -109,18 +109,20 @@ class QueriesController < ApplicationController
   end
 
   def current_menu_item
-    @query ? @query.queried_class.to_s.underscore.pluralize.to_sym : nil
+    return unless @query
+    return if query_layout == 'admin'
+
+    @query.queried_class.to_s.underscore.pluralize.to_sym
   end
 
   def current_menu(project)
-    super if params[:admin_projects].nil?
+    super unless query_layout == 'admin'
   end
 
   private
 
   def find_query
     @query = Query.find(params[:id])
-    @query.admin_projects = params[:admin_projects] if @query.is_a?(ProjectQuery)
     @project = @query.project
     render_403 unless @query.editable_by?(User.current)
   rescue ActiveRecord::RecordNotFound
@@ -170,17 +172,25 @@ class QueriesController < ApplicationController
   end
 
   def redirect_to_project_query(options)
-    if params[:admin_projects]
-      redirect_to admin_projects_path(options)
-    else
-      redirect_to projects_path(options)
-    end
+    redirect_to projects_path(options)
+  end
+
+  def redirect_to_project_admin_query(options)
+    redirect_to admin_projects_path(options)
   end
 
   def redirect_to_user_query(options)
     redirect_to users_path(options)
   end
 
+  def query_layout
+    @query&.layout || 'base'
+  end
+
+  def menu_items
+    {self.controller_name.to_sym => {:actions => {}, :default => current_menu_item}}
+  end
+
   # Returns the Query subclass, IssueQuery by default
   # for compatibility with previous behaviour
   def query_class
Actions #1

Updated by liaham 22 days ago

  • Due date set to 03/17/2025
  • Status changed from New to Closed
  • Assignee set to liaham
  • Start date set to 03/17/2025
  • % Done changed from 0 to 100
Actions #2

Updated by liaham 22 days ago

  • Parent task set to #3083
Actions

Also available in: Atom PDF