tracks/app/views/todos/create_multiple.js.rjs

42 lines
No EOL
2 KiB
Text

if @saved
page.hide 'status'
status_message = 'Added new next action'
status_message += 's' if @todos.size > 1
status_message = 'Added new project / ' + status_message if @new_project_created
status_message = 'Added new context / ' + status_message if @new_context_created
page.notify :notice, status_message, 5.0
page['badge_count'].replace_html @down_count
# reset form and set focus to first field
page.send :record, "$('#todo-form-multi-new-action').clearForm();$('#todo-form-multi-new-action input:text:first').focus();"
# set defaults of form
page.send :record, "$('#multi_todo_context_name').val('#{@initial_context_name}');"
page.send :record, "$('#multi_todo_project_name').val('#{@initial_project_name}');"
page.send :record, "$('#multi_tag_list').val('#{@default_tags}');"
if should_show_new_item()
if @new_context_created
page.insert_html :top, 'display_box', :partial => 'contexts/context', :locals => { :context => @todo.context, :collapsible => true }
else
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@todo.context_id}" if source_view_is_one_of(:todo, :deferred, :tag)
@todos.each do |todo|
page.insert_html :bottom, item_container_id(todo), :partial => 'todos/todo', :locals => { :todo => todo, :parent_container_type => parent_container_type, :source_view => @source_view }
page.visual_effect :highlight, dom_id(todo), :duration => 3
end
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
end
if (source_view_is :project and @todo.pending?) or (source_view_is :deferred)
page['tickler-empty-nd'].hide # For some reason this does not work: page['tickler-empty-nd'].hide if (@todo.pending? or (source_view_is :deferred))
end
end
# make sure the behavior of the new/updated todo is enabled
page << "enable_rich_interaction();"
else
page.show 'status'
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"
end