mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-23 07:34:08 +01:00
Code style fixes
This commit is contained in:
parent
c6bbc67dab
commit
d8acf60049
72 changed files with 458 additions and 594 deletions
|
|
@ -10,7 +10,7 @@ module ApplicationHelper
|
|||
link_to(
|
||||
t("layouts.navigation.group_view_by_#{menu_name}"),
|
||||
'#',
|
||||
{:id => "group_view_by_link", :accesskey => "g", :title => t('layouts.navigation.group_view_by_title'), :x_current_group_by => @group_view_by} )
|
||||
{ :id => "group_view_by_link", :accesskey => "g", :title => t('layouts.navigation.group_view_by_title'), :x_current_group_by => @group_view_by } )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ module ApplicationHelper
|
|||
link_to(
|
||||
image_tag("blank.png", :alt => t('common.collapse_expand')),
|
||||
"#",
|
||||
{:class => "container_toggle", :id => id} )
|
||||
{ :class => "container_toggle", :id => id })
|
||||
end
|
||||
|
||||
# Check due date in comparison to today's date Flag up date appropriately with
|
||||
|
|
@ -54,28 +54,28 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def link_to_context(context, descriptor = sanitize(context.name))
|
||||
link_to( descriptor, context, :title => "View context: #{context.name}" )
|
||||
link_to(descriptor, context, :title => "View context: #{context.name}")
|
||||
end
|
||||
|
||||
def link_to_project(project, descriptor = sanitize(project.name))
|
||||
link_to( descriptor, project, :title => "View project: #{project.name}" )
|
||||
link_to(descriptor, project, :title => "View project: #{project.name}")
|
||||
end
|
||||
|
||||
def link_to_edit_note (note, descriptor = sanitize(note.id.to_s))
|
||||
link_to(descriptor, edit_note_path(note),
|
||||
{:id => "link_edit_#{dom_id(note)}", :class => "note_edit_settings"})
|
||||
{ :id => "link_edit_#{dom_id(note)}", :class => "note_edit_settings" })
|
||||
end
|
||||
|
||||
def link_to_project_mobile(project, accesskey, descriptor = sanitize(project.name))
|
||||
link_to( descriptor, project_path(project, :format => 'm'), {:title => "View project: #{project.name}", :accesskey => accesskey} )
|
||||
link_to(descriptor, project_path(project, :format => 'm'), { :title => "View project: #{project.name}", :accesskey => accesskey })
|
||||
end
|
||||
|
||||
def item_link_to_context(item)
|
||||
link_to_context( item.context, prefs.verbose_action_descriptors ? "[#{item.context.name}]" : "[C]" )
|
||||
link_to_context(item.context, prefs.verbose_action_descriptors ? "[#{item.context.name}]" : "[C]")
|
||||
end
|
||||
|
||||
def item_link_to_project(item)
|
||||
link_to_project( item.project, prefs.verbose_action_descriptors ? "[#{item.project.name}]" : "[P]" )
|
||||
link_to_project(item.project, prefs.verbose_action_descriptors ? "[#{item.project.name}]" : "[P]")
|
||||
end
|
||||
|
||||
def render_flash
|
||||
|
|
@ -127,15 +127,15 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def sidebar_html_for_titled_list (list, title)
|
||||
return content_tag(:h3, title+" (#{list.size})") + content_tag(:ul, sidebar_html_for_list(list))
|
||||
return content_tag(:h3, title+" (#{list.size})") + content_tag(:ul, sidebar_html_for_list(list))
|
||||
end
|
||||
|
||||
def link_to_sidebar_item(item)
|
||||
item.is_a?(Project) ? link_to_project( item ) : link_to_context( item )
|
||||
item.is_a?(Project) ? link_to_project(item) : link_to_context(item)
|
||||
end
|
||||
|
||||
def sidebar_html_for_item(item)
|
||||
content_tag(:li, link_to_sidebar_item(item) + " (" + count_undone_todos_phrase(item)+")")
|
||||
content_tag(:li, link_to_sidebar_item(item) + " (" + count_undone_todos_phrase(item) + ")")
|
||||
end
|
||||
|
||||
def sidebar_html_for_list(list)
|
||||
|
|
@ -175,12 +175,12 @@ module ApplicationHelper
|
|||
def done_path(controller_name, type)
|
||||
case controller_name
|
||||
when "contexts"
|
||||
send("#{type}_todos_context_path",@context)
|
||||
send("#{type}_todos_context_path", @context)
|
||||
when "projects"
|
||||
send("#{type}_todos_project_path", @project)
|
||||
when "todos"
|
||||
if @tag_name
|
||||
send("#{type}_tag_path",@tag_name)
|
||||
send("#{type}_tag_path", @tag_name)
|
||||
else
|
||||
send("#{type}_todos_path")
|
||||
end
|
||||
|
|
@ -199,7 +199,7 @@ module ApplicationHelper
|
|||
|
||||
def get_list_of_error_messages_for(model)
|
||||
if model.errors.any?
|
||||
content_tag(:div, {:id=>"errorExplanation"}) do
|
||||
content_tag(:div, { :id => "errorExplanation" }) do
|
||||
content_tag(:ul) do
|
||||
model.errors.full_messages.collect { |msg| concat(content_tag(:li, msg)) }
|
||||
end
|
||||
|
|
@ -207,10 +207,8 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def link_to_delete(type, object, descriptor = sanitize(object.name))
|
||||
link_to(
|
||||
descriptor,
|
||||
self.send("#{type}_path", object, :format => 'js'),
|
||||
def link_to_delete(type, object, descriptor=sanitize(object.name))
|
||||
link_to(descriptor, self.send("#{type}_path", object, :format => 'js'),
|
||||
{
|
||||
:id => "delete_#{type}_#{object.id}",
|
||||
:class => "delete_#{type}_button icon",
|
||||
|
|
@ -239,7 +237,7 @@ module ApplicationHelper
|
|||
"#{name}_#{SecureRandom.hex(5)}"
|
||||
end
|
||||
|
||||
def js_render(partial, locals = {}, object=nil)
|
||||
def js_render(partial, locals={}, object=nil)
|
||||
if object
|
||||
escape_javascript(render(partial: partial, locals: locals, object: object))
|
||||
else
|
||||
|
|
@ -250,5 +248,4 @@ module ApplicationHelper
|
|||
def js_error_messages_for(object)
|
||||
escape_javascript(get_list_of_error_messages_for(object))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module ContextsHelper
|
||||
|
||||
def show_context_name(context)
|
||||
if source_view_is :context
|
||||
content_tag(:span, :id => "context_name"){context.name}
|
||||
|
|
@ -19,5 +18,4 @@ module ContextsHelper
|
|||
def context_summary(context, undone_todo_count)
|
||||
content_tag(:p, "#{undone_todo_count}. Context is #{context.hidden? ? 'Hidden' : 'Active'}.".html_safe)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module DateLabelHelper
|
||||
|
||||
class GenericDateView
|
||||
include ActionView::Context
|
||||
include ActionView::Helpers
|
||||
|
|
@ -66,11 +65,9 @@ module DateLabelHelper
|
|||
yield
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class DueDateView < GenericDateView
|
||||
|
||||
def due_text
|
||||
case @days_sym
|
||||
when :overdue_by_one
|
||||
|
|
@ -100,11 +97,9 @@ module DateLabelHelper
|
|||
def due_date_mobile_html
|
||||
date_mobile_html_wrapper { @prefs.format_date(@due) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class ShowFromDateView < GenericDateView
|
||||
|
||||
def show_from_text
|
||||
case @days_sym
|
||||
when :overdue_by_more_than_one, :overdue_by_one
|
||||
|
|
@ -127,7 +122,5 @@ module DateLabelHelper
|
|||
def show_from_date_html
|
||||
date_html_wrapper { show_from_text }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
module FeedlistHelper
|
||||
|
||||
def linkoptions(format, options)
|
||||
merge_hashes( {:format => format}, options, user_token_hash)
|
||||
merge_hashes( { :format => format }, options, user_token_hash)
|
||||
end
|
||||
|
||||
def rss_formatted_link(options = {})
|
||||
|
|
@ -10,25 +9,25 @@ module FeedlistHelper
|
|||
end
|
||||
|
||||
def text_formatted_link(options = {})
|
||||
link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}), linkoptions('txt', options))
|
||||
link_to(content_tag(:span, 'TXT', { :class => 'feed', :title => "Plain text feed" }), linkoptions('txt', options))
|
||||
end
|
||||
|
||||
def ical_formatted_link(options = {})
|
||||
link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}), linkoptions('ics', options))
|
||||
link_to(content_tag(:span, 'iCal', { :class=>"feed", :title => "iCal feed" }), linkoptions('ics', options))
|
||||
end
|
||||
|
||||
def feed_links(feeds, link_options, title)
|
||||
space = " "
|
||||
html = ""
|
||||
html << rss_formatted_link(link_options) +space if feeds.include?(:rss)
|
||||
html << text_formatted_link(link_options)+space if feeds.include?(:txt)
|
||||
html << ical_formatted_link(link_options)+space if feeds.include?(:ical)
|
||||
html << rss_formatted_link(link_options) + space if feeds.include?(:rss)
|
||||
html << text_formatted_link(link_options) + space if feeds.include?(:txt)
|
||||
html << ical_formatted_link(link_options) + space if feeds.include?(:ical)
|
||||
html << title
|
||||
return html.html_safe
|
||||
end
|
||||
|
||||
def all_feed_links(object, symbol)
|
||||
feed_links([:rss, :txt, :ical], { :controller=> 'todos', :action => 'index', symbol => object.to_param }, content_tag(:strong, object.name))
|
||||
feed_links([:rss, :txt, :ical], { :controller => 'todos', :action => 'index', symbol => object.to_param }, content_tag(:strong, object.name))
|
||||
end
|
||||
|
||||
def all_feed_links_for_project(project)
|
||||
|
|
@ -48,6 +47,4 @@ module FeedlistHelper
|
|||
def user_token_hash
|
||||
{ :token => current_user.token }
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module IconHelper
|
||||
include FontAwesome::Sass::Rails::ViewHelpers
|
||||
|
||||
def icon_fw(style, name, text = nil, html_options = {})
|
||||
def icon_fw(style, name, text=nil, html_options={})
|
||||
text, html_options = nil, text if text.is_a?(Hash)
|
||||
|
||||
if html_options.key?(:class)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
module LoginHelper
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module PreferencesHelper
|
||||
|
||||
def pref(model, pref_name, &block)
|
||||
s = content_tag(:label, Preference.human_attribute_name(pref_name), :for => model + "_" + pref_name)
|
||||
s << yield
|
||||
|
|
@ -10,7 +9,7 @@ module PreferencesHelper
|
|||
pref(model, pref_name) { check_box(model, pref_name, class: "form-control") }
|
||||
end
|
||||
|
||||
def pref_with_select_field(model, pref_name, collection = [ [t('preferences.is_true'),true], [t('preferences.is_false'), false] ])
|
||||
def pref_with_select_field(model, pref_name, collection = [[t('preferences.is_true'), true], [t('preferences.is_false'), false]])
|
||||
pref(model, pref_name) { select(model, pref_name, collection, {}, class: "form-control") }
|
||||
end
|
||||
|
||||
|
|
@ -21,8 +20,8 @@ module PreferencesHelper
|
|||
def profile_delete_user(user)
|
||||
return link_to(
|
||||
t('users.destroy_user'),
|
||||
url_for({:controller => 'users', :action => 'destroy', :id => user.id}),
|
||||
{:id => "delete_user_#{user.id}",
|
||||
url_for({ :controller => 'users', :action => 'destroy', :id => user.id }),
|
||||
{ :id => "delete_user_#{user.id}",
|
||||
:class => "delete_user_button btn btn-danger",
|
||||
:title => t('users.destroy_user'),
|
||||
:x_confirm_message => t('users.destroy_confirmation', :login => user.login)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module ProjectsHelper
|
||||
|
||||
def show_project_name(project)
|
||||
if source_view_is :project
|
||||
content_tag(:span, :id => "project_name"){project.name}
|
||||
|
|
@ -9,7 +8,7 @@ module ProjectsHelper
|
|||
end
|
||||
|
||||
def show_project_settings(project)
|
||||
content_tag(:div, :id => dom_id(project, "container"), :class=>"list") do
|
||||
content_tag(:div, :id => dom_id(project, "container"), :class => "list") do
|
||||
render :partial => "projects/project_settings", :object => project
|
||||
end
|
||||
end
|
||||
|
|
@ -27,9 +26,9 @@ module ProjectsHelper
|
|||
def project_next_prev_mobile
|
||||
prev_project = ""
|
||||
next_project = ""
|
||||
prev_project = content_tag(:li, link_to_project_mobile(@previous_project, "5", @previous_project.shortened_name), :class=>"prev") if @previous_project
|
||||
next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class=>"next") if @next_project
|
||||
return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class=>"next-prev-project")
|
||||
prev_project = content_tag(:li, link_to_project_mobile(@previous_project, "5", @previous_project.shortened_name), :class => "prev") if @previous_project
|
||||
next_project = content_tag(:li, link_to_project_mobile(@next_project, "6", @next_project.shortened_name), :class => "next") if @next_project
|
||||
return content_tag(:ul, "#{prev_project}#{next_project}".html_safe, :class => "next-prev-project")
|
||||
end
|
||||
|
||||
def project_summary(project)
|
||||
|
|
@ -52,5 +51,4 @@ module ProjectsHelper
|
|||
def link_to_edit_project (project, descriptor = sanitize(project.name))
|
||||
link_to_edit(:project, project, descriptor)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
module RecurringTodosHelper
|
||||
|
||||
def recurring_todo_tag_list
|
||||
tags_except_starred = @recurring_todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME}
|
||||
tag_list = tags_except_starred.
|
||||
collect{|t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}")}.
|
||||
join('')
|
||||
tags_except_starred = @recurring_todo.tags.reject{ |t| t.name == Todo::STARRED_TAG_NAME }
|
||||
tag_list = tags_except_starred
|
||||
.collect{ |t| content_tag(:span,link_to(t.name, tag_path(t.name)), :class => "tag #{t.label}") }
|
||||
.join('')
|
||||
return content_tag :span, tag_list.html_safe, :class => "tags"
|
||||
end
|
||||
|
||||
def recurring_todo_remote_delete_icon
|
||||
link_to( image_tag_for_delete,
|
||||
recurring_todo_path(@recurring_todo), :id => "delete_icon_"+@recurring_todo.id.to_s,
|
||||
link_to(image_tag_for_delete, recurring_todo_path(@recurring_todo),
|
||||
:id => "delete_icon_" + @recurring_todo.id.to_s,
|
||||
:class => "icon delete_icon", :title => t('todos.delete_recurring_action_title'), :x_confirm_message => t('todos.delete_recurring_action_confirm', :description => @recurring_todo.description))
|
||||
end
|
||||
|
||||
def recurring_todo_remote_star_icon
|
||||
link_to( image_tag_for_star(@recurring_todo),
|
||||
toggle_star_recurring_todo_path(@recurring_todo), :id => "star_icon_"+@recurring_todo.id.to_s,
|
||||
link_to(image_tag_for_star(@recurring_todo),
|
||||
toggle_star_recurring_todo_path(@recurring_todo), :id => "star_icon_" + @recurring_todo.id.to_s,
|
||||
:class => "icon star_item", :title => t('todos.star_action'))
|
||||
end
|
||||
|
||||
def recurring_todo_remote_edit_icon
|
||||
if !@recurring_todo.completed?
|
||||
str = link_to( image_tag_for_edit(@recurring_todo),
|
||||
str = link_to(image_tag_for_edit(@recurring_todo),
|
||||
edit_recurring_todo_path(@recurring_todo),
|
||||
:class => "icon edit_icon", :id => "link_edit_recurring_todo_#{@recurring_todo.id}")
|
||||
else
|
||||
|
|
@ -38,10 +37,10 @@ module RecurringTodosHelper
|
|||
private
|
||||
|
||||
def image_tag_for_delete
|
||||
image_tag("blank.png", :title =>t('todos.delete_action'), :class=>"delete_item")
|
||||
image_tag("blank.png", :title => t('todos.delete_action'), :class => "delete_item")
|
||||
end
|
||||
|
||||
def image_tag_for_edit(todo)
|
||||
image_tag("blank.png", :title =>t('todos.edit_action'), :class=>"edit_item", :id=> dom_id(todo, 'edit_icon'))
|
||||
image_tag("blank.png", :title => t('todos.edit_action'), :class => "edit_item", :id => dom_id(todo, 'edit_icon'))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module RenderingHelper
|
|||
# add onenote and message protocols, allow a target
|
||||
a_href_config = relaxed_config[:protocols]['a']['href'] + %w(onenote message)
|
||||
a_attributes = relaxed_config[:attributes]['a'] + ['target']
|
||||
config = Sanitize::Config.merge(config, protocols: {'a' => {'href' => a_href_config}}, :attributes => {'a' => a_attributes})
|
||||
config = Sanitize::Config.merge(config, protocols: { 'a' => { 'href' => a_href_config } }, :attributes => { 'a' => a_attributes })
|
||||
|
||||
rendered = Sanitize.fragment(rendered, config)
|
||||
return rendered.html_safe
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
module StatsHelper
|
||||
|
||||
def font_size(cloud, tag)
|
||||
9 + 2 * cloud.relative_size(tag)
|
||||
end
|
||||
|
||||
def month_and_year_label(i)
|
||||
t('date.month_names')[ (Time.zone.now.mon - i -1 ) % 12 + 1 ]+ " " + (Time.zone.now - i.months).year.to_s
|
||||
t('date.month_names')[(Time.zone.now.mon - i - 1) % 12 + 1] + " " + (Time.zone.now - i.months).year.to_s
|
||||
end
|
||||
|
||||
def array_of_month_and_year_labels(count)
|
||||
|
|
@ -13,11 +12,10 @@ module StatsHelper
|
|||
end
|
||||
|
||||
def month_label(i)
|
||||
t('date.month_names')[ (Time.zone.now.mon - i -1 ) % 12 + 1 ]
|
||||
t('date.month_names')[(Time.zone.now.mon - i - 1) % 12 + 1]
|
||||
end
|
||||
|
||||
def array_of_month_labels(count)
|
||||
Array.new(count) { |i| month_label(i) }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
require 'staleness'
|
||||
|
||||
module TodosHelper
|
||||
|
||||
# === helpers for rendering container
|
||||
|
||||
def empty_message_holder(container_name, show, title_param=nil)
|
||||
content_tag(:div, :id => "no_todos_in_view", :class => "container #{container_name}", :style => "display:" + (show ? "block" : "none") ) do
|
||||
content_tag(:h2) { t("todos.no_actions.title", :param=>title_param) } +
|
||||
|
|
@ -14,7 +12,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def todos_container_empty_message(container_name, container_id, show_message)
|
||||
content_tag(:div, :id=>"#{container_id}-empty-d", :style=>"display:#{show_message ? 'block' : 'none'}") do
|
||||
content_tag(:div, :id => "#{container_id}-empty-d", :style => "display:#{show_message ? 'block' : 'none'}") do
|
||||
content_tag(:div, :class=>"message") do
|
||||
content_tag(:p) do
|
||||
t("todos.no_actions.#{container_name}")
|
||||
|
|
@ -49,7 +47,7 @@ module TodosHelper
|
|||
|
||||
render :partial => 'todos/collection',
|
||||
:object => done_todos,
|
||||
:locals => {:settings => settings.reverse_merge!(default_collection_settings)}
|
||||
:locals => { :settings => settings.reverse_merge!(default_collection_settings) }
|
||||
end
|
||||
|
||||
def show_completed_todos_for(period, collection)
|
||||
|
|
@ -62,7 +60,7 @@ module TodosHelper
|
|||
|
||||
render :partial => "todos/collection",
|
||||
:object => collection,
|
||||
:locals => { :settings => settings}
|
||||
:locals => { :settings => settings }
|
||||
end
|
||||
|
||||
def show_hidden_todos(hidden_todos, settings={})
|
||||
|
|
@ -70,7 +68,7 @@ module TodosHelper
|
|||
|
||||
render :partial => 'todos/collection',
|
||||
:object => hidden_todos,
|
||||
:locals => {:settings => settings.reverse_merge!(default_collection_settings)}
|
||||
:locals => { :settings => settings.reverse_merge!(default_collection_settings) }
|
||||
end
|
||||
|
||||
def show_deferred_pending_todos(deferred_todos, pending_todos, settings={})
|
||||
|
|
@ -79,13 +77,13 @@ module TodosHelper
|
|||
|
||||
render :partial => "todos/collection",
|
||||
:object => deferred_todos+pending_todos,
|
||||
:locals => {:settings => settings.reverse_merge!(default_collection_settings)}
|
||||
:locals => { :settings => settings.reverse_merge!(default_collection_settings) }
|
||||
end
|
||||
|
||||
def show_todos_without_project(todos_without_project, settings = {})
|
||||
render :partial => 'todos/collection',
|
||||
:object => todos_without_project,
|
||||
:locals => {:settings => settings.reverse_merge!({
|
||||
:locals => { :settings => settings.reverse_merge!({
|
||||
:collapsible => true,
|
||||
:container_name => "without_project",
|
||||
:parent_container_type => "home"
|
||||
|
|
@ -104,8 +102,8 @@ module TodosHelper
|
|||
end
|
||||
|
||||
content_tag(:div,
|
||||
:class=>settings[:class],
|
||||
:id=>settings[:id],
|
||||
:class => settings[:class],
|
||||
:id => settings[:id],
|
||||
:style => "display:" + (settings[:show_container] ? "block" : "none")) do
|
||||
yield
|
||||
end
|
||||
|
|
@ -129,7 +127,7 @@ module TodosHelper
|
|||
# do not pass :class to partial locals
|
||||
settings.delete(:class)
|
||||
|
||||
content_tag(:div, :id =>settings[:id]+"_items", :class=>"items toggle_target") do
|
||||
content_tag(:div, :id => settings[:id] + "_items", :class => "items toggle_target") do
|
||||
todos_container_empty_message(settings[:container_name], settings[:id], collection.empty?) +
|
||||
render(:partial => "todos/todo", :collection => collection, :locals => settings)
|
||||
end
|
||||
|
|
@ -138,19 +136,18 @@ module TodosHelper
|
|||
def todos_calendar_container(period, collection)
|
||||
render :partial => 'todos/collection',
|
||||
:object => collection,
|
||||
:locals => {:settings => {
|
||||
:locals => { :settings => {
|
||||
:collapsible => false,
|
||||
:show_empty_containers => true,
|
||||
:container_name => "#{period}",
|
||||
:title =>t("todos.calendar.#{period}", :month => l(Time.zone.now, :format => "%B"), :next_month => l(1.month.from_now, :format => "%B"))
|
||||
}
|
||||
}
|
||||
} }
|
||||
end
|
||||
|
||||
# === helpers for rendering a todo
|
||||
|
||||
def remote_star_icon(todo=@todo)
|
||||
link_to( image_tag_for_star(todo),
|
||||
link_to(image_tag_for_star(todo),
|
||||
toggle_star_todo_path(todo),
|
||||
:class => "icon star_item", :title => t('todos.star_action_with_description', :description => todo.description))
|
||||
end
|
||||
|
|
@ -167,7 +164,7 @@ module TodosHelper
|
|||
def remote_delete_menu_item(todo)
|
||||
return link_to(
|
||||
t('todos.delete'),
|
||||
{:controller => 'todos', :action => 'destroy', :id => todo.id},
|
||||
{ :controller => 'todos', :action => 'destroy', :id => todo.id },
|
||||
:class => "icon_delete_item",
|
||||
:id => dom_id(todo, "delete"),
|
||||
:x_confirm_message => t('todos.confirm_delete', :description => todo.description),
|
||||
|
|
@ -175,11 +172,11 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def remote_defer_menu_item(days, todo)
|
||||
url = {:controller => 'todos', :action => 'defer', :id => todo.id, :days => days,
|
||||
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
|
||||
url = { :controller => 'todos', :action => 'defer', :id => todo.id, :days => days,
|
||||
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "") }
|
||||
url[:_tag_name] = @tag_name if @source_view == 'tag'
|
||||
|
||||
options = {:x_defer_alert => false, :class => "icon_defer_item icon_defer_#{days}_item", :id => "defer_#{days}_#{dom_id(todo)}" }
|
||||
options = { :x_defer_alert => false, :class => "icon_defer_item icon_defer_#{days}_item", :id => "defer_#{days}_#{dom_id(todo)}" }
|
||||
if todo.due
|
||||
futuredate = (todo.show_from || todo.user.date) + days.days
|
||||
if futuredate.at_midnight > todo.due.at_midnight
|
||||
|
|
@ -204,32 +201,32 @@ module TodosHelper
|
|||
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
|
||||
url[:_tag_name] = @tag_name if @source_view == 'tag'
|
||||
|
||||
link_to(t('todos.convert_to_project'), url, {:class => "icon_item_to_project", :id => dom_id(todo, "to_project")})
|
||||
link_to(t('todos.convert_to_project'), url, { :class => "icon_item_to_project", :id => dom_id(todo, "to_project") })
|
||||
end
|
||||
|
||||
def attachment_image(todo)
|
||||
link_to(
|
||||
image_tag('blank.png', width: 16, height: 16, border:0),
|
||||
todo.attachments.first.file.url,
|
||||
{:class => 'todo_attachment', title: 'Get attachments of this todo'}
|
||||
{ :class => 'todo_attachment', title: 'Get attachments of this todo' }
|
||||
)
|
||||
end
|
||||
|
||||
def collapsed_notes_image(todo)
|
||||
link = link_to(
|
||||
image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ),
|
||||
image_tag( 'blank.png', :width => '16', :height => '16', :border => '0' ),
|
||||
"#",
|
||||
{:class => 'show_notes', :title => 'Show notes'})
|
||||
{ :class => 'show_notes', :title => 'Show notes' })
|
||||
notes = content_tag(:div, {
|
||||
:class => "todo_notes",
|
||||
:id => dom_id(todo, 'notes'),
|
||||
:style => "display:none"}) { raw render_text(todo.notes) }
|
||||
:style => "display:none" }) { raw render_text(todo.notes) }
|
||||
return link+notes
|
||||
end
|
||||
|
||||
def collapsed_successors_image(todo)
|
||||
link = link_to(image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ), "#", {:class => 'show_successors', :title => 'Show successors'})
|
||||
successors = content_tag(:div, {:class => "todo_successors", :id => dom_id(todo, 'successors'), :style => "display:none"}) do
|
||||
link = link_to(image_tag('blank.png', :width => '16', :height => '16', :border => '0' ), "#", { :class => 'show_successors', :title => 'Show successors' })
|
||||
successors = content_tag(:div, { :class => "todo_successors", :id => dom_id(todo, 'successors'), :style => "display:none" }) do
|
||||
render :partial => "todos/successor", :collection => todo.pending_successors,
|
||||
:locals => { :parent_container_type => parent_container_type, :suppress_dependencies => true, :predecessor => todo }
|
||||
end
|
||||
|
|
@ -244,7 +241,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def image_tag_for_star(todo)
|
||||
image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s)
|
||||
image_tag("blank.png", :title => t('todos.star_action'), :class => "todo_star" + (todo.starred? ? " starred" : ""), :id => "star_img_" + todo.id.to_s)
|
||||
end
|
||||
|
||||
def remote_toggle_checkbox(todo=@todo)
|
||||
|
|
@ -260,14 +257,14 @@ module TodosHelper
|
|||
|
||||
def date_span(todo=@todo)
|
||||
if todo.completed?
|
||||
content_tag(:span, {:class => :grey}) { format_date( todo.completed_at ) }
|
||||
content_tag(:span, { :class => :grey }) { format_date( todo.completed_at ) }
|
||||
elsif todo.pending?
|
||||
title = t('todos.depends_on')+ ": " + todo.uncompleted_predecessors.to_a.map(&:description).join(', ')
|
||||
content_tag(:a, {:title => title}) { content_tag(:span, {:class => :orange}) { t('todos.pending') } }
|
||||
content_tag(:a, { :title => title }) { content_tag(:span, { :class => :orange }) { t('todos.pending') } }
|
||||
elsif todo.deferred?
|
||||
show_date( todo.show_from )
|
||||
show_date(todo.show_from)
|
||||
else
|
||||
due_date( todo.due )
|
||||
due_date(todo.due)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -275,7 +272,7 @@ module TodosHelper
|
|||
unless todo.pending_successors.empty?
|
||||
pending_count = todo.pending_successors.count
|
||||
title = "#{t('todos.has_x_pending', :count => pending_count)}: #{todo.pending_successors.to_a.map(&:description).join(', ')}"
|
||||
image_tag( 'successor_off.png', :width=>'10', :height=>'16', :border=>'0', :title => title )
|
||||
image_tag('successor_off.png', :width => '10', :height => '16', :border => '0', :title => title)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -291,12 +288,12 @@ module TodosHelper
|
|||
todo.tags.to_a.join(', ')
|
||||
end
|
||||
|
||||
def tag_span (tag, mobile=false)
|
||||
def tag_span(tag, mobile=false)
|
||||
content_tag(:span, :class => "tag #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
|
||||
end
|
||||
|
||||
def tag_list(todo=@todo, mobile=false)
|
||||
content_tag(:span, :class => 'tags') { todo.tags.all_except_starred.collect{|tag| tag_span(tag, mobile)}.join('').html_safe }
|
||||
content_tag(:span, :class => 'tags') { todo.tags.all_except_starred.collect{ |tag| tag_span(tag, mobile) }.join('').html_safe }
|
||||
end
|
||||
|
||||
def tag_list_mobile(todo=@todo)
|
||||
|
|
@ -310,11 +307,11 @@ module TodosHelper
|
|||
def project_and_context_links(todo, parent_container_type, opts = {})
|
||||
links = ''
|
||||
if todo.completed?
|
||||
links << item_link_to_context( todo ) unless opts[:suppress_context]
|
||||
links << item_link_to_project( todo ) unless opts[:suppress_project] || todo.project.nil?
|
||||
links << item_link_to_context(todo) unless opts[:suppress_context]
|
||||
links << item_link_to_project(todo) unless opts[:suppress_project] || todo.project.nil?
|
||||
else
|
||||
links << item_link_to_context( todo ) if include_context_link(todo, parent_container_type)
|
||||
links << item_link_to_project( todo ) if include_project_link(todo, parent_container_type)
|
||||
links << item_link_to_context(todo) if include_context_link(todo, parent_container_type)
|
||||
links << item_link_to_project(todo) if include_project_link(todo, parent_container_type)
|
||||
end
|
||||
|
||||
links.html_safe
|
||||
|
|
@ -364,7 +361,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def date_field_tag(name, id, value = nil, options = {})
|
||||
text_field_tag name, value, {"size" => 12, "id" => id, "class" => "Date", "autocomplete" => "off"}.update(options.stringify_keys)
|
||||
text_field_tag name, value, { "size" => 12, "id" => id, "class" => "Date", "autocomplete" => "off" }.update(options.stringify_keys)
|
||||
end
|
||||
|
||||
def sort_key(todo)
|
||||
|
|
@ -484,11 +481,11 @@ module TodosHelper
|
|||
|
||||
def todo_moved_out_of_container
|
||||
# moved from one project container to another
|
||||
moved_project = @project_changed && @group_view_by=='project'
|
||||
moved_project = @project_changed && @group_view_by == 'project'
|
||||
# moved from one context container to another
|
||||
moved_context = @context_changed && @group_view_by=='context'
|
||||
moved_context = @context_changed && @group_view_by == 'context'
|
||||
# moved from actions-without-project container to another
|
||||
moved_without_project = @context_changed && @group_view_by=='project' && @todo.project_id.nil?
|
||||
moved_without_project = @context_changed && @group_view_by == 'project' && @todo.project_id.nil?
|
||||
|
||||
return moved_project || moved_context || moved_without_project
|
||||
end
|
||||
|
|
@ -557,7 +554,7 @@ module TodosHelper
|
|||
page.deferred { return todo_moved_out_of_container && (@todo.deferred? || @todo.pending?) }
|
||||
page.calendar { return @due_date_changed && @todo.due }
|
||||
page.stats { return false }
|
||||
page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed}
|
||||
page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed }
|
||||
page.todo { return todo_moved_out_of_container && !(@todo.deferred? || @todo.pending? || @todo.hidden?) }
|
||||
end
|
||||
return false
|
||||
|
|
@ -684,5 +681,4 @@ module TodosHelper
|
|||
end
|
||||
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);".html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
module UsersHelper
|
||||
def remote_delete_user(user)
|
||||
return link_to(
|
||||
image_tag("blank.png", :title =>t('users.destroy_user'), :class=>"delete_item"),
|
||||
image_tag("blank.png", :title => t('users.destroy_user'), :class => "delete_item"),
|
||||
url_for({:controller => 'users', :action => 'destroy', :id => user.id}),
|
||||
{:id => "delete_user_#{user.id}",
|
||||
{ :id => "delete_user_#{user.id}",
|
||||
:class => "delete_user_button",
|
||||
:title => t('users.destroy_user'),
|
||||
:x_confirm_message => t('users.destroy_confirmation', :login => user.login)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue