mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 06:21:49 +01:00
Make contexts appear and disappear on the home page as items are added/deleted/marked complete. Fixes #313.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@285 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
8c7079dba5
commit
91f272a672
14 changed files with 26 additions and 14 deletions
|
|
@ -94,6 +94,7 @@ class TodoController < ApplicationController
|
|||
@item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working
|
||||
@saved = @item.save
|
||||
@on_page = "home"
|
||||
@remaining_undone_in_context = Todo.count(:conditions => ['user_id = ? and context_id = ? and type = ? and done = ?', @user.id, @item.context_id, "Immediate", false])
|
||||
if @saved
|
||||
@down_count = @todos.collect { |x| ( !x.done? and !x.context.hide? ) ? x:nil }.compact.size.to_s
|
||||
end
|
||||
|
|
@ -181,9 +182,11 @@ class TodoController < ApplicationController
|
|||
def destroy_action
|
||||
self.init
|
||||
@item = check_user_return_item
|
||||
context_id = @item.context_id
|
||||
|
||||
@saved = @item.destroy
|
||||
@on_page = "home"
|
||||
@remaining_undone_in_context = Todo.count(:conditions => ['user_id = ? and context_id = ? and type = ? and done = ?', @user.id, context_id, "Immediate", false])
|
||||
if @saved
|
||||
self.init
|
||||
@down_count = @todos.reject { |x| x.done? or x.context.hide? }.size.to_s
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<%= link_to( sanitize("#{context.name}"), { :controller => "context", :action => "show", :name => urlize(context.name) }, { :title => "Go to the #{context.name} context page" } ) %>
|
||||
</h2>
|
||||
<div id="c<%= context.id %>items" class="items toggle_target">
|
||||
<div id="empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
|
||||
<div id="c<%= context.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
|
||||
<div class="message"><p>Currently there are no uncompleted actions in this context</p></div>
|
||||
</div>
|
||||
<%= render :partial => "todo/item", :collection => @not_done %>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if @saved
|
|||
page.send :record, "Form.reset('todo-form-new-action-lightbox');Form.focusFirstElement('todo-form-new-action-lightbox')"
|
||||
page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page.hide "empty-nd" # If we are adding an new action, the uncompleted actions must be > 0
|
||||
page["c#{@item.context_id}empty-nd"].hide # If we are adding an new action, the uncompleted actions must be > 0
|
||||
else
|
||||
page.hide "status"
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ if @saved
|
|||
page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4
|
||||
page.replace_html "badge_count", @down_count
|
||||
if @down_count == "0"
|
||||
page.show 'empty-nd'
|
||||
page["c#{@item.context_id}empty-nd").show
|
||||
end
|
||||
else
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ if @saved
|
|||
page.insert_html :top, "completed", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
if @down_count == '0'
|
||||
page.show "empty-nd"
|
||||
page["c#{@item.context_id}empty-nd"].show
|
||||
end
|
||||
page.hide "empty-d" # If we've checked something as done, completed items can't be empty
|
||||
end
|
||||
else
|
||||
page.call "ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
if @done_count == '0'
|
||||
page.show "empty-d"
|
||||
end
|
||||
page.hide "empty-nd" # If we've checked something as undone, uncompleted items can't be empty
|
||||
page["c#{@item.context_id}empty-nd"].hide # If we've checked something as undone, uncompleted items can't be empty
|
||||
end
|
||||
page.hide "status"
|
||||
page.replace_html "badge_count", @down_count
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<p class="project_completed">Project has been marked as completed</p>
|
||||
<% end -%>
|
||||
<div class="items toggle_target">
|
||||
<div id="empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
|
||||
<div id="p<%= project.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
|
||||
<div class="message"><p>Currently there are no uncompleted actions in this project</p></div>
|
||||
</div>
|
||||
<%= render :partial => "todo/item", :collection => @not_done %>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if @saved
|
|||
page.send :record, "Form.reset('todo-form-new-action-lightbox');Form.focusFirstElement('todo-form-new-action-lightbox')"
|
||||
page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page.hide "empty-nd" # If we are adding an new action, the uncompleted actions must be > 0
|
||||
page.hide "p#{@item.project_id}empty-nd" # If we are adding an new action, the uncompleted actions must be > 0
|
||||
else
|
||||
page.hide "status"
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ if @saved
|
|||
page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4
|
||||
page.replace_html "badge_count", @down_count
|
||||
if @down_count == "0"
|
||||
page.show 'empty-nd'
|
||||
page["p#{@item.project_id}empty-nd"].show
|
||||
end
|
||||
else
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ if @saved
|
|||
page.insert_html :top, "completed", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
if @down_count == '0'
|
||||
page.show "empty-nd"
|
||||
page["p#{@item.project_id}empty-nd"].show
|
||||
end
|
||||
page.hide "empty-d" # If we've checked something as done, completed items can't be empty
|
||||
end
|
||||
else
|
||||
page.call "ensureVisibleWithEffectAppear", "p#{@item.project_id}"
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "p#{@item.project_id}"
|
||||
page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
if @done_count == '0'
|
||||
page.show "empty-d"
|
||||
end
|
||||
page.hide "empty-nd" # If we've checked something as undone, uncompleted items can't be empty
|
||||
page["p#{@item.project_id}empty-nd"].hide # If we've checked something as undone, uncompleted items can't be empty
|
||||
end
|
||||
page.hide "status"
|
||||
page.replace_html "badge_count", @down_count
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2>Deferred actions</h2>
|
||||
|
||||
<div class="items toggle_target">
|
||||
<div id="empty-nd" style="display:<%= @tickles.empty? ? 'block' : 'none'%>;">
|
||||
<div id="tickler-empty-nd" style="display:<%= @tickles.empty? ? 'block' : 'none'%>;">
|
||||
<div class="message"><p>Currently there are no deferred actions</p></div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ if @saved
|
|||
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
|
||||
page.insert_html :bottom, "tickler", :partial => 'todo/tickle', :object => @item
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page["tickler-empty-nd"].hide
|
||||
else
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
page.visual_effect :appear, 'status', :duration => 0.5
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ if @saved
|
|||
page['badge_count'].replace_html @up_count
|
||||
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
|
||||
page.send :record, "Form.reset('todo-form-new-action-lightbox');Form.focusFirstElement('todo-form-new-action-lightbox')"
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page["c#{@item.context_id}empty-nd"].hide
|
||||
else
|
||||
page.hide "status"
|
||||
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
if @saved
|
||||
page["item-#{@item.id}-container"].remove
|
||||
page['badge_count'].replace_html @down_count
|
||||
if @remaining_undone_in_context == 0
|
||||
page.visual_effect :fade, "c#{@item.context_id}", :duration => 0.4
|
||||
end
|
||||
else
|
||||
page["status"].replace_html content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation")
|
||||
end
|
||||
|
|
@ -9,8 +9,11 @@ if @saved
|
|||
page.insert_html :top, "completed", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
end
|
||||
if @remaining_undone_in_context == 0
|
||||
page.visual_effect :fade, "c#{@item.context_id}", :duration => 0.4
|
||||
end
|
||||
else
|
||||
page.call "ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue