From e00ab63b50f4e8fdc96794b05f90141bcf5ae4c6 Mon Sep 17 00:00:00 2001 From: Scott Date: Fri, 24 Nov 2017 23:55:29 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20a=20new=20button=20to=20del?= =?UTF-8?q?ete=20a=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mixins/Postable.pixy | 3 +++ scripts/Actions/Forum.ts | 16 +++++++++++++++- styles/forum.scarlet | 11 +++++++---- styles/include/config.scarlet | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/mixins/Postable.pixy b/mixins/Postable.pixy index 9fd02261..41c0623d 100644 --- a/mixins/Postable.pixy +++ b/mixins/Postable.pixy @@ -43,6 +43,9 @@ component Postable(post arn.Postable, user *arn.User, highlightAuthorID string) Icon("pencil") if post.Type() != "Thread" + if user.Role == "admin" || user.Role == "editor" + a.post-tool.post-delete.action(data-action="deletePost", data-trigger="click", data-id=post.ID(), title="Delete") + Icon("trash") a.post-tool.post-permalink.ajax(href=post.Link(), title="Permalink") Icon("link") diff --git a/scripts/Actions/Forum.ts b/scripts/Actions/Forum.ts index 7bc14bce..5141f03a 100644 --- a/scripts/Actions/Forum.ts +++ b/scripts/Actions/Forum.ts @@ -1,4 +1,4 @@ -import { AnimeNotifier } from "../AnimeNotifier" +import {AnimeNotifier} from "../AnimeNotifier" // Edit post export function editPost(arn: AnimeNotifier, element: HTMLElement) { @@ -43,6 +43,20 @@ export function savePost(arn: AnimeNotifier, element: HTMLElement) { .catch(err => arn.statusMessage.showError(err)) } +// Create thread +export function deletePost(arn: AnimeNotifier, element: HTMLElement) { + + if (!confirm(`Are you sure you want to delete this Post?`)) { + return + } + + let endpoint = arn.findAPIEndpoint(element) + + arn.post(endpoint + "/delete", "") + .then(() => arn.reloadContent()) + .catch(err => arn.statusMessage.showError(err)) +} + // Forum reply export function forumReply(arn: AnimeNotifier) { let textarea = arn.app.find("new-reply") as HTMLTextAreaElement diff --git a/styles/forum.scarlet b/styles/forum.scarlet index 1ad0affd..d3a4b18c 100644 --- a/styles/forum.scarlet +++ b/styles/forum.scarlet @@ -13,7 +13,7 @@ post-content-padding-y = 0.75rem > 330px .thread-link horizontal - + .post-author margin-bottom 0 @@ -37,11 +37,11 @@ post-content-padding-y = 0.75rem h3 font-size 1.1rem - + :hover .post-toolbar opacity 1 - + .post-date opacity 0.25 @@ -107,6 +107,9 @@ post-content-padding-y = 0.75rem .post-unlike color post-unlike-color +.post-delete + color post-delete-color + .post-save // @@ -246,7 +249,7 @@ post-content-padding-y = 0.75rem // .thread-title // width auto - + // .posts // width 100% // max-width 830px diff --git a/styles/include/config.scarlet b/styles/include/config.scarlet index 791e818c..ecc3ab74 100644 --- a/styles/include/config.scarlet +++ b/styles/include/config.scarlet @@ -60,6 +60,7 @@ nav-link-hover-slide-color = main-color // Forum post-like-color = green !important post-unlike-color = rgb(255, 32, 12) !important +post-delete-color = post-unlike-color !important post-permalink-color = blue !important table-row-hover-background = hsla(0, 0%, 0%, 0.01)