diff options
author | Yorhel <git@yorhel.nl> | 2020-02-28 12:53:44 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-02-28 12:55:40 +0100 |
commit | ccc121634fec7d7aa3a36564eeab2330e543e970 (patch) | |
tree | e427f45ceeda01c55260950e2844b22548735586 /lib | |
parent | 03106135b8d4f0c2c0387991133cc3205957d68b (diff) |
v2rw/RelEdit: Add producers relation editing
Lots of copy-pasting going on here. Meh.
Also added a couple of overdue server-side validations.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNWeb/Elm.pm | 5 | ||||
-rw-r--r-- | lib/VNWeb/Producers/Elm.pm | 24 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Edit.pm | 12 |
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/VNWeb/Elm.pm b/lib/VNWeb/Elm.pm index 4a5269dc..cf6409cb 100644 --- a/lib/VNWeb/Elm.pm +++ b/lib/VNWeb/Elm.pm @@ -75,6 +75,11 @@ my %apis = ( title => {}, original => { required => 0, default => '' }, } } ], + ProducerResult => [ { aoh => { # Response to 'Producers' + id => { id => 1 }, + name => {}, + original => { required => 0, default => '' }, + } } ], ); diff --git a/lib/VNWeb/Producers/Elm.pm b/lib/VNWeb/Producers/Elm.pm new file mode 100644 index 00000000..181729c3 --- /dev/null +++ b/lib/VNWeb/Producers/Elm.pm @@ -0,0 +1,24 @@ +package VNWeb::Producers::Elm; + +use VNWeb::Prelude; + +elm_api Producers => undef, { search => {} }, sub { + my $q = shift->{search}; + my $qs = $q =~ s/[%_]//gr; + + elm_ProducerResult tuwf->dbPagei({ results => 15, page => 1 }, + 'SELECT p.id, p.name, p.original + FROM (', + sql_join('UNION ALL', + $q =~ /^$RE{pid}$/ ? sql('SELECT 1, id FROM producers WHERE id =', \"$+{id}") : (), + sql('SELECT 1+substr_score(lower(name),' , \$qs, '), id FROM producers WHERE name ILIKE', \"$qs%"), + sql('SELECT 10+substr_score(lower(original),', \$qs, '), id FROM producers WHERE original ILIKE', \"$qs%"), + ), ') x(prio, id) + JOIN producers p ON p.id = x.id + WHERE NOT p.hidden + GROUP BY p.id, p.name, p.original + ORDER BY MIN(x.prio), p.name + '); +}; + +1; diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm index 21563c34..a292261d 100644 --- a/lib/VNWeb/Releases/Edit.pm +++ b/lib/VNWeb/Releases/Edit.pm @@ -34,6 +34,12 @@ my $FORM = { vid => { id => 1 }, title => { _when => 'out' }, } }, + producers => { sort_keys => 'pid', aoh => { + pid => { id => 1 }, + developer => { anybool => 1 }, + publisher => { anybool => 1 }, + name => { _when => 'out' }, + } }, hidden => { anybool => 1 }, locked => { anybool => 1 }, @@ -67,6 +73,7 @@ TUWF::get qr{/$RE{rrev}/(?<action>edit|copy)} => sub { to_extlinks $e; enrich_merge vid => 'SELECT id AS vid, title FROM vn WHERE id IN', $e->{vn}; + enrich_merge pid => 'SELECT id AS pid, name FROM producers WHERE id IN', $e->{producers}; my $title = ($copy ? 'Copy ' : 'Edit ').$e->{title}; framework_ title => $title, type => 'r', dbobj => $e, tab => tuwf->capture('action'), @@ -98,7 +105,12 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub { $data->{hidden} = $e->{hidden}||0; $data->{locked} = $e->{locked}||0; } + $data->{doujin} = $data->{voiced} = $data->{ani_story} = $data->{ani_ero} = 0 if $data->{patch}; + $data->{resolution} = 'unknown' if $data->{patch}; + $data->{uncensored} = 0 if $data->{minage} != 18; $_->{qty} = $MEDIUM{$_->{medium}}{qty} ? $_->{qty}||1 : 0 for $data->{media}->@*; + $data->{notes} = bb_subst_links $data->{notes}; + die "No VNs selected" if !$data->{vn}->@*; to_extlinks $e; $e->{rtype} = delete $e->{type}; |