Refactored home/ordergroup.

This commit is contained in:
benni 2011-05-16 11:00:52 +02:00
parent 1cf63fc40b
commit 2ee30fee16
4 changed files with 25 additions and 31 deletions

View file

@ -62,11 +62,10 @@ class HomeController < ApplicationController
:order => sort) :order => sort)
respond_to do |format| respond_to do |format|
format.html # myOrdergroup.haml format.html # myOrdergroup.haml
format.js { render :partial => "finance/transactions/list" } format.js { render :layout => false }
end end
else else
flash[:error] = "Leider bist Du kein Mitglied einer Bestellgruppe" redirect_to root_path, :alert => "Leider bist Du kein Mitglied einer Bestellgruppe"
redirect_to root_path
end end
end end

View file

@ -59,7 +59,7 @@ module ApplicationHelper
def sort_td_class_helper(param) def sort_td_class_helper(param)
result = 'class="sortup"' if params[:sort] == param result = 'class="sortup"' if params[:sort] == param
result = 'class="sortdown"' if params[:sort] == param + "_reverse" result = 'class="sortdown"' if params[:sort] == param + "_reverse"
return result result
end end
def sort_link_helper(text, key, options = {}) def sort_link_helper(text, key, options = {})
@ -67,23 +67,14 @@ module ApplicationHelper
action = options[:action] || "list" action = options[:action] || "list"
remote = options[:remote].nil? ? true : options[:remote] remote = options[:remote].nil? ? true : options[:remote]
key += "_reverse" if params[:sort] == key key += "_reverse" if params[:sort] == key
url = url_for(:sort => key, :page => nil, :per_page => per_page)
link_options = {
:url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})),
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:method => :get
}
html_options = { html_options = {
:title => _("Nach #{text} sortieren"), :title => "Nach #{text} sortieren",
:href => url_for(:action => action, :params => params.merge({:sort => key, :page => nil, :per_page => per_page})) :remote => remote
} }
if remote link_to(text, url, html_options)
link_to_remote(text, link_options, html_options)
else
link_to(text, link_options[:url], html_options)
end
end end
# Generates a link to the top of the website # Generates a link to the top of the website

View file

@ -14,7 +14,7 @@
<li><%= membership.user.nick -%></li> <li><%= membership.user.nick -%></li>
<% end -%> <% end -%>
</ul> </ul>
<%= remote_link_to('Person einladen', :url => new_invite_path(:id => @ordergroup)) %> <%= link_to('Person einladen', new_invite_path(:id => @ordergroup), :remote => true) %>
</div> </div>
</div> </div>
@ -23,18 +23,11 @@
<h2>Kontoauszug</h2> <h2>Kontoauszug</h2>
</div> </div>
<div class="column_content"> <div class="column_content">
<p> <%= form_tag my_ordergroup_url, :method => :get, :style => 'display:inline;', :id => 'transactions_search',
<form name="sform" action="" style="display:inline;"> :remote => true do %>
<label for="financial_transaction_note">Filter für Notizen: </label> <%= label_tag "financial_transaction_note", "Filter für Notizen:" %>
<%= text_field_tag("query", params['query'], :size => 10 ) %> <%= text_field_tag("query", params['query'], :size => 10 ) %>
</form> <% end %>
</p>
<%= observe_field 'query', :frequency => 2,
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:url => {:action => 'ordergroup'},
:with => 'query',
:update => 'transactions' %>
<div id="transactions"> <div id="transactions">
<%= render :partial => "/finance/transactions/list" %> <%= render :partial => "/finance/transactions/list" %>
</div> </div>
@ -42,3 +35,13 @@
</div> </div>
<div id="edit_box" style="display:none"></div> <div id="edit_box" style="display:none"></div>
<% content_for :head do %>
<script type="text/javascript">
$(function() {
$('#query').observe_field(1, function() {
$('#transactions_search').submit();
});
})
</script>
<% end %>

View file

@ -0,0 +1 @@
$('#transactions').html('<%= escape_javascript(render("finance/transactions/list")) %>');