mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Project and context view can now be grouped by context and project (using view menu)
This commit is contained in:
parent
591e20c9f1
commit
0a57a68a87
10 changed files with 34 additions and 15 deletions
|
|
@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base
|
||||||
before_filter :set_time_zone
|
before_filter :set_time_zone
|
||||||
before_filter :set_zindex_counter
|
before_filter :set_zindex_counter
|
||||||
before_filter :set_locale
|
before_filter :set_locale
|
||||||
|
append_before_filter :set_group_view_by
|
||||||
prepend_before_filter :login_required
|
prepend_before_filter :login_required
|
||||||
prepend_before_filter :enable_mobile_content_negotiation
|
prepend_before_filter :enable_mobile_content_negotiation
|
||||||
after_filter :set_charset
|
after_filter :set_charset
|
||||||
|
|
@ -290,4 +291,8 @@ class ApplicationController < ActionController::Base
|
||||||
render :template => 'todos/done'
|
render :template => 'todos/done'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_group_view_by
|
||||||
|
@group_view_by = params['_group_view_by'] || cookies['group_view_by'] || 'context'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ class ContextsController < ApplicationController
|
||||||
@max_completed = current_user.prefs.show_number_completed
|
@max_completed = current_user.prefs.show_number_completed
|
||||||
@done = @context.todos.completed.limit(@max_completed).reorder("todos.completed_at DESC, todos.created_at DESC").includes(Todo::DEFAULT_INCLUDES)
|
@done = @context.todos.completed.limit(@max_completed).reorder("todos.completed_at DESC, todos.created_at DESC").includes(Todo::DEFAULT_INCLUDES)
|
||||||
@not_done_todos = @context.todos.active.reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(Todo::DEFAULT_INCLUDES)
|
@not_done_todos = @context.todos.active.reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
@todos_without_project = @not_done_todos.select{|t| t.project.nil?}
|
||||||
|
|
||||||
@deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
@deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
||||||
@pending_todos = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES)
|
@pending_todos = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
|
@ -49,6 +50,9 @@ class ContextsController < ApplicationController
|
||||||
@projects = current_user.projects
|
@projects = current_user.projects
|
||||||
@contexts = current_user.contexts
|
@contexts = current_user.contexts
|
||||||
|
|
||||||
|
@projects_to_show = @projects.active
|
||||||
|
@contexts_to_show = [@context]
|
||||||
|
|
||||||
@count = @not_done_todos.count + @deferred_todos.count + @pending_todos.count
|
@count = @not_done_todos.count + @deferred_todos.count + @pending_todos.count
|
||||||
@page_title = "TRACKS::Context: #{@context.name}"
|
@page_title = "TRACKS::Context: #{@context.name}"
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
||||||
|
|
@ -131,12 +131,14 @@ class ProjectsController < ApplicationController
|
||||||
@not_done_todos = @project.todos.active_or_hidden.includes(Todo::DEFAULT_INCLUDES)
|
@not_done_todos = @project.todos.active_or_hidden.includes(Todo::DEFAULT_INCLUDES)
|
||||||
@deferred_todos = @project.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
@deferred_todos = @project.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
||||||
@pending_todos = @project.todos.pending.includes(Todo::DEFAULT_INCLUDES)
|
@pending_todos = @project.todos.pending.includes(Todo::DEFAULT_INCLUDES)
|
||||||
|
@contexts_to_show = current_user.contexts.active
|
||||||
|
@projects_to_show = [@project]
|
||||||
|
|
||||||
@done = {}
|
@done = {}
|
||||||
@done = @project.todos.completed.
|
@done = @project.todos.completed.
|
||||||
reorder("todos.completed_at DESC").
|
reorder("todos.completed_at DESC").
|
||||||
limit(current_user.prefs.show_number_completed).
|
limit(current_user.prefs.show_number_completed).
|
||||||
includes(Todo::DEFAULT_INCLUDES) unless current_user.prefs.show_number_completed == 0
|
includes(Todo::DEFAULT_INCLUDES) unless @max_completed == 0
|
||||||
|
|
||||||
@count = @not_done_todos.size
|
@count = @not_done_todos.size
|
||||||
@down_count = @count + @deferred_todos.size + @pending_todos.size
|
@down_count = @count + @deferred_todos.size + @pending_todos.size
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ class TodosController < ApplicationController
|
||||||
skip_before_filter :login_required, :only => [:index, :tag]
|
skip_before_filter :login_required, :only => [:index, :tag]
|
||||||
prepend_before_filter :login_or_feed_token_required, :only => [:index, :tag]
|
prepend_before_filter :login_or_feed_token_required, :only => [:index, :tag]
|
||||||
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
|
append_before_filter :find_and_activate_ready, :only => [:index, :list_deferred]
|
||||||
append_before_filter :set_group_view_by, :only => [:index, :tag, :create, :list_deferred, :destroy, :defer, :update, :toggle_check]
|
|
||||||
|
|
||||||
protect_from_forgery :except => :check_deferred
|
protect_from_forgery :except => :check_deferred
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ module TodosHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_grouped_todos
|
def show_grouped_todos(settings = {})
|
||||||
collection = (@group_view_by == 'context') ? @contexts_to_show : @projects_to_show
|
collection = (@group_view_by == 'context') ? @contexts_to_show : @projects_to_show
|
||||||
render(:partial => collection, :locals => { :settings => {
|
render(:partial => collection, :locals => { :settings => settings.reverse_merge!({
|
||||||
:collapsible => true,
|
:collapsible => true,
|
||||||
:show_empty_containers => @show_empty_containers,
|
:show_empty_containers => @show_empty_containers,
|
||||||
:parent_container_type => @group_view_by
|
:parent_container_type => @group_view_by
|
||||||
}})
|
})})
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_collection_settings
|
def default_collection_settings
|
||||||
|
|
@ -80,14 +80,14 @@ module TodosHelper
|
||||||
:locals => {:settings => settings.reverse_merge!(default_collection_settings)}
|
:locals => {:settings => settings.reverse_merge!(default_collection_settings)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_todos_without_project(todos_without_project)
|
def show_todos_without_project(todos_without_project, settings = {})
|
||||||
render :partial => 'todos/collection',
|
render :partial => 'todos/collection',
|
||||||
:object => todos_without_project,
|
:object => todos_without_project,
|
||||||
:locals => {:settings => {
|
:locals => {:settings => settings.reverse_merge!({
|
||||||
:collapsible => true,
|
:collapsible => true,
|
||||||
:container_name => "without_project",
|
:container_name => "without_project",
|
||||||
:parent_container_type => "home"
|
:parent_container_type => "home"
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# invalidate the cache every day because of staleness or
|
# invalidate the cache every day because of staleness or
|
||||||
# rendering of "due in x days" that change without touching updated at of the todo
|
# rendering of "due in x days" that change without touching updated at of the todo
|
||||||
cache [context, @source_view, current_user.date.strftime("%Y%m%d"), @tag_name] do
|
cache [context, @source_view, current_user.date.strftime("%Y%m%d"), @tag_name] do
|
||||||
%>
|
-%>
|
||||||
<%=
|
<%=
|
||||||
render :partial => 'todos/collection',
|
render :partial => 'todos/collection',
|
||||||
:object => @not_done,
|
:object => @not_done,
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,13 @@
|
||||||
suffix_completed = t('contexts.last_completed_in_context', :number=>prefs.show_number_completed)
|
suffix_completed = t('contexts.last_completed_in_context', :number=>prefs.show_number_completed)
|
||||||
deferred_pending_options = {:append_descriptor => nil, :parent_container_type => 'context'}
|
deferred_pending_options = {:append_descriptor => nil, :parent_container_type => 'context'}
|
||||||
done_todo_options = {:append_descriptor => suffix_completed, :suppress_context => true, :parent_container_type => 'context'}
|
done_todo_options = {:append_descriptor => suffix_completed, :suppress_context => true, :parent_container_type => 'context'}
|
||||||
|
show_empty_containers = (@group_view_by == 'context')
|
||||||
-%>
|
-%>
|
||||||
<div id="display_box">
|
<div id="display_box">
|
||||||
<%= render :partial => @context, :locals => { :settings => {:collapsible => false, :show_empty_containers => true, :parent_container_type => 'context' }} %>
|
<%= show_grouped_todos({:collapsible => false, :show_empty_containers => show_empty_containers, :parent_container_type => 'context'}) %>
|
||||||
|
<% if @group_view_by == 'project' -%>
|
||||||
|
<%= show_todos_without_project(@todos_without_project, {:collapsible => false, :parent_container_type => 'context', :title_param => @context.name}) -%>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,8 @@
|
||||||
@not_done = @not_done_todos.select {|t| t.project_id == project.id }
|
@not_done = @not_done_todos.select {|t| t.project_id == project.id }
|
||||||
# invalidate the cache every day because of staleness or
|
# invalidate the cache every day because of staleness or
|
||||||
# rendering of "due in x days" that change without touching updated at of the todo
|
# rendering of "due in x days" that change without touching updated at of the todo
|
||||||
cache [project, @source_view, current_user.date.strftime("%Y%m%d")] do
|
cache [project, @source_view, current_user.date.strftime("%Y%m%d"), @tag_name] do
|
||||||
-%>
|
-%>
|
||||||
<% if source_view_is :project -%>
|
|
||||||
<%= render :partial => "project_settings_container", :locals => {:project => project} %>
|
|
||||||
<% end -%>
|
|
||||||
<%=
|
<%=
|
||||||
title = source_view_is(:project) ? t('projects.actions_in_project_title') : show_project_name(project)
|
title = source_view_is(:project) ? t('projects.actions_in_project_title') : show_project_name(project)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,18 @@
|
||||||
:suppress_project => true,
|
:suppress_project => true,
|
||||||
:parent_container_type => 'project'
|
:parent_container_type => 'project'
|
||||||
}
|
}
|
||||||
|
if @not_done_todos.count == 0
|
||||||
|
# force project view so one empty container will be shown with an empty message
|
||||||
|
@group_view_by = 'project'
|
||||||
|
end
|
||||||
|
show_empty_containers = (@group_view_by == 'project')
|
||||||
-%>
|
-%>
|
||||||
<div id="display_box">
|
<div id="display_box">
|
||||||
<%= project_next_prev %>
|
<%= project_next_prev %>
|
||||||
|
|
||||||
<%= render :partial => @project, :locals => {:settings => {:collapsible => false, :show_empty_containers => true, :parent_container_type => 'project' }} %>
|
<%= render :partial => "project_settings_container", :locals => {:project => @project} %>
|
||||||
|
|
||||||
|
<%= show_grouped_todos({:collapsible => false, :show_empty_containers => show_empty_containers, :parent_container_type => 'project' }) %>
|
||||||
|
|
||||||
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
<%= show_deferred_pending_todos(@deferred_todos, @pending_todos, deferred_pending_options) %>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,7 @@ en:
|
||||||
home_completed: Completed actions
|
home_completed: Completed actions
|
||||||
tag_completed: "Completed actions tagged with '%{param}'"
|
tag_completed: "Completed actions tagged with '%{param}'"
|
||||||
home_without_project: "Actions without project"
|
home_without_project: "Actions without project"
|
||||||
|
context_without_project: "Actions without project in %{param}"
|
||||||
project_project: "Actions in this project"
|
project_project: "Actions in this project"
|
||||||
project_deferred_pending: Deferred/pending actions in this project
|
project_deferred_pending: Deferred/pending actions in this project
|
||||||
context_deferred_pending: Deferred/pending actions in this context
|
context_deferred_pending: Deferred/pending actions in this context
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue