From 315a94affedffda8ab4be62cebf2b62c3f5f0d78 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 8 Dec 2019 19:46:45 +0100 Subject: allow a journey's cancellation status to be edited Closes #27 --- lib/Travelynx.pm | 13 +++++++++++++ lib/Travelynx/Controller/Traveling.pm | 12 ++++++++++++ templates/edit_journey.html.ep | 9 +++++++++ templates/journey.html.ep | 8 ++++++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index e1cca7d..3bb33ea 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -184,6 +184,7 @@ sub startup { sched_departure => 0x0001, real_departure => 0x0002, route => 0x0010, + is_cancelled => 0x0020, sched_arrival => 0x0100, real_arrival => 0x0200, }; @@ -896,6 +897,18 @@ sub startup { } )->rows; } + elsif ( $key eq 'cancelled' ) { + $rows = $db->update( + 'journeys', + { + cancelled => $value, + edited => $journey->{edited} | 0x0020, + }, + { + id => $journey_id, + } + )->rows; + } elsif ( $key eq 'comment' ) { $journey->{user_data}{comment} = $value; $rows = $db->update( diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 7b48d28..6b8c766 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -752,6 +752,7 @@ sub edit_journey { my $journey = $self->get_journey( uid => $uid, journey_id => $journey_id, + verbose => 1, with_datetime => 1, ); @@ -811,6 +812,15 @@ sub edit_journey { [@route_new] ); } } + { + my $cancelled_old = $journey->{cancelled}; + my $cancelled_new = $self->param('cancelled') // 0; + if ( $cancelled_old != $cancelled_new ) { + $error + = $self->update_journey_part( $db, $journey->{id}, + 'cancelled', $cancelled_new ); + } + } if ( not $error ) { $journey = $self->get_journey( @@ -839,6 +849,8 @@ sub edit_journey { $self->param( route => join( "\n", map { $_->[0] } @{ $journey->{route} } ) ); + $self->param( cancelled => $journey->{cancelled} ); + for my $key (qw(comment)) { if ( $journey->{user_data} and $journey->{user_data}{$key} ) { $self->param( $key => $journey->{user_data}{$key} ); diff --git a/templates/edit_journey.html.ep b/templates/edit_journey.html.ep index a77bbd4..ff36381 100644 --- a/templates/edit_journey.html.ep +++ b/templates/edit_journey.html.ep @@ -51,6 +51,15 @@ % } + + + + + + Geplante Abfahrt diff --git a/templates/journey.html.ep b/templates/journey.html.ep index 7be4f78..712bba6 100644 --- a/templates/journey.html.ep +++ b/templates/journey.html.ep @@ -15,11 +15,15 @@

% if ($journey->{cancelled}) { - Ausgefallene Fahrt von + Ausgefallene Fahrt % } % else { - Fahrt von + Fahrt % } + % if ($journey->{edited} & 0x0020) { + ∗ + % } + von <%= $journey->{from_name} %> nach <%= $journey->{to_name} %> -- cgit v1.2.3