From 26450dd0e16d33519bf89e7d057bbb400f3793a0 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Tue, 24 Nov 2009 00:08:29 +0100 Subject: undo and redo seems to work now --- edit_columns.rb | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'edit_columns.rb') diff --git a/edit_columns.rb b/edit_columns.rb index 944c29f..ff584e7 100755 --- a/edit_columns.rb +++ b/edit_columns.rb @@ -49,7 +49,9 @@ revbeforeedit = VCS.revno if $cgi.include?("undo_revision") && $cgi["undo_revision"].to_i < revbeforeedit undorevision = $cgi["undo_revision"].to_i table = YAML::load(VCS.cat(undorevision, "data.yaml")) - table.store("Reverted Poll to version #{undorevision}") + comment = "Reverted Poll" + comment = "Redo changes" if $cgi.include?("redo") + table.store("#{comment} to version #{undorevision}") else table = YAML::load_file("data.yaml") end @@ -85,11 +87,14 @@ TABLE $html << table.edit_column_htmlform($cgi["editcolumn"],revno) $html << "
" -h = VCS.history.flatten +h = VCS.history +urevs = h.undorevisions +rrevs = h.redorevisions hidden = "" if $cgi.include?("add_remove_column_month") -if h.max - coltitle,action = h.max.comment.scan(/^Column (.*) (added|deleted|edited)$/).flatten +if urevs.max + urhist = urevs + coltitle,action = urevs.max.comment.scan(/^Column (.*) (added|deleted|edited)$/).flatten case action when "added" title = "Delete column #{coltitle}" @@ -98,18 +103,40 @@ if h.max when "edited" title = "Column #{coltitle} edit" end - $html << <" + unless urevs.size == 1 + $html << <
- + #{hidden}
-ADD_EDIT + +UNDO + end + if rrevs.min + $html << < +
+
+ + + + #{hidden} +
+
+ +REDO + urhist += rrevs + end + + $html << "" + $html << (urhist).to_html(urevs.max.rev) end -$html << h.to_html(1) $html << "
" #undo -- cgit v1.2.3