diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 85d763be..83142d0e 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -115,8 +115,8 @@ class TodoController < ApplicationController item.toggle!('done') if item.save - flash["confirmation"] = "Next action \"#{item.description}\" marked as completed" - redirect_to( :action => "list" ) + #flash["confirmation"] = "Next action \"#{item.description}\" marked as completed" + #redirect_to( :action => "list" ) else flash["warning"] = "Couldn't mark action \"#{item.description}\" as completed" redirect_to( :action => "list" ) diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 9d080d2f..b1269b42 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -3,9 +3,23 @@ <%= stylesheet_link_tag "standard" %> <%= javascript_include_tag "toggle_notes" %> + <%= javascript_include_tag "calendar" %> <%= @page_title %> + + +
diff --git a/tracks/app/views/todo/_not_done.rhtml b/tracks/app/views/todo/_not_done.rhtml index 2c92307c..0e8c2a06 100644 --- a/tracks/app/views/todo/_not_done.rhtml +++ b/tracks/app/views/todo/_not_done.rhtml @@ -1,8 +1,6 @@ <% @notdone_item = not_done %> - - - - <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@notdone_item.id}'" ) %> + + <%= check_box( "item", "done", "onclick" => "markItemDone('action-#{@notdone_item.id}', '/todo/toggle_check/#{@notdone_item.id}', '#{@notdone_item.id}')" ) %> <%= link_image_to( "edit", { :action => "edit", :id => @notdone_item.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @notdone_item.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete this entry: #{@notdone_item.description}" ) + " " %> <%= due_date( @notdone_item.due ) %> <%= @notdone_item.description %> diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index 208f0e98..b6d89171 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -11,9 +11,17 @@ <% end %> <% end %> +
+

Just done

+ + +
+
+

Last 5 completed actions

+ <%= render_collection_of_partials "done", @done %>
@@ -28,11 +36,44 @@
+ +
+ + + + +
+ + + + + + + + + + + + + +
SunMonTueWedThuFriSat
+
+ +
<%= render_partial "todo/item", @item %>
+
+ + <% if @flash["confirmation"] %>
<%= @flash["confirmation"] %>
<% end %> <% if @flash["warning"] %>
<%= @flash["warning"] %>
<% end %> diff --git a/tracks/doc/CHANGENOTES.txt b/tracks/doc/CHANGENOTES.txt index 6d161d39..6f734d5e 100644 --- a/tracks/doc/CHANGENOTES.txt +++ b/tracks/doc/CHANGENOTES.txt @@ -15,6 +15,8 @@ Project wiki: 1. Added back border="0" to images which I had mistakenly taken out (thanks, Adam Hughes) 2. Removed the section in config/environment.rb which requires Redcloth. This was causing errors because Rails now requires Redcloth itself. This means that you now need to have Redcloth installed as a gem (gem install redcloth) (thanks, Jim). 3. Fixed SQLite dump format in db/tracks_1.0.2_sqlite.sql (thanks, Jim) +4. Added a mini-calendar to the todo/list page. Needs some tidying up, but it provides a quick way to look up a date a few months ahead. Note that it doesn't insert the date: it's just for viewing. I modified the calendar a little bit from here: +5. Added some XMLHTTPRequest calls to speed up checking off an item as done. It grabs the checked item and appends it immediately to a 'holding' section (where you can uncheck it again if it was a mistake, or add a closing note). When you next refresh the page, it will be added to the 'Last 5 completed items' section. ## Version 1.02 diff --git a/tracks/public/javascripts/calendar.js b/tracks/public/javascripts/calendar.js new file mode 100644 index 00000000..f7c434fe --- /dev/null +++ b/tracks/public/javascripts/calendar.js @@ -0,0 +1,69 @@ +/* Today's date */ +var DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +var lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +var moty = ["January","February","March","April","May","June","July","August","September","October","November","December"]; + +function Calendar_get_daysofmonth(monthNo, p_year) { + if ((p_year % 4) == 0) { + if ((p_year % 100) == 0 && (p_year % 400) != 0) + return DOMonth[monthNo]; + return lDOMonth[monthNo]; + } else + return DOMonth[monthNo]; +} + +function getNextMonth(m,y,incr){ + var ret_arr = new Array(); + ret_arr[0] = m + incr; ret_arr[1] = y; + if (ret_arr[0] == 12){ ret_arr[0]=0; ret_arr[1]=ret_arr[1]+1; } + if (ret_arr[0] == -1){ ret_arr[0]=11; ret_arr[1]=ret_arr[1]-1; } + return ret_arr; +} +function figureDOTW(m,d,y){ + var tDate = new Date(); tDate.setDate(d); tDate.setMonth(m); tDate.setYear(y); return tDate.getDay(); +} +function scramKids(n){ // this is a basic removeChild loop for removing all childNodes from node n + var numKids = n.childNodes.length; + for (i=0;i monthNo) // if this is the first row.... + calTDtext = document.createElement('br'); + else { + calTDtext = document.createTextNode(dayCount.toString()); + + if (dayCount == curr_dy && m == curr_mn && y == curr_yr) + calTD.style.color = '#ff6600'; + dayCount++; + } + calTD.appendChild(calTDtext); + calTD.setAttribute('width','14%'); + calTR.appendChild(calTD); + } + calTB.appendChild(calTR); + } + + var nMonth = getNextMonth(m,y,+1); + var pMonth = getNextMonth(m,y,-1); + + document.getElementById('pyNav').innerHTML = '<<'; + document.getElementById('pmNav').innerHTML = '<'; + document.getElementById('myNav').innerHTML = moty[m] +' '+y; + document.getElementById('nyNav').innerHTML = '>>'; + document.getElementById('nmNav').innerHTML = '>'; +} \ No newline at end of file diff --git a/tracks/public/javascripts/toggle_notes.js b/tracks/public/javascripts/toggle_notes.js index 21ec62fd..8633efe6 100644 --- a/tracks/public/javascripts/toggle_notes.js +++ b/tracks/public/javascripts/toggle_notes.js @@ -1,13 +1,57 @@ -function toggleAll(itemname,state) -{ - tmp = document.getElementsByTagName('div'); -   for (i=0;i +// + +function createXMLHttpRequest() { + try { + // Attempt to create it "the Mozilla way" + if (window.XMLHttpRequest) { + return new XMLHttpRequest(); + } + // Guess not - now the IE way + if (window.ActiveXObject) { + return new ActiveXObject(getXMLPrefix() + ".XmlHttp"); + } + } + catch (ex) {} + return false; +}; + +// Move item from uncompleted to completed +// Many thanks to Michelle at PXL8 for a great tutorial: +// +function moveRow(id){ + // -- get the table row correstponding to the selected item + var m1 = document.getElementById(id); + if (m1) + // -- append it to the 1st tbody of table id="holding" + document.getElementById('holding').getElementsByTagName('tbody')[0].appendChild(m1); +} + +function markItemDone(rowId, uri, id) { + var req = createXMLHttpRequest(); + moveRow(rowId); + + if(!req) { + return false; + } + + req.open("POST", uri, true); //POST asynchronously + req.setRequestHeader('Content-Type', 'application/x-www-form-url-encoded; charset=UTF-8'); + req.onreadystatechange = function() { + if (req.readyState == 4 && req.status == 200) { + } + } + req.send(encodeURIComponent("id") + '=' + encodeURIComponent(id)); +};