From efd838d9ac1112d3d4cd8bb64951b417a977f4b2 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Tue, 24 Nov 2009 20:39:56 +0100 Subject: give sort feedback --- poll.rb | 7 ++++--- pollhead.rb | 17 ++++++++++++----- timepollhead.rb | 13 +++++++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/poll.rb b/poll.rb index 7f315d8..b0c44ad 100644 --- a/poll.rb +++ b/poll.rb @@ -62,9 +62,10 @@ class Poll def to_html(edituser = "", showparticipation = true) ret = "\n" - - ret += @head.to_html - sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll| + + sortcolumns = $cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"] + ret += @head.to_html(sortcolumns) + sort_data(sortcolumns).each{|participant,poll| if edituser == participant ret += participate_to_html(edituser) else diff --git a/pollhead.rb b/pollhead.rb index a4a6b8a..87d2cb3 100644 --- a/pollhead.rb +++ b/pollhead.rb @@ -78,12 +78,19 @@ class PollHead end end - def to_html(showeditbuttons = false,activecolumn = nil) - ret = "\n" + def to_html(scols, showeditbuttons = false,activecolumn = nil) + def sortsymb(scols,col) + scols.include?(col) ? SORT : NOSORT + end + ret = "" + ret += "\n" unless showeditbuttons @data.each{|columntitle,columndescription| ret += "#{CGI.escapeHTML(columntitle)} #{NOSORT}" + ret += ">" + ret += "" unless showeditbuttons + ret += "#{CGI.escapeHTML(columntitle)}" + ret += " #{sortsymb(scols,columntitle)}" unless showeditbuttons if showeditbuttons ret += < @@ -100,7 +107,7 @@ EDITDELETE end ret += "" } - ret += "\n" + ret += "\n" unless showeditbuttons ret += "\n" ret end @@ -126,7 +133,7 @@ EDITDELETE
Preview
Name #{NOSORT}
Name #{sortsymb(scols,"name")}Last Edit #{NOSORT}Last Edit #{sortsymb(scols,"timestamp")}
-#{to_html(true,activecolumn)} +#{to_html([],true,activecolumn)}
END diff --git a/timepollhead.rb b/timepollhead.rb index 4b4d619..4521f26 100644 --- a/timepollhead.rb +++ b/timepollhead.rb @@ -172,7 +172,7 @@ class TimePollHead } ret.sort end - def to_html(config = false,activecolumn = nil) + def to_html(scols,config = false,activecolumn = nil) ret = "" head_count("%Y-%m",false).each{|title,count| year, month = title.split("-").collect{|e| e.to_i} @@ -183,11 +183,16 @@ class TimePollHead head_count("%Y-%m-%d",false).each{|title,count| ret += "#{Date.parse(title).strftime("%a, %d")}\n" } - ret += "Name #{NOSORT}" + + def sortsymb(scols,col) + scols.include?(col) ? SORT : NOSORT + end + + ret += "Name #{sortsymb(scols,"name")}" @data.sort.each{|date| - ret += "#{date.time_to_s} #{NOSORT}\n" + ret += "#{date.time_to_s} #{sortsymb(scols,date.to_s + " ")}\n" } - ret += "Last Edit #{NOSORT}\n\n" + ret += "Last Edit #{sortsymb(scols,"timestamp")}\n\n" ret end -- cgit v1.2.3