diff options
author | Yorhel <git@yorhel.nl> | 2019-10-16 10:31:24 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-10-16 15:29:38 +0200 |
commit | 678f511619708ba893cb2414eead90cdae685708 (patch) | |
tree | 2c79c111805f38454e07d96645f3fdc31fe75860 /lib/VNDB/DB | |
parent | 1fb8a234cf5a455af6d78c893320b21de8347bc4 (diff) |
v2rw: Convert staff adding/editing form
This is the first major editing form to be converted, so I'm expecting a
little breakage. A good chunk of this code has been copied from v3.
In terms of the UI there has been a small change: aliases that are still
referenced do not have the 'remove' link and instead have a flag that
shows that they are still referenced. This ought to be a bit friendlier
than throwing an error message after the user has submitted the form.
Some other things I'd like to improve in this form:
- BBCode preview
- Pasting in external links and letting the form figure out the Pixiv
ID, etc.
- Or perhaps even: Integrate AniDB/Wikidata search/autocompletion.
Diffstat (limited to 'lib/VNDB/DB')
-rw-r--r-- | lib/VNDB/DB/Misc.pm | 1 | ||||
-rw-r--r-- | lib/VNDB/DB/Staff.pm | 42 |
2 files changed, 1 insertions, 42 deletions
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm index 27494380..cd290d61 100644 --- a/lib/VNDB/DB/Misc.pm +++ b/lib/VNDB/DB/Misc.pm @@ -40,7 +40,6 @@ sub dbItemEdit { $self->dbProducerRevisionInsert(\%o) if $type eq 'p'; $self->dbReleaseRevisionInsert( \%o) if $type eq 'r'; $self->dbCharRevisionInsert( \%o) if $type eq 'c'; - $self->dbStaffRevisionInsert( \%o) if $type eq 's'; return $self->dbRow('SELECT * FROM edit_!s_commit()', $type); } diff --git a/lib/VNDB/DB/Staff.pm b/lib/VNDB/DB/Staff.pm index b8995d04..87dbef43 100644 --- a/lib/VNDB/DB/Staff.pm +++ b/lib/VNDB/DB/Staff.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Exporter 'import'; -our @EXPORT = qw|dbStaffGet dbStaffGetRev dbStaffRevisionInsert dbStaffAliasIds|; +our @EXPORT = qw|dbStaffGet dbStaffGetRev|; # options: results, page, id, aid, search, exact, truename, role, gender # what: extended changes roles aliases @@ -153,44 +153,4 @@ sub _enrich { return wantarray ? ($r, $np) : $r; } - -# Updates the edit_* tables, used from dbItemEdit() -# Arguments: { columns in staff_rev and staff_alias}, -sub dbStaffRevisionInsert { - my($self, $o) = @_; - - $self->dbExec('DELETE FROM edit_staff_alias'); - if($o->{aid}) { - $self->dbExec(q| - INSERT INTO edit_staff_alias (aid, name, original) VALUES (?, ?, ?)|, - $o->{aid}, $o->{name}, $o->{original}); - } else { - $o->{aid} = $self->dbRow(q| - INSERT INTO edit_staff_alias (name, original) VALUES (?, ?) RETURNING aid|, - $o->{name}, $o->{original})->{aid}; - } - - my %staff = map exists($o->{$_}) ? (qq|"$_" = ?|, $o->{$_}) : (), - qw|aid gender lang desc l_wp l_site l_twitter l_anidb l_wikidata l_pixiv|; - $self->dbExec('UPDATE edit_staff !H', \%staff) if %staff; - for my $a (@{$o->{aliases}}) { - if($a->{aid}) { - $self->dbExec('INSERT INTO edit_staff_alias (aid, name, original) VALUES (!l)', [ @{$a}{qw|aid name orig|} ]); - } else { - $self->dbExec('INSERT INTO edit_staff_alias (name, original) VALUES (?, ?)', $a->{name}, $a->{orig}); - } - } -} - - -# returns alias IDs that are and were related to the given staff ID -sub dbStaffAliasIds { - my($self, $sid) = @_; - return $self->dbAll(q| - SELECT DISTINCT sa.aid - FROM changes c - JOIN staff_alias_hist sa ON sa.chid = c.id - WHERE c.type = 's' AND c.itemid = ?|, $sid); -} - 1; |