Added soundtrack drafts
This commit is contained in:
parent
e635be5291
commit
68901ac25e
@ -94,9 +94,10 @@ func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, i
|
||||
if field.Name == "IsDraft" {
|
||||
if fieldValue.Bool() {
|
||||
b.WriteString(`<div class="buttons"><button class="action" data-action="publish" data-trigger="click">` + utils.Icon("unlock-alt") + `Publish</button></div>`)
|
||||
} else {
|
||||
b.WriteString(`<div class="buttons"><button class="action" data-action="unpublish" data-trigger="click">` + utils.Icon("lock") + `Unpublish</button></div>`)
|
||||
}
|
||||
// else {
|
||||
// b.WriteString(`<div class="buttons"><button class="action" data-action="unpublish" data-trigger="click">` + utils.Icon("lock") + `Unpublish</button></div>`)
|
||||
// }
|
||||
}
|
||||
case "[]*arn.ExternalMedia":
|
||||
for sliceIndex := 0; sliceIndex < fieldValue.Len(); sliceIndex++ {
|
||||
|
@ -6,12 +6,15 @@ import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
const maxTracks = 9
|
||||
|
||||
// Get renders the soundtracks page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
||||
return !track.IsDraft && len(track.Media) > 0
|
||||
})
|
||||
@ -26,5 +29,5 @@ func Get(ctx *aero.Context) string {
|
||||
tracks = tracks[:maxTracks]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.SoundTracks(tracks))
|
||||
return ctx.HTML(components.SoundTracks(tracks, user))
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
component SoundTracks(tracks []*arn.SoundTrack)
|
||||
component SoundTracks(tracks []*arn.SoundTrack, user *arn.User)
|
||||
h1 Soundtracks
|
||||
|
||||
.music-buttons
|
||||
a.button.action(data-action="newSoundTrack", data-trigger="click")
|
||||
if user != nil
|
||||
if user.DraftIndex().SoundTrackID == ""
|
||||
button.action(data-action="newSoundTrack", data-trigger="click")
|
||||
Icon("plus")
|
||||
span Add soundtrack
|
||||
else
|
||||
a.button.ajax(href="/soundtrack/" + user.DraftIndex().SoundTrackID + "/edit")
|
||||
Icon("pencil")
|
||||
span Edit draft
|
||||
|
||||
.sound-tracks
|
||||
each track in tracks
|
||||
|
@ -199,7 +199,7 @@ export function createThread(arn: AnimeNotifier) {
|
||||
export function newSoundTrack(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
arn.post("/api/new/soundtrack", "")
|
||||
.then(response => response.json())
|
||||
.then(response => console.log(response))
|
||||
.then(track => arn.app.load(`/soundtrack/${track.id}/edit`))
|
||||
.catch(err => arn.statusMessage.showError(err))
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ export function publish(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
let endpoint = arn.findAPIEndpoint(button)
|
||||
|
||||
arn.post(endpoint + "/publish", "")
|
||||
.then(() => arn.reloadContent())
|
||||
.then(() => arn.app.load(arn.app.currentPath.replace("/edit", "")))
|
||||
.catch(err => arn.statusMessage.showError(err))
|
||||
}
|
||||
|
||||
@ -356,6 +356,10 @@ export function arrayAppend(arn: AnimeNotifier, element: HTMLElement) {
|
||||
|
||||
// Remove element from array
|
||||
export function arrayRemove(arn: AnimeNotifier, element: HTMLElement) {
|
||||
if(!confirm("Are you sure you want to remove this element?")) {
|
||||
return
|
||||
}
|
||||
|
||||
let field = element.dataset.field
|
||||
let index = element.dataset.index
|
||||
let apiEndpoint = arn.findAPIEndpoint(element)
|
||||
|
Loading…
Reference in New Issue
Block a user