Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix pagination's use of per_page.

Added search feature to test the new search functionality of Refinery Settings (thanks Matt!) and used crudify more now that it works properly.
  • Loading branch information...
commit 805e902b626da2b9f87486f12ecd978d1c507c75 1 parent b37d039
@parndt parndt authored
View
1  vendor/refinerycms/core/features/search.feature
@@ -20,6 +20,7 @@ Feature: Search
|page |testitem|pages |
|inquiry |testitem|inquiries |
|inquiry |testitem|spam inquiries|
+ |refinery setting|Test Item|refinery settings|
# This will only run when resources engine is installed.
@search-file
View
9 vendor/refinerycms/core/lib/refinery/crud.rb
@@ -149,7 +149,14 @@ def paginate_all_#{plural_name}
# If we have already found a set then we don't need to again
find_all_#{plural_name} if @#{plural_name}.nil?
- @#{plural_name} = @#{plural_name}.paginate(:page => params[:page])
+ paging_options = {:page => params[:page]}
+
+ # Seems will_paginate doesn't always use the implicit method.
+ if #{class_name}.methods.map(&:to_sym).include?(:per_page)
+ paging_options.update({:per_page => #{class_name}.per_page})
+ end
+
+ @#{plural_name} = @#{plural_name}.paginate(paging_options)
end
# Returns a weighted set of results based on the query specified by the user.
View
4 vendor/refinerycms/core/public/stylesheets/refinery/refinery.css
@@ -543,12 +543,12 @@ header p {
font-style: normal;
padding: 0px 6px;
}
-.pagination a, #content .pagination a, .pagination .current, .disabled {
+.pagination a, #content .pagination a, .pagination .current, .disabled, .pagination em {
padding: 7px;
line-height: 20px;
border-bottom: 0px none;
}
-.pagination .current, .pagination a:hover {
+.pagination .current, .pagination a:hover, .pagination em {
background: #A8B9C1;
}
#dialog-form-actions .pagination {
View
23 vendor/refinerycms/settings/app/controllers/admin/refinery_settings_controller.rb
@@ -3,24 +3,20 @@ class Admin::RefinerySettingsController < Admin::BaseController
crudify :refinery_setting,
:title_attribute => :title,
:order => "name ASC",
- :searchable => false,
+ :searchable => true,
+ :paging => true,
:redirect_to_url => :redirect_to_where?
before_filter :sanitise_params, :only => [:create, :update]
after_filter :fire_setting_callback, :only => [:update]
- def index
- search_all_refinery_settings if searching?
-
- paginate_all_refinery_settings
- end
-
def edit
@refinery_setting = RefinerySetting.find(params[:id])
render :layout => false if request.xhr?
end
+protected
def find_all_refinery_settings
@refinery_settings = RefinerySetting.order('name ASC')
@@ -35,17 +31,8 @@ def search_all_refinery_settings
# search for settings that begin with keyword
term = "^" + params[:search].to_s.downcase.gsub(' ', '_')
- # First find normal results.
- find_all_refinery_settings
-
- # Now get weighted results by running the query against the results already found.
- @refinery_settings = @refinery_settings.with_query(term)
- end
-
- def paginate_all_refinery_settings
- find_all_refinery_settings if @refinery_settings.nil?
-
- @refinery_settings = @refinery_settings.paginate(:page => params[:page], :per_page => RefinerySetting.per_page)
+ # First find normal results, then weight them with the query.
+ @refinery_settings = find_all_refinery_settings.with_query(term)
end
private
View
51 vendor/refinerycms/settings/app/views/admin/refinery_settings/index.html.erb
@@ -1,3 +1,32 @@
+<div id='records'>
+ <% if searching? %>
+ <h2>
+ <%= t('shared.admin.search.results_for',
+ :query => params[:search]) %>
+ </h2>
+ <% end %>
+ <% if @refinery_settings.any? %>
+ <%= will_paginate @refinery_settings, :previous_label => '&laquo;',
+ :next_label => '&raquo;' %>
+ <ul>
+ <%= render :partial => 'refinery_setting',
+ :collection => @refinery_settings %>
+ </ul>
+ <%= will_paginate @refinery_settings, :previous_label => '&laquo;',
+ :next_label => '&raquo;' %>
+ <% else %>
+ <p>
+ <% if searching? %>
+ <%= t('shared.admin.search.no_results') %>
+ <% else %>
+ <strong>
+ <%= t('.empty_set') %>
+ <%= t('.create_first', :link => t('.new')) %>
+ </strong>
+ <% end %>
+ </p>
+ <% end %>
+</div>
<div id='actions'>
<ul>
<li>
@@ -7,26 +36,14 @@
} %>
</li>
<li>
- <%= link_to t('.new'), new_admin_refinery_setting_url(:dialog => true, :width => 725, :height => 475), :class => "add_icon" %>
+ <%= link_to t('.new'), new_admin_refinery_setting_url({
+ :dialog => true,
+ :width => 725,
+ :height => 475
+ }), :class => "add_icon" %>
</li>
</ul>
</div>
-<div id='records'>
- <% if @refinery_settings.any? %>
- <%= will_paginate @refinery_settings, :previous_label => '&laquo;', :next_label => '&raquo;' %>
- <ul>
- <%= render :partial => 'refinery_setting', :collection => @refinery_settings %>
- </ul>
- <%= will_paginate @refinery_settings, :previous_label => '&laquo;', :next_label => '&raquo;' %>
- <% else %>
- <p>
- <strong>
- <%= t('.empty_set') %>
- <%= t('.create_first', :link => t('.new')) %>
- </strong>
- </p>
- <% end %>
-</div>
<% content_for :head do %>
<script type='text/javascript'>
$(document).ready(function() {
View
9 vendor/refinerycms/settings/features/step_definitions/setting_steps.rb
@@ -0,0 +1,9 @@
+Given /^I have no (refinery )?settings$/ do
+ RefinerySetting.delete_all
+end
+
+Given /^I (only )?have a (refinery )?setting titled "([^"]*)"$/ do |only, refinery, title|
+ RefinerySetting.delete_all if only
+
+ RefinerySetting.set(title.to_s.gsub(' ', '').underscore.to_sym, nil)
+end
View
14 vendor/refinerycms/settings/features/support/paths.rb
@@ -0,0 +1,14 @@
+module NavigationHelpers
+ module Refinery
+ module Settings
+ def path_to(page_name)
+ case page_name
+ when /the list of (refinery )?settings/
+ admin_refinery_settings_path
+ else
+ nil
+ end
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.