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
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 ||= @query.hash
@query.name = params[:name].present? ? params[:name] : l(:label_default)
@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.save!
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">
<% 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),
:condition => 'Ajax.activeRequestCount === 0',
:update => "content",
:eval_scripts => true
}, :class => 'reporting_button send_query' %>
:eval_scripts => true } %>
</span>
<% end %>
</div>
<div style="clear:both"></div>

@ -39,17 +39,10 @@
}, :class => 'reporting_button apply' %>
<%= 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 %>
<%= link_to_remote l(:button_save),
{ :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' %>
<%= render :partial => 'save_query' %>
<% end %>
</p>
</div>
<div class='cost_types'>
<b><%= l(:label_report) %>:</b>
<%= 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();

@ -352,3 +352,24 @@ td:hover .drill_down, th:hover .drill_down {
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