File tree Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Expand file tree Collapse file tree 2 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" hello" >
3
+ <h1 >Edit {{episode.title}}</h1 >
4
+ <form enctype =" multipart/form-data" action =" /admin/edit" method =" post" >
5
+ <label for =" title" >Episode Title</label >
6
+ <input type =" text" id =" title" name =" title" :value =" episode.title" >
7
+ <label for =" description" >Episode Description</label >
8
+ <textarea name =" description" id =" description" cols =" 100" rows =" 20" style =" resize : none ;" >{{ episode.description }}</textarea >
9
+ <label for =" date" >Publish Date</label >
10
+ <input type =" date" id =" date" name =" date" :value =" episode.time" >
11
+ <input name =" previousfilename" id =" previousfilename" :value =" episode.previousfilename" type =" hidden" >
12
+ <input type =" submit" class =" button" value =" Publish" ></form >
13
+ </div >
14
+ </template >
15
+
16
+ <script >
17
+ export default {
18
+ name: ' EpisodeEdit' ,
19
+ data () {
20
+ return {
21
+ loading: false ,
22
+ episode: {},
23
+ error: null
24
+ }
25
+ },
26
+ created () {
27
+ // fetch the data when the view is created and the data is
28
+ // already being observed
29
+ this .fetchData ()
30
+ },
31
+ watch: {
32
+ // call again the method if the route changes
33
+ ' $route' : ' fetchData'
34
+ },
35
+ methods: {
36
+ fetchData () {
37
+ this .error = this .items = []
38
+ this .loading = true
39
+
40
+ fetch (' /static/feed.json' ).then (response => {
41
+ return response .text ()
42
+ }).then (blob => {
43
+ this .loading = false
44
+ var t = JSON .parse (blob).items
45
+ for (var i = t .length - 1 ; i >= 0 ; i-- ) {
46
+ if (t[i].id === this .$route .params .id ) {
47
+ var time = t[i].date_published .split (' T' )
48
+ var prev = time[0 ] + ' _' + t[i].title
49
+ this .episode = {
50
+ title: t[i].title ,
51
+ description: t[i].summary ,
52
+ url: t[i].url ,
53
+ id: t[i].id ,
54
+ time: time[0 ],
55
+ previousfilename: prev
56
+ }
57
+ }
58
+ }
59
+ })
60
+ }
61
+ }
62
+ }
63
+ </script >
64
+
65
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
66
+ <style scoped>
67
+ h1 , h2 {
68
+ font-weight : normal ;
69
+ }
70
+ ul {
71
+ list-style-type : none ;
72
+ padding : 0 ;
73
+ }
74
+ li {
75
+ display : inline-block ;
76
+ margin : 0 10px ;
77
+ }
78
+ </style >
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import Vue from 'vue'
2
2
import Router from 'vue-router'
3
3
import Publish from '@/components/Publish'
4
4
import EpisodeList from '@/components/EpisodeList'
5
+ import EpisodeEdit from '@/components/EpisodeEdit'
5
6
6
7
Vue . use ( Router )
7
8
@@ -16,6 +17,11 @@ export default new Router({
16
17
path : '/manage' ,
17
18
name : 'EpisodeList' ,
18
19
component : EpisodeList
20
+ } ,
21
+ {
22
+ path : '/edit/:id' ,
23
+ name : 'EpisodeEdit' ,
24
+ component : EpisodeEdit
19
25
}
20
26
]
21
27
} )
You can’t perform that action at this time.
0 commit comments