summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-01-09 14:07:56 +0100
committerYorhel <git@yorhel.nl>2020-01-09 14:07:58 +0100
commit3416762e5e5cda330a851af916b136b91bb733e0 (patch)
tree9c4987b5db4b5460cd1c72b4ac68b125850cf978 /lib
parenta462070881b07a4db4898df69d2cb1e04ca9b23e (diff)
ulist: Rework VN "User options" tab to be more prominent and convenient
Personally not a big fan of this taking so much space when it's not on the user's list, but people want instant options so there we go. It probably still blends in too well with the rest of the VN info though, styling isn't my thing. And there's no need to hit "Add to list" anymore now.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Handler/VNPage.pm8
-rw-r--r--lib/VNWeb/User/Lists.pm27
2 files changed, 11 insertions, 24 deletions
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 3556476c..8b01fabc 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -440,6 +440,7 @@ sub page {
_affiliate_links($self, $r);
_anime($self, $v) if @{$v->{anime}};
+
_useroptions($self, $v, $r) if $self->authInfo->{id};
Tr class => 'nostripe';
@@ -725,9 +726,8 @@ sub _useroptions {
);
my $lst = tuwf->dbRowi('SELECT vid, vote FROM ulist_vns WHERE uid =', \$self->authInfo->{id}, 'AND vid =', \$v->{id});
- Tr;
- td 'User options';
- td;
+ Tr class => 'nostripe';
+ td colspan => 2;
VNWeb::HTML::elm_('UList.VNPage', undef, {
uid => 1*$self->authInfo->{id},
vid => 1*$v->{id},
@@ -738,7 +738,7 @@ sub _useroptions {
selected => [ map $_->{id}, grep $_->{assigned}, @$labels ],
});
end;
- end 'tr';
+ end;
}
diff --git a/lib/VNWeb/User/Lists.pm b/lib/VNWeb/User/Lists.pm
index 00ec2470..cdebab6b 100644
--- a/lib/VNWeb/User/Lists.pm
+++ b/lib/VNWeb/User/Lists.pm
@@ -91,13 +91,13 @@ elm_api UListVoteEdit => undef, $VNVOTE, sub {
my($data) = @_;
return elm_Unauth if !own $data->{uid};
tuwf->dbExeci(
- 'UPDATE ulist_vns
- SET vote =', \$data->{vote},
- ', vote_date = CASE WHEN', \$data->{vote}, '::smallint IS NULL THEN NULL WHEN vote IS NULL THEN NOW() ELSE vote_date END',
- ', lastmod = NOW()
- WHERE uid =', \$data->{uid}, 'AND vid =', \$data->{vid}
+ 'INSERT INTO ulist_vns', { %$data, vote_date => sql $data->{vote} ? 'NOW()' : 'NULL' },
+ 'ON CONFLICT (uid, vid) DO UPDATE
+ SET', { %$data,
+ lastmod => sql('NOW()'),
+ vote_date => sql $data->{vote} ? 'CASE WHEN ulist_vns.vote IS NULL THEN NOW() ELSE ulist_vns.vote_date END' : 'NULL'
+ }
);
-
updcache $data->{uid};
elm_Success
};
@@ -122,6 +122,7 @@ elm_api UListLabelEdit => $VNLABELS_OUT, $VNLABELS_IN, sub {
return elm_Unauth if !own $data->{uid};
die "Attempt to set vote label" if $data->{label} == 7;
+ tuwf->dbExeci('INSERT INTO ulist_vns', {uid => $data->{uid}, vid => $data->{vid}}, 'ON CONFLICT (uid, vid) DO NOTHING');
tuwf->dbExeci(
'DELETE FROM ulist_vns_labels
WHERE uid =', \$data->{uid}, 'AND vid =', \$data->{vid}, 'AND lbl =', \$data->{label}
@@ -212,20 +213,6 @@ elm_api UListDel => undef, {
-elm_api UListAdd => undef, {
- uid => { id => 1 },
- vid => { id => 1 },
-}, sub {
- my($data) = @_;
- return elm_Unauth if !own $data->{uid};
- tuwf->dbExeci('INSERT INTO ulist_vns', $data, 'ON CONFLICT (uid, vid) DO NOTHING');
- updcache $data->{uid};
- elm_Success
-};
-
-
-
-
# Adds the release when not in the list.
elm_api UListRStatus => undef, {
uid => { id => 1 },