mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-31 05:05:18 +01:00
Web-service enable homepage actions by context listing using responds_to. Try it out using:
curl -H 'Accept: application/xml' --basic --user YOUR_TRACKS_USERNAME:YOUR_TRACKS_PASSWORD http://localhost:3000/ git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@257 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
c2fb93415c
commit
0765c801a4
2 changed files with 22 additions and 5 deletions
|
|
@ -6,10 +6,9 @@ class TodoController < ApplicationController
|
|||
|
||||
helper :todo
|
||||
|
||||
before_filter :login_required
|
||||
prepend_before_filter :login_required
|
||||
layout "standard"
|
||||
|
||||
|
||||
def index
|
||||
list
|
||||
render_action "list"
|
||||
|
|
@ -29,15 +28,19 @@ class TodoController < ApplicationController
|
|||
max_completed = @user.preferences["no_completed"].to_i-1
|
||||
@done = (max_completed > 0) ? @done[0..max_completed] : nil
|
||||
|
||||
@contexts_to_show = @contexts.clone
|
||||
@contexts_to_show = @contexts_to_show.collect {|x| (!x.hide? and !x.find_not_done_todos.empty?) ? x:nil }.compact
|
||||
@contexts_to_show = @contexts.reject {|x| x.hide? || x.find_not_done_todos.empty? }
|
||||
|
||||
if @contexts.empty?
|
||||
flash['warning'] = 'You must add at least one context before adding next actions.'
|
||||
end
|
||||
|
||||
# Set count badge to number of not-done, not hidden context items
|
||||
@count = @todos.collect { |x| ( !x.done? and !x.context.hide? ) ? x:nil }.compact.size
|
||||
@count = @todos.reject { |x| x.done? || x.context.hide? }.size
|
||||
|
||||
respond_to do |wants|
|
||||
wants.html
|
||||
wants.xml { render :action => 'list.rxml', :layout => false }
|
||||
end
|
||||
end
|
||||
|
||||
def update_element
|
||||
|
|
|
|||
14
tracks/app/views/todo/list.rxml
Normal file
14
tracks/app/views/todo/list.rxml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
@headers["Content-Type"] = "text/xml; charset=utf-8"
|
||||
xml.todos_by_context do
|
||||
@contexts_to_show.each { |c|
|
||||
xml.context do
|
||||
xml.name c.name
|
||||
xml.hide c.hide, :type => :boolean
|
||||
xml.id c.id, :type => :integer
|
||||
xml.position c.position, :type => :integer
|
||||
c.find_not_done_todos.each { |t|
|
||||
xml << t.to_xml( :skip_instruct => true, :root => 'todo', :except => [:user_id, :context_id] )
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue