mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-01 02:20:16 +01:00
change look of todo
This commit is contained in:
parent
b79efb3f31
commit
972210326a
10 changed files with 136 additions and 84 deletions
|
|
@ -16,13 +16,6 @@ module ApplicationHelper
|
|||
{:id => "group_view_by_link", :accesskey => "g", :title => t('layouts.navigation.group_view_by_title'), :x_current_group_by => @group_view_by} )
|
||||
end
|
||||
end
|
||||
|
||||
def container_toggle(id)
|
||||
link_to(
|
||||
image_tag("blank.png", :alt => t('common.collapse_expand')),
|
||||
"#",
|
||||
{:class => "container_toggle", :id => id} )
|
||||
end
|
||||
|
||||
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
link_to name, options, html_options
|
||||
|
|
@ -39,38 +32,31 @@ module ApplicationHelper
|
|||
return "" if due.nil?
|
||||
|
||||
days = days_from_today(due)
|
||||
days_limited = days
|
||||
days_limited = -2 if days < -2
|
||||
days_limited = 2 if days > 2
|
||||
|
||||
colors = ['amber','amber','orange','orange','orange','orange','orange','orange']
|
||||
color = :red if days < 0
|
||||
color = :green if days > 7
|
||||
colors = [:warning, :warning, :warning, :info, :info, :info]
|
||||
color = :important if days < 0
|
||||
color = :default if days > 7
|
||||
color = colors[days] if color.nil?
|
||||
|
||||
|
||||
if prefs.due_style == Preference.due_styles[:due_on]
|
||||
# TODO: internationalize strftime here
|
||||
due_text = Hash.new( t('models.preference.due_on', :date => due.strftime("%A")) )
|
||||
else
|
||||
due_text = Hash.new( t('models.preference.due_in', :days => days) )
|
||||
end
|
||||
|
||||
due_text = Hash.new(t('models.preference.due_in', :days => days)).merge({
|
||||
"-2" => t('todos.next_actions_due_date.overdue_by_plural', :days => days * -1),
|
||||
"-1" => t('todos.next_actions_due_date.overdue_by', :days => days * -1),
|
||||
"0" => t('todos.next_actions_due_date.due_today'),
|
||||
"1" => t('todos.next_actions_due_date.due_tomorrow')
|
||||
})
|
||||
|
||||
return content_tag(:a, {:title => format_date(due)}) {
|
||||
content_tag(:span, {:class => color}) {
|
||||
case days
|
||||
when 0
|
||||
t('todos.next_actions_due_date.due_today')
|
||||
when 1
|
||||
t('todos.next_actions_due_date.due_tomorrow')
|
||||
when 2..7
|
||||
if prefs.due_style == Preference.due_styles[:due_on]
|
||||
# TODO: internationalize strftime here
|
||||
t('models.preference.due_on', :date => due.strftime("%A"))
|
||||
else
|
||||
t('models.preference.due_in', :days => days)
|
||||
end
|
||||
else
|
||||
# overdue or due very soon! sound the alarm!
|
||||
if days == -1
|
||||
t('todos.next_actions_due_date.overdue_by', :days => days * -1)
|
||||
elsif days < -1
|
||||
t('todos.next_actions_due_date.overdue_by_plural', :days => days * -1)
|
||||
else
|
||||
# more than a week away - relax
|
||||
t('models.preference.due_in', :days => days)
|
||||
end
|
||||
end
|
||||
}
|
||||
content_tag(:span, {:class => "badge badge-#{color}"}) { due_text[days_limited.to_s] }
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,13 +12,8 @@ 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, :class=>"message") do
|
||||
content_tag(:p) do
|
||||
t("todos.no_actions.#{container_name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
render partial: "todos/container_empty_message", locals:
|
||||
{container_id: container_id, container_name: container_name, show_message: show_message}
|
||||
end
|
||||
|
||||
def show_grouped_todos(settings = {})
|
||||
|
|
@ -93,8 +88,8 @@ module TodosHelper
|
|||
|
||||
def todos_container(settings={})
|
||||
settings.reverse_merge!({
|
||||
:id => "#{settings[:container_name]}_container",
|
||||
:class => "container #{settings[:container_name]}",
|
||||
:id => "#{settings[:container_name]}-container",
|
||||
:class => "todos-container #{settings[:container_name]}",
|
||||
})
|
||||
|
||||
if settings[:collapsible]
|
||||
|
|
@ -115,7 +110,8 @@ module TodosHelper
|
|||
})
|
||||
header = settings[:link_in_header].nil? ? "" : content_tag(:div, :class=>"add_note_link"){settings[:link_in_header]}
|
||||
header += content_tag(:h4) do
|
||||
toggle = settings[:collapsible] ? container_toggle("toggle_#{settings[:id]}") : ""
|
||||
toggle = ""
|
||||
# toggle = settings[:collapsible] ? container_toggle("toggle_#{settings[:id]}") : ""
|
||||
"#{toggle} #{settings[:title]} #{settings[:append_descriptor]}".html_safe
|
||||
end
|
||||
header.html_safe
|
||||
|
|
@ -126,10 +122,14 @@ module TodosHelper
|
|||
# do not pass :class to partial locals
|
||||
settings.delete(:class)
|
||||
|
||||
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
|
||||
render :partial => 'todos/container_items', :locals => {
|
||||
div_id: settings[:id]+"_items",
|
||||
container_name: settings[:container_name],
|
||||
todo_id: settings[:id],
|
||||
hide_empty_message: collection.empty?,
|
||||
collection: collection,
|
||||
settings: settings
|
||||
}
|
||||
end
|
||||
|
||||
def todos_calendar_container(period, collection)
|
||||
|
|
@ -281,7 +281,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def tag_span (tag, mobile=false)
|
||||
content_tag(:span, :class => "label label-info #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
|
||||
content_tag(:span, :class => "label #{tag.label}") { link_to(tag.name, tag_path(tag.name, :format => mobile ? :m : nil)) }
|
||||
end
|
||||
|
||||
def tag_list(todo=@todo, mobile=false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue