mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-30 12:45:18 +01:00
fix clearing show_from fails
caused by slightly different (better) workings of aasm
This commit is contained in:
parent
883ea2b968
commit
f891ee86fe
8 changed files with 80 additions and 32 deletions
|
|
@ -4,12 +4,28 @@ module Todos
|
|||
attr_reader :new_project_created, :new_context_created
|
||||
|
||||
def initialize(params, user)
|
||||
@params = params['request'] || params
|
||||
@attributes = params['request'] && params['request']['todo'] || params['todo']
|
||||
@attributes = {} if @attributes.nil? # make sure there is at least an empty hash
|
||||
set_params(params)
|
||||
filter_attributes
|
||||
filter_tags
|
||||
filter_starred
|
||||
|
||||
@user = user
|
||||
@errors = []
|
||||
|
||||
@new_project_created = find_or_create_group(:project, user.projects, project_name)
|
||||
@new_context_created = find_or_create_group(:context, user.contexts, context_name)
|
||||
end
|
||||
|
||||
def set_params(params)
|
||||
@params = params['request'] || params
|
||||
end
|
||||
|
||||
def filter_attributes
|
||||
@attributes = @params['request'] && @params['request']['todo'] || @params['todo']
|
||||
@attributes = {} if @attributes.nil? # make sure there is at least an empty hash
|
||||
end
|
||||
|
||||
def filter_tags
|
||||
if @attributes[:tags]
|
||||
# for single tags, @attributed[:tags] returns a hash. For multiple tags,
|
||||
# it with return an array of hashes. Make sure it is always an array of hashes
|
||||
|
|
@ -18,11 +34,13 @@ module Todos
|
|||
@attributes[:add_tags] = @attributes[:tags]
|
||||
@attributes.delete :tags
|
||||
end
|
||||
end
|
||||
|
||||
@new_project_created = find_or_create_group(:project, user.projects, project_name)
|
||||
@new_context_created = find_or_create_group(:context, user.contexts, context_name)
|
||||
@attributes["starred"] = (params[:new_todo_starred]||"").include? "true" if params[:new_todo_starred]
|
||||
end
|
||||
def filter_starred
|
||||
if @params[:new_todo_starred]
|
||||
@attributes["starred"] = (@params[:new_todo_starred]||"").include? "true"
|
||||
end
|
||||
end
|
||||
|
||||
def attributes
|
||||
@attributes
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class TodosController < ApplicationController
|
|||
@predecessor = todo
|
||||
end
|
||||
else
|
||||
@todos = @todos_init
|
||||
@todos = @build_todos
|
||||
@saved = false
|
||||
end
|
||||
|
||||
|
|
@ -194,6 +194,8 @@ class TodosController < ApplicationController
|
|||
determine_down_count if @saved
|
||||
@contexts = current_user.contexts if p.new_context_created
|
||||
@projects = current_user.projects if p.new_project_created
|
||||
@new_project_created = p.new_project_created
|
||||
@new_context_created = p.new_context_created
|
||||
@initial_context_name = params['default_context_name']
|
||||
@initial_project_name = params['default_project_name']
|
||||
@initial_tags = params['initial_tag_list']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue