aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-07-21 13:23:07 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-07-21 13:23:07 -0400
commitb286ce04cb9d6b29048e0ad7549cfe980d8c2e7b (patch)
tree04c259734a256eb2c2babe27483e92d64598ec25
parent8e7b31a19cc9f9d68d6c936d3d36e1d48c82248f (diff)
downloadikiwiki-b286ce04cb9d6b29048e0ad7549cfe980d8c2e7b.tar
ikiwiki-b286ce04cb9d6b29048e0ad7549cfe980d8c2e7b.tar.gz
implemented form state saving and retrieval
This is overkill for delete, since it's only used on Cancel. But it will be crucial for rename, so as to restore any pending edits after renaming a page.
-rw-r--r--IkiWiki/Plugin/remove.pm22
1 files changed, 14 insertions, 8 deletions
diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm
index 77ddd63ba..3ad90ad6d 100644
--- a/IkiWiki/Plugin/remove.pm
+++ b/IkiWiki/Plugin/remove.pm
@@ -65,15 +65,16 @@ sub formbuilder (@) { #{{{
if (defined $form->field("do") && $form->field("do") eq "edit" &&
$form->submitted eq "Remove") {
- # When the remove button is pressed on the edit form,
- # save the rest of the form state and generate a small
- # remove confirmation form.
-
- # TODO save state
-
-
my $q=$params{cgi};
my $session=$params{session};
+ # Save current form state to allow returning to it later
+ # without losing any edits.
+ # (But don't save what button was submitted.)
+ $q->param(-name => "_submit", -value => "");
+ $session->param(postremove => scalar $q->Vars);
+ IkiWiki::cgi_savesession($session);
+
+ # Display a small confirmation form.
my ($f, $buttons)=confirmation_form($q, $session);
$f->field(name => "page", value => $form->field("page"),
force => 1);
@@ -90,7 +91,12 @@ sub sessioncgi ($$) { #{{{
my ($form, $buttons)=confirmation_form($q, $session);
IkiWiki::decode_form_utf8($form);
if ($form->submitted eq 'Cancel') {
- error("canceled"); # TODO load state
+ # Load saved form state and return to edit form.
+ my $postremove=CGI->new($session->param("postremove"));
+ $session->clear("postremove");
+ IkiWiki::cgi_savesession($session);
+ IkiWiki::cgi($postremove, $session);
+ exit 0;
}
elsif ($form->submitted eq 'Remove' && $form->validate) {
error("removal not yet implemented"); # TODO