summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/VNEdit.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-07-31 09:04:22 +0200
committerYorhel <git@yorhel.nl>2016-07-31 09:04:25 +0200
commitf3c877ba7257c024219fd7f79724f726f6d1a63d (patch)
treef63cc2827767a65c5ee615bf254587e9e7f305ee /lib/VNDB/Handler/VNEdit.pm
parentcca3548bc9221564fb4910b462cef2e4f2883b16 (diff)
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.
Diffstat (limited to 'lib/VNDB/Handler/VNEdit.pm')
-rw-r--r--lib/VNDB/Handler/VNEdit.pm11
1 files changed, 5 insertions, 6 deletions
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 <a href="/d2.3">staff editing guidelines</a>. You can'
.' <a href="/s/new">create a new staff entry</a> if it is not in the database yet,'