Fully implement episode editing

TODO is implement proper function into backend but frontend rendering works as intended.
This commit is contained in:
gmemstr 2017-10-08 17:57:58 -07:00
parent 182a381f23
commit 72b90d8ddc
3 changed files with 18 additions and 14 deletions

View file

@ -3,7 +3,7 @@ const episodepublishform = {
}
const episodemanagement = {
template: '<div><table style="width:100%"><tr><th>Title</th><th>URL</th><th>Actions</th></tr><tr v-for="item in items"><td>{{ item.title }}</td><td>{{ item.url }}</td><td><router-link :to="\'edit/\' + item.id">Edit</router-link></td></tr></table></div>',
template: '<div><table style="width:100%"><tr><th>Title</th><th>URL</th><th>Actions</th></tr><tr v-for="item in items"><td>{{ item.id }}: {{ item.title }}</td><td>{{ item.url }}</td><td><router-link :to="\'edit/\' + item.id">Edit</router-link></td></tr></table></div>',
data() {
return {
loading: false,
@ -30,7 +30,7 @@ const episodemanagement = {
if (err) {
this.error = err.toString()
} else {
console.log(items);
console.log(items);
var t = JSON.parse(items).items
for (var i = t.length - 1; i >= 0; i--) {
this.items.push({
@ -46,8 +46,8 @@ const episodemanagement = {
}
const episodeedit = {
template: '<div><div><h3>Edit Episode</h3><form enctype="multipart/form-data" action="/admin/edit" method="post"><label for="title">Episode Title</label><input type="text" id="title" name="title"><label for="description">Episode Description</label><textarea name="description" id="description" cols="100" rows="20" style="resize: none;"></textarea><label for="date">Publish Date</label><input type="date" id="date" name="date"><input type="submit" value="Publish"></form></div></div>',
data() {
template: '<div><div><h3>Edit Episode</h3><form enctype="multipart/form-data" action="/admin/edit" method="post"><label for="title">Episode Title</label><input type="text" id="title" name="title" :value="episode.title"><label for="description">Episode Description</label><textarea name="description" id="description" cols="100" rows="20" style="resize: none;">{{ episode.description }}</textarea><label for="date">Publish Date</label><input type="date" id="date" name="date"><input type="submit" value="Publish"></form></div></div>',
data() {
return {
loading: false,
episode: null,
@ -65,7 +65,7 @@ const episodeedit = {
},
methods: {
fetchData() {
this.error = this.items = []
this.error = this.episode = {}
this.loading = true
getEpisodes((err, items) => {
@ -75,14 +75,17 @@ const episodeedit = {
} else {
var t = JSON.parse(items).items
for (var i = t.length - 1; i >= 0; i--) {
if (t[i].id == route.params.id)
this.items.push({
title: t[i].title,
url: t[i].url
})
if (t[i].id == this.$route.params.id) {
this.episode = {
title: t[i].title,
description: t[i].summary,
url: t[i].url,
id: t[i].id
}
}
}
}
console.log(this.items)
console.log(this.episode)
})
}
}
@ -127,7 +130,7 @@ const routes = [
{ path: '/publish', component: episodepublishform },
{ path: '/manage', component: episodemanagement },
{ path: '/theme', component: customcss },
{ path: '/edit/:id', component: episodeedit}
{ path: '/edit/:id', component: episodeedit }
]
const router = new VueRouter({

View file

@ -12,6 +12,7 @@ import (
"io/ioutil"
"log"
"strings"
"strconv"
"time"
"encoding/json"
@ -110,7 +111,7 @@ func GenerateRss() {
link := podcasturl + "/download/" + file.Name()
feed.Add(
&feeds.Item{
Id: string(i),
Id: strconv.Itoa(i),
Title: title,
Link: &feeds.Link{Href: link, Length: size, Type: "audio/mpeg"},
Enclosure: &feeds.Enclosure{Url: link, Length: size, Type: "audio/mpeg"},