diff options
author | Yorhel <git@yorhel.nl> | 2019-11-04 15:49:20 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-10 12:44:55 +0100 |
commit | 3af0103b6bcc791142f78664bc449263c99571fb (patch) | |
tree | 6a350ca45d1b2bc862cc43515067a324b6e66035 /lib/VNWeb | |
parent | de6df4ab815a4f4447122d7f19888afd1b3e50ec (diff) |
ulist: Implement deletion of items from the list
Diffstat (limited to 'lib/VNWeb')
-rw-r--r-- | lib/VNWeb/User/Lists.pm | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/VNWeb/User/Lists.pm b/lib/VNWeb/User/Lists.pm index 0aa10630..fb09a8e4 100644 --- a/lib/VNWeb/User/Lists.pm +++ b/lib/VNWeb/User/Lists.pm @@ -74,6 +74,15 @@ elm_form 'UListVNOpt', undef, $VNOPT; +my $VNDEL = form_compile any => { + uid => { id => 1 }, + vid => { id => 1 }, +}; + +elm_form 'UListDel', undef, $VNDEL; + + + # TODO: Filters to find unlabeled VNs or VNs with/without notes? sub filters_ { my($own, $labels) = @_; @@ -126,7 +135,7 @@ sub filters_ { sub vn_ { my($uid, $own, $n, $v, $labels) = @_; - tr_ mkclass(odd => $n % 2 == 0), sub { + tr_ mkclass(odd => $n % 2 == 0), id => "ulist_tr_$v->{id}", sub { my %labels = map +($_,1), $v->{labels}->@*; td_ class => 'tc1', sub { @@ -382,4 +391,12 @@ json_api qr{/u/ulist/setdate.json}, $VNDATE, sub { elm_Success }; + +json_api qr{/u/ulist/del.json}, $VNDEL, sub { + my($data) = @_; + return elm_Unauth if !auth || auth->uid != $data->{uid}; + tuwf->dbExeci('DELETE FROM ulist_vns WHERE uid =', \$data->{uid}, 'AND vid =', \$data->{vid}); + elm_Success +}; + 1; |