mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-05 07:21:48 +01:00
small refactorings
This commit is contained in:
parent
26a27e5cfe
commit
ccdaae038b
4 changed files with 57 additions and 63 deletions
|
|
@ -237,39 +237,30 @@ module ApplicationHelper
|
|||
javascript_include_tag("i18n/jquery.ui.datepicker-#{locale}.js")
|
||||
end
|
||||
end
|
||||
|
||||
def determine_done_path
|
||||
case controller.controller_name
|
||||
|
||||
def done_path(controller_name, type)
|
||||
case controller_name
|
||||
when "contexts"
|
||||
done_todos_context_path(@context)
|
||||
send("#{type}_context_path",@context)
|
||||
when "projects"
|
||||
done_todos_project_path(@project)
|
||||
send("#{type}_todos_project_path", @project)
|
||||
when "todos"
|
||||
if source_view_is(:tag)
|
||||
done_tag_path(@tag_name)
|
||||
send("#{type}_tag_path",@tag_name)
|
||||
else
|
||||
done_todos_path
|
||||
send("#{type}_todos_path")
|
||||
end
|
||||
else
|
||||
done_todos_path
|
||||
send("#{type}_todos_path")
|
||||
end
|
||||
end
|
||||
|
||||
def determine_done_path
|
||||
done_path(controller.controller_name, :done)
|
||||
end
|
||||
|
||||
def determine_all_done_path
|
||||
case controller.controller_name
|
||||
when "contexts"
|
||||
all_done_todos_context_path(@context)
|
||||
when "projects"
|
||||
all_done_todos_project_path(@project)
|
||||
when "todos"
|
||||
if source_view_is(:tag)
|
||||
all_done_tag_path(@tag_name)
|
||||
else
|
||||
all_done_todos_path
|
||||
end
|
||||
else
|
||||
all_done_todos_path
|
||||
end
|
||||
done_path(controller.controller_name, :all_done)
|
||||
end
|
||||
|
||||
def get_list_of_error_messages_for(model)
|
||||
|
|
@ -282,4 +273,26 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
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",
|
||||
:x_confirm_message => t("#{type}s.delete_#{type}_confirmation", :name => object.name),
|
||||
:title => t("#{type}s.delete_#{type}_title")
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def link_to_edit(type, object, descriptor)
|
||||
link_to(descriptor, self.send("edit_#{type}_path", object),
|
||||
{
|
||||
:id => "link_edit_#{dom_id(object)}",
|
||||
:class => "#{type}_edit_settings icon"
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,22 +9,11 @@ module ContextsHelper
|
|||
end
|
||||
|
||||
def link_to_delete_context(context, descriptor = sanitize(context.name))
|
||||
link_to(descriptor,
|
||||
context_path(context, :format => 'js'),
|
||||
{
|
||||
:id => "delete_context_#{context.id}",
|
||||
:class => "delete_context_button icon",
|
||||
:x_confirm_message => t('contexts.delete_context_confirmation', :name => context.name),
|
||||
:title => t('contexts.delete_context_title')
|
||||
})
|
||||
link_to_delete(:context, context, descriptor)
|
||||
end
|
||||
|
||||
def link_to_edit_context (context, descriptor = sanitize(context.name))
|
||||
link_to(descriptor, edit_context_path(context),
|
||||
{
|
||||
:id => "link_edit_#{dom_id(context)}",
|
||||
:class => "context_edit_settings icon"
|
||||
})
|
||||
link_to_edit(:context, context, descriptor)
|
||||
end
|
||||
|
||||
def context_summary(context, undone_todo_count)
|
||||
|
|
|
|||
|
|
@ -30,27 +30,6 @@ module ProjectsHelper
|
|||
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 link_to_delete_project(project, descriptor = sanitize(project.name))
|
||||
link_to(
|
||||
descriptor,
|
||||
project_path(project, :format => 'js'),
|
||||
{
|
||||
:id => "delete_project_#{project.id}",
|
||||
:class => "delete_project_button icon",
|
||||
:x_confirm_message => t('projects.delete_project_confirmation', :name => project.name),
|
||||
:title => t('projects.delete_project_title')
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def link_to_edit_project (project, descriptor = sanitize(project.name))
|
||||
link_to(descriptor, edit_project_path(project),
|
||||
{
|
||||
:id => "link_edit_#{dom_id(project)}",
|
||||
:class => "project_edit_settings icon"
|
||||
})
|
||||
end
|
||||
|
||||
def project_summary(project)
|
||||
project_description = ''
|
||||
|
|
@ -65,4 +44,12 @@ module ProjectsHelper
|
|||
return item.needs_review?(current_user) ? "needsreview" : "needsnoreview"
|
||||
end
|
||||
|
||||
def link_to_delete_project(project, descriptor = sanitize(project.name))
|
||||
link_to_delete(:project, project, descriptor)
|
||||
end
|
||||
|
||||
def link_to_edit_project (project, descriptor = sanitize(project.name))
|
||||
link_to_edit(:project, project, descriptor)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue