Commit 8af883ca authored by azul's avatar azul

cleanup: more unused helper functions

parent 6fceeed3
......@@ -163,37 +163,6 @@ module Common::Ui::LayoutHelper
lines.join("\n").html_safe
end
##
## PARTIALS
##
def dialog_page(options = {}, &block)
block_to_partial('common/dialog_page', options, &block)
end
# from http://www.igvita.com/2007/03/15/block-helpers-and-dry-views-in-rails/
# Only need this helper once, it will provide an interface to convert a block into a partial.
# 1. Capture is a Rails helper which will 'capture' the output of a block into a variable
# 2. Merge the 'body' variable into our options hash
# 3. Render the partial with the given options hash. Just like calling the partial directly.
def block_to_partial(partial_name, options = {}, &block)
options[:body] = capture(&block)
concat(render(partial: partial_name, locals: options))
end
##
## MISC. LAYOUT HELPERS
##
#
# takes an array of objects and splits it into two even halves. If the count
# is odd, the first half has one more than the second.
#
def even_split(arry)
cutoff = (arry.count + 1) / 2
[arry[0..cutoff - 1], arry[cutoff..-1]]
end
#
# acts like haml_tag, capture_haml, or haml_concat, depending on how it is called.
#
......
......@@ -15,27 +15,4 @@ module Page::BaseHelper
yield(f)
end
end
def display_page_cover(page, options = {}, html_options = {})
options = { size: :medium, crop: '200x200' }.merge(options)
html_options = { class: 'thumb', alt: 'thumbnail', width: '200' }.merge(html_options)
if page.cover.respond_to?(:thumbnail)
link_to(thumbnail_img_tag(page.cover, options[:size], { crop: options[:crop] }, class: html_options[:class]),
page_url(page))
elsif page.external_cover_url
link_to(image_tag(page.external_cover_url, class: html_options[:class], width: html_options[:size], alt: html_options[:alt]), page_url(page))
end
end
def recipient_checkbox_line(recipient, options = {})
name = CGI.escape(recipient.name) # so that '+' does show up as ' '
ret = '<label>'
ret << check_box_tag("recipients[#{name}][send_notice]", 1, false, class: options[:class])
ret << display_entity(recipient, avatar: :xsmall, format: :hover)
ret << '</label>'
end
def this_page_class
@page ? @page.class_display_name.capitalize : @page_class.class_display_name.capitalize
end
end
module TaskListPageHelper
##
## show tasks
##
def list_for_task(list, options)
case options[:status]
when 'pending'
tasks = list.tasks.select { |t| t.completed == false }
when 'completed'
tasks = list.tasks.select { |t| t.completed == true }
else
list.tasks
end
tasks.any? ? tasks.sort_by { |t| [(t.completed? ? 1 : 0), t.position] } : []
end
def options_for_task_list
options = {}
options[:user] = @user ? @user : nil
options[:all_users] = @user ? false : true
options[:status] = @show_status ? @show_status : 'pending'
options[:all_states] = @show_status == 'both'
options[:completed] = @show_status == 'completed'
options
end
##
## show task
##
# creates a checkbox tag for a task
def task_checkbox(task)
disabled = !current_user.may?(:edit, task.page)
if true
content_tag(:label, class: 'checkbox-inline') do
content_tag(:input, '', type: 'checkbox', disabled: 'disabled') +
h(task.name)
end
else
next_state = task.completed? ? 'pending' : 'complete'
name = "#{task.id}_task"
spinbox_tag name, task_url(task, page_id: task.page),
checked: task.completed?,
tag: :span,
method: :put,
with: "'task[state]=#{next_state}'"
end
end
# creates a link that expands to display the task details.
# options must include :show or :toggle
def task_link_to_details(task, *options)
......@@ -83,11 +34,6 @@ module TaskListPageHelper
end.join(', ').html_safe
end
# a button to hide the task detail
def close_task_details_button(task)
button_to_function :hide.t, hide(task, 'details')
end
# a button to delete the task
def delete_task_details_button(task)
function = remote_function(
......
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