From: Bernd Bleßmann Date: Wed, 19 Aug 2015 13:59:25 +0000 (+0200) Subject: Auftrags-Controller: save via ajax, damit Eingaben bei Fehlern erhalten bleiben. X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=53e34f9acf8185573f82197f4c6289cec4bb933e;p=kivitendo-erp.git Auftrags-Controller: save via ajax, damit Eingaben bei Fehlern erhalten bleiben. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index c4624072a..c532740b9 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -82,8 +82,14 @@ sub action_update { sub action_save { my ($self) = @_; - $self->_save(); + my $errors = $self->_save(); + if (scalar @{ $errors }) { + $self->js->flash('error', $_) foreach @{ $errors }; + return $self->js->render($self); + } + + flash_later('info', 'The order has been saved'); my @redirect_params = ( action => 'edit', type => $self->type, @@ -308,12 +314,15 @@ sub _recalc { sub _save { my ($self) = @_; + my $errors = []; my $db = $self->order->db; $db->do_transaction( sub { $self->order->save(); - }) || die($db->error); + }) || push(@{$errors}, $db->error); + + return $errors; } diff --git a/templates/webpages/order/form.html b/templates/webpages/order/form.html index b2e68a518..169355524 100644 --- a/templates/webpages/order/form.html +++ b/templates/webpages/order/form.html @@ -30,7 +30,18 @@ [% L.hidden_tag('action', 'Order/dispatch') %] - [% L.submit_tag('action_update', LxERP.t8('Update')) %] - [% L.submit_tag('action_save', LxERP.t8('Save')) %] + [% L.button_tag('save()', LxERP.t8('Save')) %] + + +