mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-24 16:14:07 +01:00
get tests running and fix editing context state
This commit is contained in:
parent
99eed9f638
commit
1e84adc91b
8 changed files with 27 additions and 17 deletions
|
|
@ -69,6 +69,7 @@ class ContextsController < ApplicationController
|
|||
return
|
||||
end
|
||||
@context = current_user.contexts.build(params['context'])
|
||||
@context.hide! if params['context_state']['hide'] == '1'
|
||||
@saved = @context.save
|
||||
@context_not_done_counts = { @context.id => 0 }
|
||||
respond_to do |format|
|
||||
|
|
@ -97,13 +98,22 @@ class ContextsController < ApplicationController
|
|||
|
||||
@original_context_hidden = @context.hidden?
|
||||
@context.attributes = params["context"]
|
||||
if params['context_state']
|
||||
if params['context_state']['hide'] == '1'
|
||||
@context.hide! if !@context.hidden?
|
||||
else
|
||||
@context.activate! if @context.hidden?
|
||||
end
|
||||
else
|
||||
@context.activate! if @context.hidden?
|
||||
end
|
||||
|
||||
@saved = @context.save
|
||||
|
||||
if @saved
|
||||
if boolean_param('wants_render')
|
||||
@state_changed = (@original_context_hidden != @context.hidden?)
|
||||
@new_state = (@context.hidden? ? "hidden" : "active") if @state_changed
|
||||
@new_state = @context.state if @state_changed
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class StatsController < ApplicationController
|
|||
all_actions_per_context = current_user.contexts.find_by_sql(
|
||||
"SELECT c.name AS name, c.id as id, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.hide "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.state='hidden' "+
|
||||
"AND c.user_id = #{current_user.id} " +
|
||||
"GROUP BY c.name, c.id "+
|
||||
"ORDER BY total DESC"
|
||||
|
|
@ -491,7 +491,7 @@ class StatsController < ApplicationController
|
|||
@running_actions_per_context = current_user.contexts.find_by_sql(
|
||||
"SELECT c.id AS id, c.name AS name, count(*) AS total "+
|
||||
"FROM contexts c, todos t "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.hide "+
|
||||
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.state='hidden' "+
|
||||
"AND t.user_id=#{current_user.id} " +
|
||||
"GROUP BY c.id, c.name ORDER BY total DESC " +
|
||||
"LIMIT 5"
|
||||
|
|
|
|||
|
|
@ -692,7 +692,7 @@ class TodosController < ApplicationController
|
|||
|
||||
@projects = current_user.projects
|
||||
@contexts = current_user.contexts
|
||||
@contexts_to_show = @contexts.reject {|x| x.hide? }
|
||||
@contexts_to_show = @contexts.reject {|c| c.hidden? }
|
||||
|
||||
# Set defaults for new_action
|
||||
@initial_tags = @tag_name
|
||||
|
|
@ -999,7 +999,7 @@ class TodosController < ApplicationController
|
|||
context_id = @original_item_context_id || @todo.context_id
|
||||
todos = current_user.contexts.find(context_id).todos.not_completed
|
||||
|
||||
if @todo.context.hide?
|
||||
if @todo.context.hidden?
|
||||
# include hidden todos
|
||||
@down_count = todos.count
|
||||
else
|
||||
|
|
@ -1063,12 +1063,12 @@ class TodosController < ApplicationController
|
|||
@remaining_deferred_or_pending_count = context.todos.deferred_or_blocked.count
|
||||
|
||||
remaining_actions_in_context = context.todos(true).active
|
||||
remaining_actions_in_context = remaining_actions_in_context.not_hidden if !context.hide?
|
||||
remaining_actions_in_context = remaining_actions_in_context.not_hidden if !context.hidden?
|
||||
@remaining_in_context = remaining_actions_in_context.count
|
||||
|
||||
if @todo_was_deferred_or_blocked
|
||||
actions_in_target = current_user.contexts.find(@todo.context_id).todos(true).active
|
||||
actions_in_target = actions_in_target.not_hidden if !context.hide?
|
||||
actions_in_target = actions_in_target.not_hidden if !context.hidden?
|
||||
else
|
||||
actions_in_target = @todo.context.todos.deferred_or_blocked
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue