Skip to content

Commit

Permalink
#1 feat(udateTags): Update article's tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mochenski committed Jul 15, 2020
1 parent c0600b2 commit e85788f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
36 changes: 35 additions & 1 deletion front-end/pages/dashboard/articles/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
<v-textarea auto-grow outlined rounded label="Excerpt" v-model="article.excerpt"></v-textarea>
<v-textarea auto-grow outlined rounded label="Body" v-model="article.body"></v-textarea>

<v-select
outlined
rounded
label="Tags"
v-model="article.tags"
item-value="id"
item-text="name"
:items="tags"
chips
multiple
></v-select>

<v-row class="pa-5">
<v-btn color="red" @click="loadArticle" dark>Reset</v-btn>
<v-spacer></v-spacer>
Expand All @@ -30,12 +42,14 @@ export default {
layout: 'dashboard',
data: () => ({
loading: false,
article: Object,
loading: false
tags: []
}),
mounted() {
this.loadArticle()
this.loadTags()
},
computed: {
Expand All @@ -50,6 +64,7 @@ export default {
await this.$axios
.get(`articles/${this.params.slug}`)
.then((response) => {
console.log(response.data)
this.article = response.data
this.loading = false
})
Expand All @@ -59,8 +74,27 @@ export default {
})
},
async loadTags() {
console.log('a')
this.loading = true
await this.$axios
.get('tags')
.then((response) => {
this.tags = response.data.map((tag) => ({
id: tag.id,
name: tag.name
}))
this.loading = false
})
.catch((err) => {
console.log(err.response)
this.loading = false
})
},
async submitArticle() {
this.loading = true
console.log(this.article)
await this.$axios
.put(`articles/${this.params.slug}`, this.article)
.then((response) => {
Expand Down
2 changes: 1 addition & 1 deletion front-end/pages/dashboard/articles/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
async publishArticle(article, slug) {
this.loading = true
article.publicated_at = this.$moment().format()
article.publicated_at = this.$moment().format('YYYY-MM-DD HH:mm:ss')
console.log(article)
await this.$axios
.put(`articles/${slug}`, article)
Expand Down

0 comments on commit e85788f

Please sign in to comment.