From e44bfd94b74d604b736b704e0cb808df9f44eb85 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 12 Nov 2018 14:52:02 +0900 Subject: [PATCH] Added activity deletion --- pages/activity/activity.pixy | 4 ++++ pages/activity/activity.scarlet | 17 +++++++++++++++++ scripts/Actions/Object.ts | 8 +++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pages/activity/activity.pixy b/pages/activity/activity.pixy index fa15215a..31f6711a 100644 --- a/pages/activity/activity.pixy +++ b/pages/activity/activity.pixy @@ -30,6 +30,10 @@ component Activity(activity arn.Activity, user *arn.User) else if activity.Type() == "ActivityConsumeAnime" ActivityConsumeAnimeTitle(activity.(*arn.ActivityConsumeAnime), user) + if user != nil && user.ID == activity.GetCreatedBy() && activity.Type() == "ActivityConsumeAnime" + button.post-delete.activity-action.tip.action(data-action="deleteObject", data-trigger="click", aria-label="Delete", data-return-path="/activity", data-confirm-type="activity", data-api=fmt.Sprintf("/api/%s/%s", strings.ToLower(activity.Type()), activity.GetID())) + RawIcon("trash") + .activity-date.utc-date(data-date=activity.GetCreated()) if activity.Type() == "ActivityCreate" diff --git a/pages/activity/activity.scarlet b/pages/activity/activity.scarlet index d139d014..cdd13eb4 100644 --- a/pages/activity/activity.scarlet +++ b/pages/activity/activity.scarlet @@ -4,6 +4,11 @@ max-width forum-width margin 0 auto +.activity + :hover + .activity-action + opacity 1 + .activity-header horizontal @@ -19,6 +24,18 @@ .actvity-text-create opacity 0.8 +.activity-action + border none + background none + padding 0 + height auto + margin-right 0.5rem + opacity 0 + + :hover + color link-hover-color + background none + #load-new-activities [data-count="0"] display none \ No newline at end of file diff --git a/scripts/Actions/Object.ts b/scripts/Actions/Object.ts index 6717d5eb..e4ce690e 100644 --- a/scripts/Actions/Object.ts +++ b/scripts/Actions/Object.ts @@ -29,6 +29,12 @@ export function deleteObject(arn: AnimeNotifier, button: HTMLButtonElement) { let endpoint = arn.findAPIEndpoint(button) arn.post(endpoint + "/delete") - .then(() => arn.app.load(returnPath)) + .then(() => { + if(returnPath) { + arn.app.load(returnPath) + } else { + arn.reloadContent() + } + }) .catch(err => arn.statusMessage.showError(err)) } \ No newline at end of file