From d0a48a8792435f0f42305ffb3940067a5c6c32b5 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 20 Dec 2017 17:28:13 -0800 Subject: [PATCH] added delete-* actions --- app/collections.hoon | 48 ++++++++++++++++++++++++++------- mar/collections/action.hoon | 2 ++ mar/collections/topic-full.hoon | 24 +++++++++++++++++ sur/collections.hoon | 4 +++ web/lib/css/collections.css | 4 +++ 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/app/collections.hoon b/app/collections.hoon index 1c95319d8..83ca7b9d8 100644 --- a/app/collections.hoon +++ b/app/collections.hoon @@ -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 :: diff --git a/mar/collections/action.hoon b/mar/collections/action.hoon index 1bcecf401..185e6e996 100644 --- a/mar/collections/action.hoon +++ b/mar/collections/action.hoon @@ -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 diff --git a/mar/collections/topic-full.hoon b/mar/collections/topic-full.hoon index 321349144..85ac89e2c 100644 --- a/mar/collections/topic-full.hoon +++ b/mar/collections/topic-full.hoon @@ -12,6 +12,20 @@ ;h1: {(trip tit.info.top)} ;b: {} ;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 -}, at ;{a/"#{id}" -} + :: + ;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 ); + ;input.red(type "submit", value "X"); + == == == -- :: diff --git a/sur/collections.hoon b/sur/collections.hoon index f184d1779..e7bcc0b53 100644 --- a/sur/collections.hoon +++ b/sur/collections.hoon @@ -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 == :: -- -- diff --git a/web/lib/css/collections.css b/web/lib/css/collections.css index e3f9b6484..35d965562 100644 --- a/web/lib/css/collections.css +++ b/web/lib/css/collections.css @@ -1,3 +1,7 @@ input.red { background: hsl(0, 100%, 60%); } + +form.inline { + display: inline; +}