Added create and edit pages

This commit is contained in:
Grzegorz Leoniec 2019-01-23 21:37:05 +01:00
parent 0673e0f823
commit 99fbd52f6e
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
3 changed files with 86 additions and 7 deletions

View File

@ -0,0 +1,65 @@
<template>
<ds-flex
:width="{ base: '100%' }"
gutter="base"
>
<ds-flex-item :width="{ base: '100%', sm: 3, md: 5, lg: 3 }">
<ds-card>
<no-ssr>
<hc-editor :html="htmlContent" />
</no-ssr>
</ds-card>
</ds-flex-item>
<ds-flex-item :width="{ base: '100%', sm: 2, md: 2, lg: 1 }">
&nbsp;
</ds-flex-item>
</ds-flex>
</template>
<script>
import gql from 'graphql-tag'
import HcEditor from '~/components/Editor/Editor.vue'
export default {
components: {
HcEditor
},
computed: {
htmlContent() {
return this.Post ? this.Post[0].content : ''
}
},
apollo: {
Post: {
query() {
return gql(`
query($id: ID!) {
Post(id: $id) {
id
title
content
createdAt
slug
image
tags {
name
}
categories {
id
name
icon
}
}
}
`)
},
variables() {
return {
id: this.$route.params.id || 'p1'
}
},
fetchPolicy: 'cache-and-network'
}
}
}
</script>

View File

@ -12,6 +12,7 @@
context="contribution"
:item-id="post.id"
:name="post.title"
:is-author="isAuthor"
/>
</no-ssr>
<ds-space margin-bottom="small" />
@ -154,6 +155,11 @@ export default {
title: 'loading'
}
},
computed: {
isAuthor() {
return this.$store.getters['auth/user'].id === this.post.author.id
}
},
watch: {
Post(post) {
this.post = post[0]

View File

@ -1,11 +1,19 @@
<template>
<div>
<ds-card>
<no-ssr>
<hc-editor />
</no-ssr>
</ds-card>
</div>
<ds-flex
:width="{ base: '100%' }"
gutter="base"
>
<ds-flex-item :width="{ base: '100%', sm: 3, md: 5, lg: 3 }">
<ds-card>
<no-ssr>
<hc-editor />
</no-ssr>
</ds-card>
</ds-flex-item>
<ds-flex-item :width="{ base: '100%', sm: 2, md: 2, lg: 1 }">
&nbsp;
</ds-flex-item>
</ds-flex>
</template>
<script>