added delete-* actions

This commit is contained in:
Anton Dyudin 2017-12-20 17:28:13 -08:00
parent f583143877
commit d0a48a8792
5 changed files with 72 additions and 10 deletions

View File

@ -86,9 +86,9 @@
++ ignore-action
|= act=action:api ^- ?
?- -.act
?($create $delete)
?($create $delete $delete-topic $delete-comment)
?: (team:title our.bol src.bol) |
~|([%unauthorized -.act src.bol] !!)
~|([%unauthorized -.act src.bol] !!) :: what about the authors?
::
?($submit $comment)
=/ col (~(get by cols) col.act)
@ -110,6 +110,8 @@
$submit (ta-submit:ta +.act)
$comment (ta-comment:ta +.act)
$delete (ta-delete:ta +.act)
$delete-topic (ta-delete-topic:ta +.act)
$delete-comment (ta-delete-comment:ta +.act)
==
::
++ ta
@ -150,9 +152,7 @@
^+ +>
?~ com $(com now.bol) :: new comment
=; res/$@(~ _+>.$) ?^(res res +>.$)
%+ biff (~(get by cols) col)
|= [^ tops=(map @da topicful) ~]
%+ biff (~(get by tops) top)
%+ biff (ta-get-topic col top)
|= [^ cos=(map @da {@da comment}) ~]
=/ old/{@da comment}
(fall (~(get by cos) com) [now.bol src.bol wat])
@ -161,6 +161,18 @@
[col top com]
[%collections-comment !>(`comment`+.old(wat wat))]
::
++ ta-get-topic
|= {col/time top/@da} ^- (unit topicful)
%+ biff (~(get by cols) col)
|= [^ tos=(map @da topicful) ~]
(~(get by tos) top)
::
++ ta-get-comment
|= {col/time top/@da com/@da} ^- (unit [@da comment])
%+ biff (ta-get-topic col top)
|= [^ cos=(map @da {@da comment}) ~]
(~(get by cos) com)
::
++ ta-delete
|= col/time
^+ +>
@ -173,14 +185,30 @@
|- ^+ ta-this
?~ tops ta-this
=. ta-this $(tops t.tops)
=. ta-this (ta-remove /topic [col top.i.tops] %collections-topic)
=/ cyt (circle-for-topic col top.i.tops)
=. ta-this (ta-hall-action %delete cyt `'Collection deleted')
=/ coms=(list [com=@da @ comment]) ~(tap by coms.i.tops)
(ta-delete-topic-inf 'Collection deleted' col i.tops)
::
++ ta-delete-topic
|= {col/time top/@da} ^+ ta-this
=+ (ta-get-topic col top)
?~ - ta-this ::REVIEW error?
(ta-delete-topic-inf 'Topic deleted' col top u)
::
++ ta-delete-topic-inf ::REVIEW name
|= {inf/@t col/time top/@da tof/topicful}
=. ta-this (ta-remove /topic [col top] %collections-topic)
=/ cyt (circle-for-topic col top)
=. ta-this (ta-hall-action %delete cyt `inf)
=/ coms=(list [com=@da @ comment]) ~(tap by coms.tof)
|- ^+ ta-this
?~ coms ta-this
=. ta-this $(coms t.coms)
(ta-remove /comment [col top.i.tops com.i.coms] %collections-comment)
(ta-remove /comment [col top com.i.coms] %collections-comment)
::
++ ta-delete-comment
|= {col/time top/@da com/@da} ^+ +>
=+ (ta-get-comment col top com)
?~ - ta-this ::REVIEW error?
(ta-remove /comment [col top com] %collections-comment)
::
:: %writing-files
::

View File

@ -23,6 +23,8 @@
delete+(ot col+(se %da) ~)
submit+(ot col+(se %da) tit+so wat+wain ~)
comment+(ot col+(se %da) top+(se %da) com+null-or-da wat+wain ~)
delete-topic+(ot col+(se %da) top+(se %da) ~)
delete-comment+(ot col+(se %da) top+(se %da) com+(se %da) ~)
==
::
++ null-or-da

View File

@ -12,6 +12,20 @@
;h1: {(trip tit.info.top)}
;b: {<who.info.top>}
;pre: {(of-wall:format (turn wat.info.top trip))}
::
;hr;
::
;form(onsubmit "return easy_form.submit(this)")
;input(type "hidden", name "easy_form:mark", value "collections-action");
;input(type "hidden", name "easy_form:tag", value "delete-topic");
;input(type "hidden", name "easy_form:url_end", value "collections/:col/:top");
;input(type "hidden", name "easy_form:confirm");
::
;input.red(type "submit", value "Archive this topic");
==
::
;hr;
::
;h2: Post comment:
;script@"/lib/js/easy-form.js";
;form(onsubmit "return easy_form.submit(this)")
@ -35,6 +49,16 @@
;hr;
;pre: {(of-wall:format (turn wat.com trip))}
; ;{b -<who.com>}, at ;{a/"#{id}" -<wen>}
::
;form.inline(onsubmit "return easy_form.submit(this)")
;input(type "hidden", name "easy_form:mark", value "collections-action");
;input(type "hidden", name "easy_form:tag", value "delete-comment");
;input(type "hidden", name "easy_form:url_end", value "collections/:col/:top");
;input(type "hidden", name "easy_form:confirm");
::
;input(type "hidden", name "com", value <wen>);
;input.red(type "submit", value "X");
==
== ==
--
::

View File

@ -41,6 +41,10 @@
{$submit col/time tit/cord wat/wain} :: submit a post/note
{$comment col/time top/@da com/?(~ @da) wat/wain} :: submit a comment
{$delete col/time} :: delete a collection
::
::REVIEW names? nest collection/topic/comment actions?
{$delete-topic col/time top/@da} :: delete a collection
{$delete-comment col/time top/@da com/@da} :: delete a collection
== ::
--
--

View File

@ -1,3 +1,7 @@
input.red {
background: hsl(0, 100%, 60%);
}
form.inline {
display: inline;
}