Added activity deletion

This commit is contained in:
Eduard Urbach 2018-11-12 14:52:02 +09:00
parent f711cdb011
commit e44bfd94b7
3 changed files with 28 additions and 1 deletions

View File

@ -30,6 +30,10 @@ component Activity(activity arn.Activity, user *arn.User)
else if activity.Type() == "ActivityConsumeAnime" else if activity.Type() == "ActivityConsumeAnime"
ActivityConsumeAnimeTitle(activity.(*arn.ActivityConsumeAnime), user) 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()) .activity-date.utc-date(data-date=activity.GetCreated())
if activity.Type() == "ActivityCreate" if activity.Type() == "ActivityCreate"

View File

@ -4,6 +4,11 @@
max-width forum-width max-width forum-width
margin 0 auto margin 0 auto
.activity
:hover
.activity-action
opacity 1
.activity-header .activity-header
horizontal horizontal
@ -19,6 +24,18 @@
.actvity-text-create .actvity-text-create
opacity 0.8 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 #load-new-activities
[data-count="0"] [data-count="0"]
display none display none

View File

@ -29,6 +29,12 @@ export function deleteObject(arn: AnimeNotifier, button: HTMLButtonElement) {
let endpoint = arn.findAPIEndpoint(button) let endpoint = arn.findAPIEndpoint(button)
arn.post(endpoint + "/delete") 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)) .catch(err => arn.statusMessage.showError(err))
} }