mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 11:37:14 +00:00
Allow query class to select layout for QueriesController (#42352).
Patch by Holger Just (user:hjust). git-svn-id: https://svn.redmine.org/redmine/trunk@23529 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e9ba222e6b
commit
10971361fa
@ -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
|
||||
@ -70,7 +71,6 @@ class QueriesController < ApplicationController
|
||||
end
|
||||
|
||||
def edit
|
||||
render :layout => 'admin' if params[:admin_projects]
|
||||
end
|
||||
|
||||
def update
|
||||
@ -109,11 +109,13 @@ 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
|
||||
@ -182,6 +184,14 @@ class QueriesController < ApplicationController
|
||||
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
|
||||
|
||||
@ -174,4 +174,8 @@ class ProjectQuery < Query
|
||||
|
||||
scope
|
||||
end
|
||||
|
||||
def layout
|
||||
admin_projects ? 'admin' : super
|
||||
end
|
||||
end
|
||||
|
||||
@ -355,6 +355,8 @@ class Query < ApplicationRecord
|
||||
# Permission required to view the queries, set on subclasses.
|
||||
class_attribute :view_permission
|
||||
|
||||
class_attribute :layout, default: 'base'
|
||||
|
||||
# Scope of queries that are global or on the given project
|
||||
scope :global_or_on_project, (lambda do |project|
|
||||
where(:project_id => (project.nil? ? nil : [nil, project.id]))
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
|
||||
class UserQuery < Query
|
||||
self.layout = 'admin'
|
||||
self.queried_class = Principal # must be Principal (not User) for custom field filters to work
|
||||
|
||||
self.available_columns = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user