From f3c877ba7257c024219fd7f79724f726f6d1a63d Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 31 Jul 2016 09:04:22 +0200 Subject: Handler::VNEdit: Fix bug with new staff/cast being removed on form error The names of the staff were fetched from the existing VN entry, so any newly added staff were not present in that list, and would thus not show up when the form validation failed. This fix makes sure to always fetch the required data from the database. --- lib/VNDB/Handler/VNEdit.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/VNDB/Handler') diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index 1c059e7a..2564f62b 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -313,12 +313,11 @@ sub _form { [ json => short => 'credits' ], [ static => nolabel => 1, content => sub { # propagate staff ids and names to javascript - my %staff_data; - for my $c (@{$v->{credits}}, @{$v->{seiyuu}}) { - $staff_data{$c->{aid}} //= { map +($_ => $c->{$_}), qw|id aid name| }; - } - script_json staffdata => \%staff_data; - + my @alist = map $_->{aid}, @{$frm->{credits}}, @{$frm->{seiyuu}}; + script_json staffdata => { + map +($_->{aid}, {id => $_->{id}, aid => $_->{aid}, name => $_->{name}}), + @alist ? @{$self->dbStaffGet(aid => \@alist, results => 200)} : () + }; div class => 'warning'; lit 'Please check the staff editing guidelines. You can' .' create a new staff entry if it is not in the database yet,' -- cgit v1.2.3