$self->autor_session2stash($c);
$c->stash->{'autor_edit'}{'name'} = "Neuer Autor" unless $c->stash->{'autor_edit'}{'name'};
+ $c->stash->{'return_target_autor_save'} = $c->session->{'return_target_autor_save'} || $c->web_path('/autor');
+
return 1 unless $c->request->params->{'autor_form_sent'} and $c->request->params->{'do_save'};
- return 1 unless $self->check_formparams($c);
- return 1;
+ return $self->save_author($c);
}
my ( $self, $c ) = @_;
my $K = __PACKAGE__ . "::save_author(): ";
-
+ return 1 unless $self->check_formparams($c);
+
+ eval {
+ die "Speichern des Autors misslungen." unless save_autor( $c, $c->stash->{'autor_edit'} );
+ };
+ if ( $@ ) {
+ $c->stash->{'error_message'} = $@;
+ return undef;
+ }
+
+ $c->stash->{'template'} = 'autor/save_success.tt2';
+ delete $c->session->{'autor_data_edit'} if exists $c->session->{'autor_data_edit'};
+ delete $c->session->{'return_target_autor_save'} if exists $c->session->{'return_target_autor_save'};
+
+ return 1;
}
return 1 unless $c->request->params->{'autor_form_sent'};
+ $c->session->{'return_target_autor_save'} = $c->request->params->{'return_target_form'} if $c->request->params->{'return_target_form'};
+
# Basis anlegen, wenn notwendig
$c->session->{'autor_data_edit'} = {} unless $c->session->{'autor_data_edit'};
$self->bookdata_cgi2session($c);
+ if ( $c->request->params->{'neuer_autor'} ) {
+ $c->session->{'return_target_autor_save'} = $c->stash->{'self_url'};
+ $c->detach('/autor/form_new');
+ }
+
$c->stash->{'book_edit'} = {} unless $c->stash->{'book_edit'};
$self->bookdata_session2stash($c);
$c->stash->{'book_edit'}{'title'} = "Neues Buch" unless $c->stash->{'book_edit'}{'title'};
my $save_func = sub {
my ( $storage, $dbh, $autor_id, $name, $desc ) = @_;
+ $desc = '' unless defined $desc;
my $sql = <<ENDE;
INSERT INTO `autoren` (
`id`, `autor_name`, `autor_descr` )
if ( $storage->debug() ) {
my $text = $sql;
$text =~ s/\s+$//;
- $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $uid, $ptype_id, $value, $value ) ) . "\n";
+ $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $autor_id, $name, $desc, $name, $desc ) ) . "\n";
warn $text;
}
[% PROCESS autor/autor_form.tt2 %]
<div class="back">
-<h2><a href="[% path('/autor') %]">[% 'Zurück' %]</a></h2>
+<h2><a href="[% return_target_autor_save %]">[% 'Zurück' %]</a></h2>
</div>
--- /dev/null
+[%#
+
+ index.tt2 - Template fuer erfolgreiches Speichern des Autors
+
+ #$Id$
+ #$URL$
+
+-%]
+<div style="text-align: center">
+
+Der Autor <b>"[% autor_edit.name %]</b> wurde erfolgreich gespeichert.
+
+<h2><a href="[% return_target_autor_save %]">OK</a></h2>
+
+</div>
$URL$
-%]
+
<!-- Book form -->
+
+<script type="text/javascript">//<![CDATA[
+
+function goto_new_author() {
+ var target = '[% Catalyst.web_path( '/autor/new', { 'return_target_form' => self_url } ) %]';
+ window.location.href = target;
+}
+
+//]]></script>
+
<form method="post" name="book_form" action="[% self_url %]">
<input type="hidden" name="book_form_sent" value="sent" />
[%- IF book_edit.id %]<input type="hidden" name="book_id" value="[% book_edit.id | html %]" />[% END %]
[% END %]</select></td>
<td><input type="submit" name="wird_autor" value="⇒" class="shift_button" title="Wird Autor" /><br /><br />
<input type="submit" name="nach_oben" value="⇑" class="shift_button" title="Autor in der Reihenfolge nach oben" /><br /><br />
- <input type="submit" name="neuer_autor" value="*" class="shift_button" title="Neuer Autor" /><br /><br />
+ <input type="button" name="neuer_autor" value="*" class="shift_button" title="Neuer Autor" onclick="goto_new_author();" /><br /><br />
<input type="submit" name="nach_unten" value="⇓" class="shift_button" title="Autor in der Reihenfolge nach unten" /><br /><br />
<input type="submit" name="entf_autor" value="⇐" class="shift_button" title="Autor entfernen" />
</td>
<td><input type="text" name="book_original_title" size="60" maxlength="250" value="[% book_edit.original_title | html %]" /></td>
</tr><tr>
<th>Verlag:</th>
- <td><select name="verlags_id"> size="1">
+ <td><select name="verlags_id" size="1">
<option value="">-- Verlag auswählen --</option>[% FOR verlagsid IN verlags_ids %]
<option value="[% verlagsid %]"[% IF book_edit.verlags_id == verlagsid %] selected[% END %]>[% verlagsliste.$verlagsid %]</option>[% END %]
- </select> <input type="submit" name="neuer_verlag" value="*" class="shift_button" title="Neuer Verlag" /></td>
+ </select> <input type="button" name="neuer_verlag" value="*" class="shift_button" title="Neuer Verlag" /></td>
</tr><tr>
<th>Kategorie(n):</th>
<td>
<option value="[% cat_id %]">[% kategorie_list.$cat_id %]</option>
[% END %]</select></td>
<td><input type="submit" name="wird_kategorie" value="⇒" class="shift_button" title="Wird Kategorie" /><br /><br />
- <input type="submit" name="neue_kategorie" value="*" class="shift_button" title="Neue Kategorie" /><br /><br />
+ <input type="button" name="neue_kategorie" value="*" class="shift_button" title="Neue Kategorie" /><br /><br />
<input type="submit" name="entf_kategorie" value="⇐" class="shift_button" title="Kategorie entfernen" />
</td>
<td><select name="kategorie_book" size="7" multiple>
<option value="[% serien_id %]">[% serienliste.$serien_id %]</option>
[% END %]</select></td>
<td><input type="submit" name="wird_serie" value="⇒" class="shift_button" title="Wird Serie" /><br /><br />
- <input type="submit" name="neue_serie" value="*" class="shift_button" title="Neue Serie" /><br /><br />
+ <input type="button" name="neue_serie" value="*" class="shift_button" title="Neue Serie" /><br /><br />
<input type="submit" name="entf_serie" value="⇐" class="shift_button" title="Serie entfernen" />
</td>
<td><select name="serie_book" size="7" multiple>