mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 22:41:48 +01:00
Enable converting active actions to deferred actions and vice versa by editing the show_from date. Fixes #396.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@359 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
85486a6233
commit
d57b313376
4 changed files with 19 additions and 13 deletions
|
|
@ -7,7 +7,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
acts_as_state_machine :initial => :active, :column => 'state'
|
||||
|
||||
state :active, :enter => Proc.new { |t| t.show_from = nil }
|
||||
state :active, :enter => Proc.new { |t| t[:show_from] = nil }
|
||||
state :project_hidden
|
||||
state :completed, :enter => Proc.new { |t| t.completed_at = Time.now() }, :exit => Proc.new { |t| t.completed_at = nil }
|
||||
state :deferred
|
||||
|
|
@ -29,7 +29,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
event :unhide do
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| t.show_from != nil}
|
||||
transitions :to => :deferred, :from => [:project_hidden], :guard => Proc.new{|t| !t.show_from.blank? }
|
||||
transitions :to => :active, :from => [:project_hidden]
|
||||
end
|
||||
|
||||
|
|
@ -58,6 +58,12 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def show_from=(date)
|
||||
activate! if deferred? && date.blank?
|
||||
defer! if active? && !date.blank? && date > Date.today()
|
||||
self[:show_from] = date
|
||||
end
|
||||
|
||||
alias_method :original_project, :project
|
||||
|
||||
def project
|
||||
|
|
|
|||
|
|
@ -38,12 +38,10 @@
|
|||
<td class="label"><label for="item_due">Due</td>
|
||||
<td><input name="item[due]" id="due_<%= @item.id %>" type="text" value="<%= format_date(@item.due) %>" tabindex="5" size="10" onFocus="Calendar.setup" autocomplete="off" class="Date" /></td>
|
||||
</tr>
|
||||
<% if @item.current_state == :deferred -%>
|
||||
<tr>
|
||||
<td class="label"><label for="item_show_from">Show from</td>
|
||||
<td><input name="item[show_from]" id="show_from_<%= @item.id %>" type="text" value="<%= format_date(@item.show_from) %>" tabindex="5" size="10" onFocus="Calendar.setup" autocomplete="off" class="Date" /></td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
<% if controller.controller_name == "project" || @item.deferred? -%>
|
||||
<input type="hidden" name="on_project_page" value="true" />
|
||||
<% end -%>
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ if @saved
|
|||
page.notify :notice, status_message, 5.0
|
||||
page['badge_count'].replace_html @down_count
|
||||
page.send :record, "Form.reset('todo-form-new-action');Form.focusFirstElement('todo-form-new-action')"
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}" if source_view_is(:todo)
|
||||
page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}" if @new_context_created
|
||||
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}" if @new_project_created
|
||||
page.insert_html :bottom, item_container_id, :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type, :source_view => @source_view }
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
|
||||
unless (source_view_is(:deferred) && !@item.deferred?) || (source_view_is(:project) && @item.project.hidden? && @item.project_hidden?) || (!source_view_is(:deferred) && @item.active)
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}" if source_view_is(:todo)
|
||||
page.insert_html :bottom, item_container_id, :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type, :source_view => @source_view }
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
|
||||
end
|
||||
else
|
||||
page.show 'status'
|
||||
page.replace_html 'status', "#{error_messages_for('item')}"
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ if @saved
|
|||
page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true" if @new_context_created
|
||||
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created
|
||||
if source_view_is_one_of [:todo, :context]
|
||||
if @context_changed
|
||||
if @context_changed || @item.deferred?
|
||||
page[item_container_id].remove
|
||||
if (@remaining_undone_in_original_context == 0)
|
||||
if (@remaining_undone_in_context == 0)
|
||||
source_view do |from|
|
||||
from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 }
|
||||
from.context { page.show "c#{@original_item_context_id}empty-nd" }
|
||||
end
|
||||
end
|
||||
if source_view_is :todo
|
||||
if source_view_is(:todo) && @item.active?
|
||||
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}"
|
||||
page.call "todoItems.expandNextActionListingByContext", "c#{@item.context_id}items", true
|
||||
page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'todo/item', :locals => { :parent_container_type => parent_container_type }
|
||||
|
|
@ -24,7 +24,7 @@ if @saved
|
|||
page.replace_html("badge_count", @remaining_undone_in_context) if source_view_is :context
|
||||
page.delay(0.5) do
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
|
||||
if source_view_is :todo
|
||||
if source_view_is(:todo) && @item.active?
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@item.context_id}items"
|
||||
page.visual_effect :highlight, item_container_id, :duration => 3
|
||||
end
|
||||
|
|
@ -34,7 +34,7 @@ if @saved
|
|||
page.visual_effect :highlight, item_container_id, :duration => 3
|
||||
end
|
||||
elsif source_view_is :project
|
||||
if @project_changed
|
||||
if @project_changed || @item.deferred?
|
||||
page[item_container_id].remove
|
||||
page.show("p#{@original_item_project_id}empty-nd") if (@remaining_undone_in_project == 0)
|
||||
page.replace_html "badge_count", @remaining_undone_in_project
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue