Forráskód Böngészése

Hide unnamed queries

Andrew Kane 8 éve
szülő
commit
7606d639be

+ 2 - 0
app/models/blazer/query.rb

@@ -8,6 +8,8 @@ module Blazer
 
     validates :statement, presence: true
 
+    scope :named, -> { where("name <> ''") }
+
     def to_param
       [id, name].compact.join("-").gsub("'", "").parameterize
     end

+ 1 - 1
app/views/blazer/checks/_form.html.erb

@@ -10,7 +10,7 @@
   <div class="form-group">
     <%= f.label :query_id, "Query" %>
     <div class="hide">
-      <%= f.select :query_id, Blazer::Query.order(:name).map { |q| [q.name, q.id] }, {include_blank: true} %>
+      <%= f.select :query_id, Blazer::Query.named.order(:name).map { |q| [q.name, q.id] }, {include_blank: true} %>
     </div>
     <script>
       $("#check_query_id").selectize().parents(".hide").removeClass("hide");

+ 1 - 1
app/views/blazer/dashboards/_form.html.erb

@@ -38,7 +38,7 @@ li:hover .glyphicon-remove {
   <div class="form-group">
     <%= f.label :query_id, "Add Chart" %>
     <div class="hide">
-      <%= select_tag :query_id, options_for_select(Blazer::Query.order(:name).map { |q| [q.name, q.id] }), {include_blank: true, placeholder: "Select chart"} %>
+      <%= select_tag :query_id, options_for_select(Blazer::Query.named.order(:name).map { |q| [q.name, q.id] }), {include_blank: true, placeholder: "Select chart"} %>
     </div>
     <script>
       $("#query_id").selectize().parents(".hide").removeClass("hide");