Skip to content

Commit

Permalink
feature to edit news story
Browse files Browse the repository at this point in the history
  • Loading branch information
shg-dsi committed Oct 14, 2017
1 parent 06f5d5e commit 6428e4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions vueapp/src/components/Feeds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</q-card-main>
<q-card-separator />
<q-card-actions>
<q-btn flat @click="edit( story.id )">Edit</q-btn>
<q-btn flat @click="getStory( story.id )">HTML</q-btn>
<q-btn flat @click="getStoryJson( story.id )">JSON</q-btn>
<q-btn flat @click="getStoryXml( story.id )">XML</q-btn>
Expand Down Expand Up @@ -72,6 +73,10 @@ export default {
getStoryXml (storyId) {
this.$router.push({name: 'news_detail_xml', params: {id: storyId}})
},
edit (storyId) {
this.$router.push({name: 'edit_news', params: {id: storyId}})
}
}
}
Expand Down
1 change: 1 addition & 0 deletions vueapp/src/components/NewsDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</q-card-main>
<q-card-separator />
<q-card-actions>
<q-btn flat @click="edit( story.id )">Edit</q-btn>
<q-btn flat @click="back()">Back</q-btn>
</q-card-actions>
</q-card>
Expand Down
23 changes: 19 additions & 4 deletions vueapp/src/components/NewsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<div class="layout-padding docs-input row justify-center">
<div style="width: 500px; max-width: 90vw; text-align: left">
<q-card>
<q-card-title>
Create News Story
</q-card-title>
<q-card-title v-if="this.$route.params.id">Edit News Story</q-card-title>
<q-card-title v-else>Create News Story</q-card-title>
<q-card-main>
<q-field>
<q-input v-model="story.title" float-label="Title" />
Expand All @@ -22,6 +21,7 @@
<q-card-separator />
<q-card-actions>
<q-btn flat color="secondary" @click="submit()">Submit</q-btn>
<q-btn flat @click="cancel()">Cancel</q-btn>
</q-card-actions>
</q-card>
</div>
Expand Down Expand Up @@ -68,7 +68,7 @@ export default {
},
data () {
return {
let data = {
story: {
title: '',
body: '',
Expand All @@ -78,6 +78,13 @@ export default {
}
}
}
if (this.$route.params.id) {
this.$http.get('/stories/' + this.$route.params.id)
.then(resp => {
data.story = resp.data
})
}
return data
},
methods: {
Expand All @@ -88,6 +95,14 @@ export default {
.then(resp => {
this.$router.push({name: 'feeds'})
})
},
edit (storyId) {
this.$router.push({name: 'edit_news', params: {id: storyId}})
},
cancel () {
this.$router.go(-1)
}
}
}
Expand Down

0 comments on commit 6428e4c

Please sign in to comment.