summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-09-01 13:52:50 +0200
committerYorhel <git@yorhel.nl>2020-09-01 13:52:52 +0200
commitd019f3a2bc73e9513ec6489ac742faa0f8f560dc (patch)
treee88ff2b04b3bc68b0860a934303016e4fe594f5b
parent5e523de0ef77aa4d44426bf1c01896475aed0fe9 (diff)
Reviews: Hide up/down vote counts
Experimenting a bit.
-rw-r--r--data/style.css4
-rw-r--r--elm/Reviews/Vote.elm22
-rw-r--r--lib/VNWeb/Reviews/Elm.pm2
-rw-r--r--lib/VNWeb/Reviews/Lib.pm20
-rw-r--r--lib/VNWeb/Reviews/List.pm6
-rw-r--r--lib/VNWeb/Reviews/Page.pm7
-rw-r--r--lib/VNWeb/Reviews/VNTab.pm5
7 files changed, 17 insertions, 49 deletions
diff --git a/data/style.css b/data/style.css
index cd743aa0..08cee73d 100644
--- a/data/style.css
+++ b/data/style.css
@@ -525,7 +525,7 @@ div#vntags { margin: 0 30px 0 30px; border-top: 1px solid $bo
.reviewbox > div:first-child > span:first-child { font-weight: bold }
.reviewbox > div:nth-child(2) { box-sizing: border-box; padding: 5px 0 }
.reviewbox > div:last-child { display: flex; justify-content: space-between; border-top: 1px solid $border$ }
-.reviewbox .myvote { font-weight: bold }
+.reviewbox .myvote { font-weight: bold; text-decoration: underline }
/***** Vote stats ****/
@@ -619,7 +619,7 @@ div.producerbrowse { padding-bottom: 10px }
.fullreview td { padding: 0 0 15px 10px }
.fullreview tr > td:first-child { width: 140px; text-align: right; font-weight: bold }
.fullreview tr > td:last-child { max-width: 700px }
-.fullreview .myvote { font-weight: bold }
+.fullreview .myvote { font-weight: bold; text-decoration: underline }
#reviewspoil:not(:checked) ~ .fullreview .reviewspoil { display: none }
#reviewspoil:checked ~ .fullreview .reviewnotspoil { display: none }
diff --git a/elm/Reviews/Vote.elm b/elm/Reviews/Vote.elm
index 717539c1..c3d8ff9d 100644
--- a/elm/Reviews/Vote.elm
+++ b/elm/Reviews/Vote.elm
@@ -23,8 +23,6 @@ type alias Model =
{ state : Api.State
, id : String
, my : Maybe Bool
- , up : Int
- , down : Int
}
init : GRV.Recv -> Model
@@ -32,8 +30,6 @@ init d =
{ state = Api.Normal
, id = d.id
, my = d.my
- , up = d.up
- , down = d.down
}
type Msg
@@ -45,14 +41,8 @@ update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
Vote b ->
- let nm = case (model.my, b) of
- (Nothing, True) -> { model | my = Just b, up = model.up+1 }
- (Nothing, False) -> { model | my = Just b , down = model.down+1 }
- (Just True, False) -> { model | my = Just b, up = model.up-1, down = model.down+1 }
- (Just False, True) -> { model | my = Just b, up = model.up+1, down = model.down-1 }
- (Just True, True) -> { model | my = Nothing, up = model.up-1 }
- (Just False, False) -> { model | my = Nothing , down = model.down-1 }
- in ({ nm | state = Api.Loading }, GRV.send { id = nm.id, my = nm.my } Saved)
+ let my = if model.my == Just b then Nothing else Just b
+ in ({ model | my = my, state = Api.Loading }, GRV.send { id = model.id, my = my } Saved)
Saved GApi.Success -> ({ model | state = Api.Normal }, Cmd.none)
Saved e -> ({ model | state = Api.Error e }, Cmd.none)
@@ -66,8 +56,8 @@ view model =
[ case model.state of
Api.Loading -> span [ class "spinner" ] []
Api.Error e -> b [ class "standout" ] [ text (Api.showResponse e) ]
- Api.Normal -> if model.my == Nothing then text "Was this review helpful? " else text ""
- , but True ("๐Ÿ‘ " ++ String.fromInt model.up)
- , text " "
- , but False ("๐Ÿ‘Ž " ++ String.fromInt model.down)
+ Api.Normal -> text "Was this review helpful? "
+ , but True "yes"
+ , text " / "
+ , but False "no"
]
diff --git a/lib/VNWeb/Reviews/Elm.pm b/lib/VNWeb/Reviews/Elm.pm
index 428da4dc..6bce7973 100644
--- a/lib/VNWeb/Reviews/Elm.pm
+++ b/lib/VNWeb/Reviews/Elm.pm
@@ -5,8 +5,6 @@ use VNWeb::Prelude;
my $VOTE = {
id => { vndbid => 'w' },
my => { required => 0, jsonbool => 1 },
- up => { _when => 'out', uint => 1 },
- down => { _when => 'out', uint => 1 },
};
my $VOTE_IN = form_compile in => $VOTE;
diff --git a/lib/VNWeb/Reviews/Lib.pm b/lib/VNWeb/Reviews/Lib.pm
deleted file mode 100644
index 3564464a..00000000
--- a/lib/VNWeb/Reviews/Lib.pm
+++ /dev/null
@@ -1,20 +0,0 @@
-package VNWeb::Reviews::Lib;
-
-use VNWeb::Prelude;
-use Exporter 'import';
-
-our @EXPORT = qw/review_vote_/;
-
-
-# Display the up/down vote counts for a review, optionally with the option for the user to vote.
-# Takes an object with the following fields: id, c_up, c_down, my, can
-sub review_vote_ {
- my($w) = @_;
- my sub plain_ {
- span_ sprintf '๐Ÿ‘ %d ๐Ÿ‘Ž %d', $w->{c_up}, $w->{c_down};
- };
- return plain_ if !auth || !$w->{can};
- elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, { id => $w->{id}, up => $w->{c_up}, down => $w->{c_down}, my => $w->{my} }, \&plain_;
-}
-
-1;
diff --git a/lib/VNWeb/Reviews/List.pm b/lib/VNWeb/Reviews/List.pm
index a9dc9b41..8d2d0903 100644
--- a/lib/VNWeb/Reviews/List.pm
+++ b/lib/VNWeb/Reviews/List.pm
@@ -1,7 +1,6 @@
package VNWeb::Reviews::List;
use VNWeb::Prelude;
-use VNWeb::Reviews::Lib;
sub tablebox_ {
@@ -18,7 +17,7 @@ sub tablebox_ {
td_ class => 'tc3', 'Vote';
td_ class => 'tc4', 'Type';
td_ class => 'tc5', 'Review';
- td_ class => 'tc6', sub { txt_ 'Score'; sortable_ 'rating', $opt, \&url if auth->isMod };
+ td_ class => 'tc6', sub { txt_ 'Score*'; sortable_ 'rating', $opt, \&url } if auth->isMod;
td_ class => 'tc7', 'C#';
td_ class => 'tc8', sub { txt_ 'Last comment'; sortable_ 'lastpost', $opt, \&url };
} };
@@ -28,7 +27,7 @@ sub tablebox_ {
td_ class => 'tc3', fmtvote $_->{vote};
td_ class => 'tc4', $_->{isfull} ? 'Full' : 'Mini';
td_ class => 'tc5', sub { a_ href => "/$_->{id}", $_->{title} };
- td_ class => 'tc6', sub { review_vote_ $_ };
+ td_ class => 'tc6', sprintf '๐Ÿ‘ %d ๐Ÿ‘Ž %d', $_->{c_up}, $_->{c_down} if auth->isMod;
td_ class => 'tc7', $_->{c_count};
td_ class => 'tc8', $_->{c_lastnum} ? sub {
user_ $_, 'lu_';
@@ -77,6 +76,7 @@ TUWF::get qr{/w}, sub {
if($u && !$count) {
p_ +(auth && $u->{id} == auth->uid ? 'You have' : user_displayname($u).' has').' not submitted any reviews yet.';
}
+ p_ 'Note: The score column is only visible to moderators.' if auth->isMod;
};
tablebox_ $opt, $lst, $count if $count;
};
diff --git a/lib/VNWeb/Reviews/Page.pm b/lib/VNWeb/Reviews/Page.pm
index cab028e4..36ed8ee2 100644
--- a/lib/VNWeb/Reviews/Page.pm
+++ b/lib/VNWeb/Reviews/Page.pm
@@ -2,7 +2,6 @@ package VNWeb::Reviews::Page;
use VNWeb::Prelude;
use VNWeb::Releases::Lib;
-use VNWeb::Reviews::Lib;
my $COMMENT = form_compile any => {
@@ -65,7 +64,9 @@ sub review_ {
};
tr_ sub {
td_ '';
- td_ style => 'text-align: right', sub { review_vote_ $w };
+ td_ style => 'text-align: right', sub {
+ elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, $w if auth && $w->{can};
+ };
};
}
}
@@ -74,7 +75,7 @@ sub review_ {
TUWF::get qr{/$RE{wid}(?:(?<sep>[\./])$RE{num})?}, sub {
my($id, $sep, $num) = (tuwf->capture('id'), tuwf->capture('sep')||'', tuwf->capture('num'));
my $w = tuwf->dbRowi(
- 'SELECT r.id, r.vid, r.rid, r.isfull, r.text, r.spoiler, COALESCE(c.count,0) AS count, r.c_up, r.c_down, uv.vote, rm.id IS NULL AS can
+ 'SELECT r.id, r.vid, r.rid, r.isfull, r.text, r.spoiler, COALESCE(c.count,0) AS count, uv.vote, rm.id IS NULL AS can
, v.title, rel.title AS rtitle, rel.original AS roriginal, rel.type AS rtype, rv.vote AS my
, ', sql_user(), ',', sql_totime('r.date'), 'AS date,', sql_totime('r.lastmod'), 'AS lastmod
FROM reviews r
diff --git a/lib/VNWeb/Reviews/VNTab.pm b/lib/VNWeb/Reviews/VNTab.pm
index cd729832..bd1ae870 100644
--- a/lib/VNWeb/Reviews/VNTab.pm
+++ b/lib/VNWeb/Reviews/VNTab.pm
@@ -1,7 +1,6 @@
package VNWeb::Reviews::VNTab;
use VNWeb::Prelude;
-use VNWeb::Reviews::Lib;
sub reviews_ {
@@ -9,7 +8,7 @@ sub reviews_ {
# TODO: Better order, pagination
my $lst = tuwf->dbAlli(
- 'SELECT r.id, r.rid, r.text, r.spoiler, r.c_up, r.c_down, r.c_count, uv.vote, rv.vote AS my, NOT r.isfull AND rm.id IS NULL AS can
+ 'SELECT r.id, r.rid, r.text, r.spoiler, r.c_count, uv.vote, rv.vote AS my, NOT r.isfull AND rm.id IS NULL AS can
, ', sql_totime('r.date'), 'AS date, ', sql_user(), '
FROM reviews r
LEFT JOIN users u ON r.uid = u.id
@@ -56,7 +55,7 @@ sub reviews_ {
div_ sub {
a_ href => "/$r->{id}#review", 'Full review ยป' if !$mini;
a_ href => "/$r->{id}#threadstart", $r->{c_count} == 1 ? '1 comment' : "$r->{c_count} comments";
- review_vote_ $r;
+ elm_ 'Reviews.Vote' => $VNWeb::Reviews::Elm::VOTE_OUT, $r if auth && $r->{can};
};
} for @$lst;
}