saving allows setting public and name options in a drop-down menu

pull/6827/head
jwollert 14 years ago
parent 01a7d31963
commit 85ca3e8e53
  1. 6
      app/controllers/cost_reports_controller.rb
  2. 14
      app/views/cost_reports/_save_query.rhtml
  3. 7
      app/views/cost_reports/_saved_queries.rhtml
  4. 9
      app/views/cost_reports/index.rhtml
  5. 9
      assets/javascripts/reporting.js
  6. 21
      assets/stylesheets/reporting.css

@ -208,8 +208,10 @@ class CostReportsController < ApplicationController
def save_query def save_query
return unless params[:save_query].to_i == 1 || !User.current.allowed_to?(:save_queries, @project, :global => true) return unless params[:save_query].to_i == 1 || !User.current.allowed_to?(:save_queries, @project, :global => true)
# TODO render some form instead of just guessing values! @query.name = params[:name].present? ? params[:name] : l(:label_default)
@query.name ||= @query.hash @query.is_public = if User.current.allowed_to?(:manage_public_queries, @project) || User.current.admin?
params[:public]
end || false
@query.user_id ||= User.current.id @query.user_id ||= User.current.id
@query.save! @query.save!
end end

@ -0,0 +1,14 @@
<%= link_to_function l(:button_save), "toggleElementSlide('button_form')", :class => 'icon icon-save' %>
<div id='button_form' style='display:none'>
<div>
<p><%= label :name, l(:field_name) %> <%= text_field_tag :name, l(:label_default) %></p>
<p><%= label :public, l(:field_is_public) %> <%= check_box_tag :public %></p>
<p><%= button_to_remote l(:button_save), {
:url => { :action => 'index', :save_query => 1, :set_filter => 1 },
:with => 'Form.serialize("query_form")',
:before => 'selectAllOptions("group_by_rows");selectAllOptions("group_by_columns");',
:eval_scripts => true,
:update => 'content' } %></p>
</div>
</div>

@ -5,12 +5,13 @@
<div class="saved_queries buttons"> <div class="saved_queries buttons">
<% queries.each do |query| %> <% queries.each do |query| %>
<%= link_to_remote "<div><em>#{query.name}</em></div>", <span class='reporting_button'>
<%= link_to_remote "<em>#{query.name}</em>",
{ :url => ({ :set_filter => 1, :action => 'index' }.merge CostQuery.load(query.yamlized).to_params), { :url => ({ :set_filter => 1, :action => 'index' }.merge CostQuery.load(query.yamlized).to_params),
:condition => 'Ajax.activeRequestCount === 0', :condition => 'Ajax.activeRequestCount === 0',
:update => "content", :update => "content",
:eval_scripts => true :eval_scripts => true } %>
}, :class => 'reporting_button send_query' %> </span>
<% end %> <% end %>
</div> </div>
<div style="clear:both"></div> <div style="clear:both"></div>

@ -39,17 +39,10 @@
}, :class => 'reporting_button apply' %> }, :class => 'reporting_button apply' %>
<%= link_to_function l(:button_clear), "disable_all_filters(); disable_all_group_bys();", :class => 'icon icon-reload' %> <%= link_to_function l(:button_clear), "disable_all_filters(); disable_all_group_bys();", :class => 'icon icon-reload' %>
<% if User.current.allowed_to?(:save_queries, @project, :global => true) && @valid %> <% if User.current.allowed_to?(:save_queries, @project, :global => true) && @valid %>
<%= link_to_remote l(:button_save), <%= render :partial => 'save_query' %>
{ :url => { :save_query => 1 },
:before => 'selectAllOptions("group_by_rows");selectAllOptions("group_by_columns");',
:with => "Form.serialize('query_form')",
:update => 'content',
:eval_scripts => true
}, :class => 'icon icon-save' %>
<% end %> <% end %>
</p> </p>
</div> </div>
<div class='cost_types'> <div class='cost_types'>
<b><%= l(:label_report) %>:</b> <b><%= l(:label_report) %>:</b>
<%= delimit( <%= delimit(

@ -363,4 +363,13 @@ function defineElementGetter() {
} }
} }
function toggleElementSlide(id) {
if ($(id).visible()) {
new Effect.SlideUp(id);
} else {
new Effect.SlideDown(id);
}
$(id).toggle();
}
defineElementGetter(); defineElementGetter();

@ -352,3 +352,24 @@ td:hover .drill_down, th:hover .drill_down {
margin: 2px; margin: 2px;
} }
div#button_form {
/* TODO IE Compatibility! */
background-color: white;
border: 1px solid grey;
-moz-border-radius: 3px;
border-radius: 3px;
position: absolute;
left: 100px;
padding: 5px;
margin-top: -10px;
}
div#button_form * input#name {
width: 200px
}
div#button_form * input[type="button"] {
float: right;
} br { clear: right; }

Loading…
Cancel
Save