92 lines
3.4 KiB
Vue
Executable File
92 lines
3.4 KiB
Vue
Executable File
<template>
|
|
<div>
|
|
<Loader v-if="loading" />
|
|
<div v-else>
|
|
<div class="relative">
|
|
<img
|
|
v-if="!loading"
|
|
class="cover"
|
|
:src="memo.attributes.cover_image.data.attributes.path"
|
|
/>
|
|
<div class="flex-col flex-between absolute memo-cover">
|
|
<div class="flex-between px-2 py-1">
|
|
<router-link to="/memos/" class="btn-secondary">< Back</router-link>
|
|
<div v-if="modal" class="modal-container" @click="modal = ! modal">
|
|
<div class="modal">
|
|
<p class="m-1 text-center">Are you sure you want to delete this record ?</p>
|
|
<div class="flex-center m-1 mt-2">
|
|
<button class="btn-secondary mr-2" @click="modal = ! modal">Cancel</button>
|
|
<button class="btn-alert" @click="destroy"> Delete</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="flex-middle">
|
|
<router-link :to="'/memos/' + memo.memo_id + '/edit'" class="btn-secondary mr-1" >Edit</router-link>
|
|
<a href="#" class="btn-alert" @click="modal = ! modal">Delete</a>
|
|
</div>
|
|
</div>
|
|
<h1 class="memo-title flex-center">{{ memo.name }}</h1>
|
|
</div>
|
|
</div>
|
|
<!-- <TagBox :memo="memo" />-->
|
|
<div class="p-2">
|
|
|
|
<p class="memo-style pt-1" v-html="memoMarkdown"></p>
|
|
<div class="memo-change">@last update : {{ memo.last_updated }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
// import TagBox from "../Tag/TagBox";
|
|
import Loader from "../../components/Loader";
|
|
let MarkdownIt = require('markdown-it'),
|
|
md = new MarkdownIt()
|
|
.use(require('markdown-it-checkbox'));
|
|
|
|
export default {
|
|
name: 'MemoShow',
|
|
components: {
|
|
Loader
|
|
// TagBox
|
|
},
|
|
data: function () {
|
|
return {
|
|
loading: true,
|
|
modal: false,
|
|
memo: null,
|
|
}
|
|
},
|
|
computed: {
|
|
memoMarkdown: function () {
|
|
return md.render(this.memo.memo)
|
|
}
|
|
},
|
|
mounted() {
|
|
axios.get('/api/memos/' + this.$route.params.id)
|
|
.then(response => {
|
|
this.memo = response.data.data
|
|
this.loading = false
|
|
})
|
|
.catch(errorRes => {
|
|
this.loading = false
|
|
if (errorRes.response.status === 404) {
|
|
this.$router.push('/memos')
|
|
}
|
|
})
|
|
},
|
|
methods: {
|
|
destroy: function () {
|
|
axios.delete('/api/memos/' + this.$route.params.id)
|
|
.then(response => {
|
|
this.$router.push('/memos')
|
|
})
|
|
.catch(errorRes => {
|
|
console.log('Internal Error, Unable to delete contact.' + errorRes)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|