summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-08-25 09:48:01 +0200
committerYorhel <git@yorhel.nl>2020-08-25 09:48:01 +0200
commit4b24bbb405895d8b3bd4afc833a8c6af76103f99 (patch)
tree50bfd6f1ce5af76e182bea492c6c65e2df91cd30
parentb608999b020fce26fd7dd07078b240d18a312953 (diff)
UList.VNPage: Add link to review submit/edit form when voted
-rw-r--r--elm/UList/VNPage.elm8
-rw-r--r--lib/VNWeb/ULists/Elm.pm2
-rw-r--r--lib/VNWeb/VN/Page.pm3
3 files changed, 10 insertions, 3 deletions
diff --git a/elm/UList/VNPage.elm b/elm/UList/VNPage.elm
index 7746e836..b41e6ea1 100644
--- a/elm/UList/VNPage.elm
+++ b/elm/UList/VNPage.elm
@@ -146,9 +146,11 @@ view model =
, td []
[ a [ href "#", onClickD NotesToggle ] [ text "💬" ]
, span [ class "spinner", classList [("hidden", model.notesState /= Api.Loading)] ] []
- , case model.notesState of
- Api.Error e -> b [ class "standout" ] [ text <| Api.showResponse e ]
- _ -> text ""
+ , case (model.notesState, model.vote.vote /= Nothing && model.flags.canreview, model.flags.review) of
+ (Api.Error e, _, _) -> b [ class "standout" ] [ text <| Api.showResponse e ]
+ (_, False, _) -> text ""
+ (_, True, Nothing) -> a [ href ("/v" ++ String.fromInt model.flags.vid ++ "/addreview") ] [ text " write a review »" ]
+ (_, True, Just w) -> a [ href ("/" ++ w ++ "/edit") ] [ text " edit review »" ]
]
]
else text ""
diff --git a/lib/VNWeb/ULists/Elm.pm b/lib/VNWeb/ULists/Elm.pm
index 33ad9b86..4fd032dc 100644
--- a/lib/VNWeb/ULists/Elm.pm
+++ b/lib/VNWeb/ULists/Elm.pm
@@ -172,6 +172,8 @@ our $VNPAGE = form_compile any => {
canvote => { anybool => 1 },
vote => { vnvote => 1 },
notes => { required => 0, default => '' },
+ review => { required => 0, vndbid => 'w' },
+ canreview=> { anybool => 1 },
labels => { aoh => { id => { int => 1 }, label => {}, private => { anybool => 1 } } },
selected => { type => 'array', values => { id => 1 } },
};
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index 6dcd3fc9..ace37546 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -307,6 +307,7 @@ sub infobox_useroptions_ {
ORDER BY CASE WHEN l.id < 10 THEN l.id ELSE 10 END, l.label'
);
my $lst = tuwf->dbRowi('SELECT vid, vote, notes FROM ulist_vns WHERE uid =', \auth->uid, 'AND vid =', \$v->{id});
+ my $review = tuwf->dbVali('SELECT id FROM reviews WHERE uid =', \auth->uid, 'AND vid =', \$v->{id});
tr_ class => 'nostripe', sub {
td_ colspan => 2, sub {
@@ -317,6 +318,8 @@ sub infobox_useroptions_ {
canvote => canvote($v),
vote => fmtvote($lst->{vote}),
notes => $lst->{notes}||'',
+ review => $review,
+ canreview=> canvote($v) && can_edit(w => {}),
labels => $labels,
selected => [ map $_->{id}, grep $_->{assigned}, @$labels ],
};