Force query selection for dashboards not to use descendants

This commit is contained in:
Alexander Meindl 2020-09-27 10:52:02 +02:00
parent 867b1a4bc1
commit 421d1efa9b
2 changed files with 13 additions and 1 deletions

View File

@ -401,6 +401,18 @@ module DashboardsHelper
title.presence || block_definition[:label]
end
def options_for_query_select(klass, project)
# sidebar_queries cannot be use because descendants classes are included
# this changes on class loading
# queries = klass.visible.global_or_on_project(@project).sorted.to_a
queries = klass.visible
.global_or_on_project(project)
.where(type: klass.to_s)
.sorted.to_a
tag.option + options_from_collection_for_select(queries, :id, :name)
end
private
# Renders a single block content

View File

@ -12,7 +12,7 @@ div id="#{block}-settings" style="#{'display: none;' if hide}"
= block_definition[:label]
'
= select_tag "settings[#{block}][query_id]",
tag.option + options_from_collection_for_select(sidebar_queries(klass, @project), :id, :name),
options_for_query_select(klass, @project),
required: true
p
label