From 53e34f9acf8185573f82197f4c6289cec4bb933e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 19 Aug 2015 15:59:25 +0200 Subject: [PATCH] Auftrags-Controller: save via ajax, damit Eingaben bei Fehlern erhalten bleiben. --- SL/Controller/Order.pm | 13 +++++++++++-- templates/webpages/order/form.html | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) 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')) %] + + + -- 2.20.1