From: Moritz Bunkus Date: Thu, 12 May 2011 08:04:48 +0000 (+0200) Subject: Verwaltung von Zahlungsbedingungen auf Drag & Drop mit AJAX und jQuery UI Sortable... X-Git-Tag: release-2.6.3~25^2~45 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=662b757f97c456d1a8f93f1f37ae188b945da42e;p=kivitendo-erp.git Verwaltung von Zahlungsbedingungen auf Drag & Drop mit AJAX und jQuery UI Sortable umgestellt --- diff --git a/SL/Controller/PaymentTerm.pm b/SL/Controller/PaymentTerm.pm index 631428edb..92cff0cff 100644 --- a/SL/Controller/PaymentTerm.pm +++ b/SL/Controller/PaymentTerm.pm @@ -64,16 +64,17 @@ sub action_destroy { $self->redirect_to(action => 'list'); } -sub action_move_up { +sub action_reorder { my ($self) = @_; - $self->{payment_term}->move_position_up; - $self->redirect_to(action => 'list'); -} -sub action_move_down { - my ($self) = @_; - $self->{payment_term}->move_position_down; - $self->redirect_to(action => 'list'); + my @ids = @{ $::form->{payment_term_id} || [] }; + my $result = SL::DB::PaymentTerm->new->db->do_transaction(sub { + foreach my $idx (0 .. scalar(@ids) - 1) { + SL::DB::PaymentTerm->new(id => $ids[$idx])->load->update_attributes(sortkey => $idx + 1); + } + }); + + $self->render(type => 'js', inline => '1;'); } # diff --git a/templates/webpages/payment_term/list.html b/templates/webpages/payment_term/list.html index e26e07f83..8563137d3 100644 --- a/templates/webpages/payment_term/list.html +++ b/templates/webpages/payment_term/list.html @@ -1,4 +1,7 @@ [% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %] + + +
[% FORM.title %]
@@ -11,29 +14,22 @@

[%- ELSE %] - +
+ - - + + + [%- FOREACH payment_term = PAYMENT_TERMS %] - - - + + [%- END %] +
[ LxERP.t8('reorder item') %] [%- 'Description' | $T8 %] [%- 'Long Description' | $T8 %] [%- 'Netto Terms' | $T8 %] [%- 'Skonto Terms' | $T8 %] [%- 'Skonto' | $T8 %]
- [%- UNLESS loop.first %] - - [%- END %] - - [%- UNLESS loop.last %] - - [%- END %] -
[ LxERP.t8('reorder item') %] [%- HTML.escape(payment_term.description) %] @@ -45,6 +41,7 @@ [%- HTML.escape(payment_term.percent_skonto_as_number) %] %
[%- END %] @@ -53,5 +50,7 @@

+ [% L.sortable_element('#payment_term_list tbody', url => 'controller.pl?action=PaymentTerm/reorder', with => 'payment_term_id') %] +