module Admin::DocumentsHelper # returns options Array for 'sort_by' select def sort_by_options options = { 'Date DESC' => 'published_at DESC', 'Date ASC' => 'published_at ASC', 'Title' => 'title', 'Manually' => 'position ASC' } result = [] options.each do |k,v| k = k + ' (Default)' if v == Settings.documents._sort_by result << [k,v] end result.sort end # Returns options Array for 'per_page' select def per_page_options options = [1, 5, 10, 20, 50, 100] result = [] options.each do | o | k = o.to_s v = o k = k + ' (Default)' if o == Settings.documents.per_page result << [k, v] end result end # Find the correct form partial for @document def form_partial root = 'admin/documents' choices = ["_#{@document.meta_definition.label_path.gsub('/', '_')}_form.html.erb", "_#{@document.label}_form.html.erb"] self.view_paths.each do | view_path | choices.each do | choice | target = File.join(view_path, root, choice) logger.debug 'FORM: ' + target if File.exists? target return File.join(root, choice).gsub('/_', '/') end end end "admin/documents/form" end def admin_bread_crumb(document, root = true) result = '' if root result << '