Commit 0639d1eb authored by azul's avatar azul
Browse files

cleanup: use to_partial_path for pages

Also cleanup the corresponding views a bit.
Maily removing unused options
parent 8af883ca
......@@ -5,18 +5,6 @@
module Common::Page::ListingHelper
protected
#
# this is a workaround for the missing to_partial_path before rails 3.2
#
# In rails 3.2 we'll be able to just set to_partial_path for pages and use
# render pages, locals
def render_pages(pages, locals)
render partial: 'common/pages/page',
collection: pages,
as: :page,
locals: locals
end
def partial_from_style(style)
case style
when Symbol, String
......
......@@ -8,26 +8,6 @@
module Common::Ui::PaginationHelper
protected
# def letter_pagination_labels
# $letter_pagination_labels_list ||= ("A".."Z").to_a + ["#"]
# end
# def letter_pagination_links(url_opts = {}, pagination_opts = {}, &url_proc)
# url_proc = method :url_for if url_proc.nil?
# available_letters = pagination_opts[:available_letters]
# if available_letters and !available_letters.grep(/^[^a-z]/i).empty?
# # we have things that are not letters in the mix
# available_letters << "#"
# end
# render :partial => 'pages/letter_pagination',
# :locals => {:letter_labels => letter_pagination_labels,
# :available_letters => pagination_opts[:available_letters],
# :url_proc => url_proc,
# :url_opts => url_opts,
# }
# end
#
# Default pagination link options:
#
......
......@@ -91,6 +91,10 @@ class Page < ApplicationRecord
# used for caching access
alias to_s friendly_url
def to_partial_path
'common/pages/page'
end
# using only knowledge of this page, returns
# best guess uri string, sans protocol/host/port.
# ie /rainbows/what-a-fine-page+5234
......
......@@ -26,7 +26,7 @@ class Page::History < ApplicationRecord
# all subclasses use the same partial
def to_partial_path
'page_histories/page_history'
'page/history/history'
end
def self.recipients_for_page(page)
......
-# locals:
-#
-# style -- one of table, rows, grid, blog. if not set, we use @path to
-# which one to use.
-# style -- one of table or mini (used for recent pages in me menu)
- style_from_path = case @path.try(:arg_for, 'view'); when 'compact' then 'table'; when 'detailed' then 'rows'; when 'grid' then 'grid'; end
- style = local_assigns[:style] || style_from_path || 'table'
- style = local_assigns[:style] || 'table'
- pages = local_assigns[:pages] ||= @pages.select{|page| page.owner_id and page.owner_name != 'none'}
- paginate = false # pages.respond_to?(:total_entries)
- paginate_options ||= {}
- classes = ['page_list', ('table-responsive' if style == 'table'), (style if style != 'table')]
- classes = ['page_list', (style == 'table' ? 'table-responsive' : style)]
%section{class: classes}
= render "/common/pages/list_as_#{style}", local_assigns
- if paginate
= pagination_links( pages, paginate_options )
- ul_class = local_assigns[:ul_class] || ''
%ul{class: ul_class}
= render_pages pages, style: :mini
%ul
= render pages, style: :mini
= render_pages pages, style: :row
= pagination_links pages
- ##
- ## displays a list of pages in a table (ie, using rows and columns).
- ##
-
- heading = true if heading.nil?
- sortable = false
%table.table.table-striped
- if pages.empty?
%tr
%td= :no_search_results.t
- else
- if heading
= render 'common/pages/table_header'
= render_pages pages, style: :table_row
= render 'common/pages/table_header'
= render pages, style: :table_row
= pagination_links(@pages)
<%= "* #{description_for(page_history)} at #{full_time(page_history.created_at)}" %>
<%= details_for(page_history) if !details_for(page_history).empty? %>
<%= "* #{description_for(history)} at #{full_time(history.created_at)}" %>
<%= details_for(history) if !details_for(history).empty? %>
......@@ -27,6 +27,10 @@ module Crabgrass
# versions of Rails older than 5.2.
config.action_dispatch.use_authenticated_cookie_encryption = false
# we use namespaced controllers but still want to be able to do
# render @pages
config.action_view.prefix_partial_path_with_controller_namespace = false
config.autoload_paths << "#{Rails.root}/lib"
config.autoload_paths << "#{Rails.root}/app/models"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment