From 3f14a7a8bbe938f288f1e101a73fb32a309b0380 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Thu, 4 Mar 2010 16:42:23 -0500 Subject: [PATCH 1/5] Respect user's week start preference Fixes #1005 --- app/views/layouts/standard.html.erb | 1 + public/javascripts/application.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb index 11ebb9d8..223efb41 100644 --- a/app/views/layouts/standard.html.erb +++ b/app/views/layouts/standard.html.erb @@ -30,6 +30,7 @@ var defaultTags = <%= default_tags_for_autocomplete %>; var tagNames = <%= tag_names_for_autocomplete %>; var dateFormat = '<%= date_format_for_date_picker %>'; + var weekStart = '<%= current_user.prefs.week_starts %>'; <% end -%> <% if @prefs.refresh != 0 -%> setup_auto_refresh(<%= @prefs["refresh"].to_i*60000 %>); diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ca39f728..ccdab0ae 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -185,7 +185,7 @@ function project_defaults(){ } function enable_rich_interaction(){ - $('input.Date').datepicker({'dateFormat': dateFormat}); + $('input.Date').datepicker({'dateFormat': dateFormat, 'firstDay': weekStart}); /* Autocomplete */ $('input[name=context_name]').autocomplete(contextNames, {matchContains: true}); $('input[name=project[default_context_name]]').autocomplete(contextNames, {matchContains: true}); From 0778284afe9a025a570647ac5394db34bbfff81a Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sat, 6 Mar 2010 15:42:20 -0500 Subject: [PATCH 2/5] Cleaner form clearing for new recurring todos Just replace the entire HTML to make sure it works right Fixes #1003, Fixes #1004 --- app/controllers/recurring_todos_controller.rb | 4 ++-- app/views/recurring_todos/_recurring_todo_form.erb | 5 ++--- app/views/recurring_todos/create.js.rjs | 3 +-- public/javascripts/application.js | 2 -- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/controllers/recurring_todos_controller.rb b/app/controllers/recurring_todos_controller.rb index be659b3a..2bfcdc3b 100644 --- a/app/controllers/recurring_todos_controller.rb +++ b/app/controllers/recurring_todos_controller.rb @@ -2,7 +2,7 @@ class RecurringTodosController < ApplicationController helper :todos, :recurring_todos - append_before_filter :init, :only => [:index, :new, :edit] + append_before_filter :init, :only => [:index, :new, :edit, :create] append_before_filter :get_recurring_todo_from_param, :only => [:destroy, :toggle_check, :toggle_star, :edit, :update] def index @@ -243,7 +243,7 @@ class RecurringTodosController < ApplicationController private - def init + def init @days_of_week = [ ['Sunday',0], ['Monday',1], ['Tuesday', 2], ['Wednesday',3], ['Thursday',4], ['Friday',5], ['Saturday',6]] @months_of_year = [ ['January',1], ['Februari',2], ['March', 3], ['April',4], ['May',5], ['June',6], diff --git a/app/views/recurring_todos/_recurring_todo_form.erb b/app/views/recurring_todos/_recurring_todo_form.erb index ef724f33..4b3dc734 100644 --- a/app/views/recurring_todos/_recurring_todo_form.erb +++ b/app/views/recurring_todos/_recurring_todo_form.erb @@ -2,8 +2,7 @@ <% form_remote_tag( :url => recurring_todos_path, :method => :post, :html=> { :id=>'recurring-todo-form-new-action', :name=>'recurring_todo', :class => 'inline-form' }, - :before => "$('#recurring_todo_new_action_submit').block({message: null})", - :complete => "$('#recurring_todo_new_action_submit').unblock();$('#recurring-todo-form-new-action').clearForm();") do + :before => "$('#recurring_todo_new_action_submit').block({message: null})") do -%>
<%= error_messages_for("item", :object_name => 'action') %>
@@ -18,7 +17,7 @@ - + <%= text_field_tag "tag_list", nil, :size => 30, :tabindex => 5 -%> diff --git a/app/views/recurring_todos/create.js.rjs b/app/views/recurring_todos/create.js.rjs index 790e2fc9..4ef13703 100644 --- a/app/views/recurring_todos/create.js.rjs +++ b/app/views/recurring_todos/create.js.rjs @@ -4,8 +4,7 @@ page.replace_html 'new_status', "#{error_messages_for('recurring_todo')}" page.notify :notice, @message, 5.0 if @recurring_saved # reset form - page << "TracksForm.hide_all_recurring(); $('#recurring_daily').show();" - page << "$('#recurring_todo_new_action_submit').unblock();$('#recurring-todo-form-new-action').clearForm();" + page['new-recurring-todo'].replace_html :partial => 'recurring_todo_form' # hide overlayed edit form page << "TracksForm.toggle_overlay();" # insert new recurring todo diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ccdab0ae..51d31fae 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -359,7 +359,6 @@ $(document).ready(function() { }); $("#recurring_todo_new_action_cancel").click(function(){ - $('#recurring-todo-form-new-action').clearForm(); $('#recurring-todo-form-new-action input:text:first').focus(); TracksForm.hide_all_recurring(); $('#recurring_daily').show(); @@ -367,7 +366,6 @@ $(document).ready(function() { }); $("#recurring_todo_edit_action_cancel").live('click', function(){ - $('#recurring-todo-form-edit-action').clearForm(); $('#recurring-todo-form-edit-action input:text:first').focus(); TracksForm.hide_all_recurring(); $('#recurring_daily').show(); From 9591d29e7355ef02e14318442ab3de59d53fdb81 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sat, 6 Mar 2010 18:43:59 -0500 Subject: [PATCH 3/5] Fix refreshing of grandparent dependencies Closes #972 --- app/views/todos/add_predecessor.js.rjs | 7 +++++++ app/views/todos/remove_predecessor.js.rjs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/views/todos/add_predecessor.js.rjs b/app/views/todos/add_predecessor.js.rjs index dfe73a7d..ee5715a4 100644 --- a/app/views/todos/add_predecessor.js.rjs +++ b/app/views/todos/add_predecessor.js.rjs @@ -9,6 +9,13 @@ if @saved # regenerate predecessor to add arrow page[@predecessor].replace_html :partial => 'todos/todo', :locals => { :todo => @predecessor, :parent_container_type => parent_container_type } + # regenerate predecessors of predecessor + parents = @predecessor.predecessors + parents.each do |parent| + puts parent.description + page[parent].replace_html :partial => 'todos/todo', :locals => { :todo => parent, :parent_container_type => parent_container_type } + end + # show in tickler box in project view if source_view_is_one_of :project, :tag page['tickler-empty-nd'].hide diff --git a/app/views/todos/remove_predecessor.js.rjs b/app/views/todos/remove_predecessor.js.rjs index 734d24a6..944a829b 100644 --- a/app/views/todos/remove_predecessor.js.rjs +++ b/app/views/todos/remove_predecessor.js.rjs @@ -5,6 +5,13 @@ if @removed # replace old predecessor with one without the successor page.replace dom_id(@predecessor), :partial => 'todos/todo', :locals => { :todo => @predecessor, :parent_container_type => parent_container_type } + + # regenerate predecessors of predecessor + parents = @predecessor.predecessors + parents.each do |parent| + puts parent.description + page[parent].replace_html :partial => 'todos/todo', :locals => { :todo => parent, :parent_container_type => parent_container_type } + end # update display if pending->active if @successor.active? From ec68e04f2723682c5d4ab1aa08dbeb49cacf15ad Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sun, 7 Mar 2010 16:21:23 -0500 Subject: [PATCH 4/5] Move dependency drop target into image In preparation for #937 and other potential uses of drag&drop --- app/helpers/todos_helper.rb | 6 +- artwork/add_successor_on.svg | 179 ++++++++++++++++++++++++++++ artwork/predecessor.svg | 175 +++++++++++++++++++++++++++ public/images/add_successor_off.png | Bin 0 -> 801 bytes public/images/add_successor_on.png | Bin 0 -> 794 bytes public/javascripts/application.js | 15 ++- public/stylesheets/standard.css | 14 ++- 7 files changed, 378 insertions(+), 11 deletions(-) create mode 100644 artwork/add_successor_on.svg create mode 100644 artwork/predecessor.svg create mode 100644 public/images/add_successor_off.png create mode 100644 public/images/add_successor_on.png diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index d8fe0a51..57331e01 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -121,8 +121,10 @@ module TodosHelper def grip_span unless @todo.completed? image_tag('grip.png', :width => '7', :height => '16', :border => '0', - :title => 'Drag onto another action to make it depend on that action', - :class => 'grip') + :title => 'Drag onto another action to make it depend on that action', + :class => 'grip') + + image_tag('blank.png', :width => 16, :height => 16, :border => 0, + :title => "Drop an action to make it depend on this action", :class => 'successor_target') end end diff --git a/artwork/add_successor_on.svg b/artwork/add_successor_on.svg new file mode 100644 index 00000000..b7b3165c --- /dev/null +++ b/artwork/add_successor_on.svg @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/artwork/predecessor.svg b/artwork/predecessor.svg new file mode 100644 index 00000000..75e1ea1a --- /dev/null +++ b/artwork/predecessor.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/public/images/add_successor_off.png b/public/images/add_successor_off.png new file mode 100644 index 0000000000000000000000000000000000000000..183f1326da59fb9ce8dfc4de71f365f9c1e3dad6 GIT binary patch literal 801 zcmV++1K#|JP)A_TU&dEb1w4v{O4RQ_k3<{?vtzz{)F`O^mzOG z`)>>k4BU>#BFA>^5qk^um1XlS?|jYcmjiXs;m7n5siYcEaH z+*VcfLM#?bjE#*&L!nSO6bfCQo}PXKU=skSq9|t_$Eg!SuuLZNdVYTXk!4vK0GOSf zeZRG}b-%T>H5v|w&qX4U#uKqzF4q}`0o%5-rfGgH6biZOAE{I-RbOBK&Fl3>6-5bh z&RYl}@1&GAWsDJB*HJ7MA%qYB>c+>%uc@kf#qD+n7-KC52L~0-xt}pMGdVeVX<}kR ztFbH#x~?Oe%}UcWT~f-NX__AcfqW83NQ=< zLI~Kl4MK=ZO1V8aIC!^MEYjxY=Bs|cADnZf)9H=f-Q9-^3kz>4V+^{kqg*cI_|jw6 z*Vi|PhKBA4A!uV`Zzqt3ASzjS`MtPt|k+S#Jx-=V-iBX zD2no8e}A6?K#gTtFbo5^Tn?Ob{K@k2@`uC2!$`b`(W1 f(&@DPuLa--f+vKa3jVpwx}gdBNaMgZL5u;Go3lJoHJ+6nX`N@YQ)ln-}Uo* zlPB*(gb)CL#oG?Hnx4wNrl)#|&Al#GQVmy8e&sb&mtS1J_!8yd56Gsrw#xY2b$jIC z#=~-O^#apd1=s)>;3{TO_2t=U&1ld0Dd~6TdhbUQWs!etj2aQgm$ngD>N-N&E% zl7lDosS88J$~iNN)uH;bNU3djBs~jvek>zt$q$iOAzSX@)?&l{ne98GSt^H+X90?Msh1*A=)5X%MFb=4d}3 z-1qe1o7L+!A7PfxHGe~xl!}9XW#r84SkJAqLYSOc1#m45I3}oG_;nn3{`lU&lJy%g1;6Xg+aZ$A+aRpFFvd`MDfgQo)1+ z2pi1S@h3tE8xte^4bDm`h-E+sXX3!ZmcQi5p#PPc1TIlJ?g)EW5HU!FBYz#L5dYSI Y?{CsPln#@-BLDyZ07*qoM6N<$f&*G*_W%F@ literal 0 HcmV?d00001 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 51d31fae..0fa72903 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -209,7 +209,7 @@ function enable_rich_interaction(){ /* Drag & Drop for successor/predecessor */ function drop_todo(evt, ui) { dragged_todo = ui.draggable[0].id.split('_')[2]; - dropped_todo = this.id.split('_')[2]; + dropped_todo = $(this).parents('.item-show').get(0).id.split('_')[2]; ui.draggable.hide(); $(this).block({message: null}); $.post('/todos/add_predecessor', @@ -217,11 +217,14 @@ function enable_rich_interaction(){ null, 'script'); } - $('.item-show').draggable({handle: '.grip', revert: 'invalid'}); - $('.item-show').droppable({ - drop: drop_todo, - hoverClass: 'hover' - }); + $('.item-show').draggable({handle: '.grip', + revert: 'invalid', + start: function() {$('.successor_target').show();}, + stop: function() {$('.successor_target').hide();}}); + + $('.successor_target').droppable({drop: drop_todo, + tolerance: 'pointer', + hoverClass: 'hover'}); /* Reset auto updater */ field_touched = false; diff --git a/public/stylesheets/standard.css b/public/stylesheets/standard.css index c32a167a..58148f63 100644 --- a/public/stylesheets/standard.css +++ b/public/stylesheets/standard.css @@ -939,9 +939,17 @@ div.message { cursor: move; } -.hover { - background: #EAEAEA; - font-weight: bold; +.successor_target { + background-image:url("../images/add_successor_off.png"); + background-repeat: no-repeat; + background-position: center right; + display: none; +} + +.successor_target.hover { + background-image:url("../images/add_successor_on.png"); + background-repeat: no-repeat; + background-position: center right; } /* Error message styles */ From 42c4c199a9785d9d4680d6f7d8921efaa3a1c633 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Sun, 7 Mar 2010 16:54:17 -0500 Subject: [PATCH 5/5] Move edit button out of dropdown menu Closes #976 --- app/helpers/todos_helper.rb | 14 ++++++-------- app/views/todos/_todo.html.erb | 6 +++--- public/javascripts/application.js | 11 +++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 57331e01..8eafc567 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -24,14 +24,12 @@ module TodosHelper :class => "icon star_item", :title => "star the action '#{@todo.description}'") end - def remote_edit_menu_item(parameters, todo) - return link_to_remote( - image_tag("edit_off.png", :mouseover => "edit_on.png", :alt => "Edit", :align => "absmiddle", :id => 'edit_icon_todo_'+todo.id.to_s)+" Edit", - :url => {:controller => 'todos', :action => 'edit', :id => todo.id}, - :method => 'get', - :with => "'#{parameters}'", - :before => todo_start_waiting_js(todo), - :complete => todo_stop_waiting_js(todo)) + def remote_edit_button + link_to( + image_tag("blank.png", :alt => "Edit", :align => "absmiddle", :id => 'edit_icon_todo_'+@todo.id.to_s, :class => 'edit_item'), + {:controller => 'todos', :action => 'edit', :id => @todo.id}, + :class => "icon edit_item", + :title => "Edit the action '#{@todo.description}'") end def remote_delete_menu_item(parameters, todo) diff --git a/app/views/todos/_todo.html.erb b/app/views/todos/_todo.html.erb index 579ea766..4e325c8b 100644 --- a/app/views/todos/_todo.html.erb +++ b/app/views/todos/_todo.html.erb @@ -11,12 +11,12 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<%= remote_star_icon %> <%= remote_toggle_checkbox unless source_view_is :deferred %> + <% unless suppress_edit_button %> + <%= remote_edit_button %> + <% end %>
  • <%= image_tag "downarrow.png", :alt=> "" %>
      - <% unless suppress_edit_button %> -
    • <%= remote_edit_menu_item(parameters, todo) %>
    • - <% end %>
    • <%= remote_delete_menu_item(parameters, todo) %>
    • <% unless todo.completed? || todo.deferred? %>
    • <%= remote_defer_menu_item(1, todo) %>
    • diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 0fa72903..efacc608 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -310,6 +310,17 @@ $(document).ready(function() { $.post(this.value, params, null, 'script'); }); + /* set behavior for edit icon */ + $(".item-container a.edit_item").live('click', function (ev){ + itemContainer = $(this).parents(".item-container"); + $.ajax({ + url: this.href, + beforeSend: function() { itemContainer.block({message: null});}, + complete: function() { itemContainer.unblock();}, + dataType: 'script'}); + return false; + }); + setup_container_toggles(); $('#toggle_action_new').click(function(){