mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-20 09:10:12 +01:00
fix #1287. Fix various small bugs and some small improvements
This commit is contained in:
parent
88729f57ce
commit
bd8498f39c
10 changed files with 18 additions and 40 deletions
|
|
@ -100,11 +100,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_deferred_todos(todos_parent)
|
def count_deferred_todos(todos_parent)
|
||||||
if todos_parent.nil?
|
return todos_parent.nil? ? 0 : eval("@#{todos_parent.class.to_s.downcase}_deferred_counts[#{todos_parent.id}]") || 0
|
||||||
count = 0
|
|
||||||
else
|
|
||||||
count = todos_parent.todos.deferred.count
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a date object to the format specified in the user's preferences in
|
# Convert a date object to the format specified in the user's preferences in
|
||||||
|
|
@ -284,7 +280,8 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def init_not_done_counts(parents = ['project','context'])
|
def init_not_done_counts(parents = ['project','context'])
|
||||||
parents.each do |parent|
|
parents.each do |parent|
|
||||||
eval("@#{parent}_not_done_counts = @#{parent}_not_done_counts || current_user.todos.active.count(:group => :#{parent}_id)")
|
eval("@#{parent}_not_done_counts ||= current_user.todos.active.group('#{parent}_id').count")
|
||||||
|
eval("@#{parent}_deferred_counts ||= current_user.todos.deferred.group('#{parent}_id').count")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ class ContextsController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js do
|
format.js do
|
||||||
@down_count = current_user.contexts.size
|
@down_count = current_user.contexts.size
|
||||||
|
init_not_done_counts
|
||||||
end
|
end
|
||||||
format.xml do
|
format.xml do
|
||||||
if @context.new_record?
|
if @context.new_record?
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,8 @@ class IntegrationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_plugin
|
def search_plugin
|
||||||
# TODO: ASSET PATH!!
|
@icon_data = [File.open(File.join(Rails.root, 'app', 'assets', 'images', 'done.png')).read].
|
||||||
@icon_data = [File.open(Rails.root + '/app/assets/images/done.png').read].
|
|
||||||
pack('m').gsub(/\n/, '')
|
pack('m').gsub(/\n/, '')
|
||||||
|
|
||||||
render :layout => false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def google_gadget
|
def google_gadget
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,10 @@ class ProjectsController < ApplicationController
|
||||||
@contexts = current_user.contexts
|
@contexts = current_user.contexts
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js { @down_count = current_user.projects.size }
|
format.js do
|
||||||
|
@down_count = current_user.projects.size
|
||||||
|
init_not_done_counts
|
||||||
|
end
|
||||||
format.xml do
|
format.xml do
|
||||||
if @project.new_record?
|
if @project.new_record?
|
||||||
render_failure @project.errors.to_xml.html_safe, 409
|
render_failure @project.errors.to_xml.html_safe, 409
|
||||||
|
|
|
||||||
|
|
@ -11,26 +11,6 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
protect_from_forgery :except => :check_deferred
|
protect_from_forgery :except => :check_deferred
|
||||||
|
|
||||||
def with_parent_resource_scope(&block)
|
|
||||||
@feed_title = t('common.actions')
|
|
||||||
if (params[:context_id])
|
|
||||||
@context = current_user.contexts.find_by_params(params)
|
|
||||||
@feed_title = @feed_title + t('todos.feed_title_in_context', :context => @context.name)
|
|
||||||
Todo.send :where, ['todos.context_id = ?', @context.id] do
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
elsif (params[:project_id])
|
|
||||||
@project = current_user.projects.find_by_params(params)
|
|
||||||
@feed_title = @feed_title + t('todos.feed_title_in_project', :project => @project.name)
|
|
||||||
@project_feed = true
|
|
||||||
Todo.send :where, ['todos.project_id = ?', @project.id] do
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
else
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@source_view = params['_source_view'] || 'todo'
|
@source_view = params['_source_view'] || 'todo'
|
||||||
init_data_for_sidebar unless mobile?
|
init_data_for_sidebar unless mobile?
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ module ApplicationHelper
|
||||||
return content_tag(:li, t('sidebar.list_empty')).html_safe
|
return content_tag(:li, t('sidebar.list_empty')).html_safe
|
||||||
else
|
else
|
||||||
return list.inject("") do |html, item|
|
return list.inject("") do |html, item|
|
||||||
link = (item.class == "Project") ? link_to_project( item ) : link_to_context(item)
|
link = item.is_a?(Project) ? link_to_project( item ) : link_to_context(item)
|
||||||
html << content_tag(:li, link + " (" + count_undone_todos_phrase(item)+")")
|
html << content_tag(:li, link + " (" + count_undone_todos_phrase(item)+")")
|
||||||
end.html_safe
|
end.html_safe
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,12 @@ class Todo < ActiveRecord::Base
|
||||||
scope :active, :conditions => { :state => 'active' }
|
scope :active, :conditions => { :state => 'active' }
|
||||||
scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
|
scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
|
||||||
scope :not_completed, :conditions => ['NOT (todos.state = ?)', 'completed']
|
scope :not_completed, :conditions => ['NOT (todos.state = ?)', 'completed']
|
||||||
scope :completed, :conditions => ["NOT (todos.completed_at IS NULL)"]
|
scope :completed, :conditions => ["todos.state = ?", 'completed']
|
||||||
scope :deferred, :conditions => ["todos.completed_at IS NULL AND NOT (todos.show_from IS NULL)"]
|
scope :deferred, :conditions => ["todos.state = ?", 'deferred']
|
||||||
scope :blocked, :conditions => ['todos.state = ?', 'pending']
|
scope :blocked, :conditions => ['todos.state = ?', 'pending']
|
||||||
scope :pending, :conditions => ['todos.state = ?', 'pending']
|
scope :pending, :conditions => ['todos.state = ?', 'pending']
|
||||||
scope :deferred_or_blocked, :conditions => ["(todos.completed_at IS NULL AND NOT(todos.show_from IS NULL)) OR (todos.state = ?)", "pending"]
|
scope :deferred_or_blocked, :conditions => ["(todos.state = ?) OR (todos.state = ?)", "deferred", "pending"]
|
||||||
scope :not_deferred_or_blocked, :conditions => ["(todos.completed_at IS NULL) AND (todos.show_from IS NULL) AND (NOT todos.state = ?)", "pending"]
|
scope :not_deferred_or_blocked, :conditions => ["(NOT todos.state=?) AND (NOT todos.state = ?)", "deferred", "pending"]
|
||||||
scope :hidden,
|
scope :hidden,
|
||||||
:joins => "INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id",
|
:joins => "INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id",
|
||||||
:conditions => ["todos.state = ? OR (c_hidden.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
|
:conditions => ["todos.state = ? OR (c_hidden.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
</script>
|
</script>
|
||||||
<link rel="shortcut icon" href="<%= image_path ('favicon.ico') %>" />
|
<link rel="shortcut icon" href="<%= image_path ('favicon.ico') %>" />
|
||||||
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
|
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
|
||||||
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path %>" />
|
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path(:format => :xml) %>" />
|
||||||
<title><%= @page_title %></title>
|
<title><%= @page_title %></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ Tracksapp::Application.routes.draw do
|
||||||
match 'integrations' => "integrations#index"
|
match 'integrations' => "integrations#index"
|
||||||
match 'integrations/rest_api' => "integrations#rest_api", :as => 'rest_api_docs'
|
match 'integrations/rest_api' => "integrations#rest_api", :as => 'rest_api_docs'
|
||||||
match 'integrations/cloudmailin' => 'integrations#cloudmailin'
|
match 'integrations/cloudmailin' => 'integrations#cloudmailin'
|
||||||
match 'integrations/search_plugin.xml' => "integrations#search_plugin", :as => 'search_plugin'
|
match 'integrations/search_plugin' => "integrations#search_plugin", :as => 'search_plugin'
|
||||||
match 'integrations/google_gadget.xml' => 'integrations#google_gadget', :as => 'google_gadget'
|
match 'integrations/google_gadget.xml' => 'integrations#google_gadget', :as => 'google_gadget'
|
||||||
match 'integrations/get_applescript1.js' => 'integrations#get_applescript1'
|
match 'integrations/get_applescript1.js' => 'integrations#get_applescript1'
|
||||||
match 'integrations/get_applescript2.js' => 'integrations#get_applescript2'
|
match 'integrations/get_applescript2.js' => 'integrations#get_applescript2'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue