[server links] description

This commit is contained in:
JakubPapso committed 2024-07-02 22:25:29 +02:00
1 parent 1b7315617f
commit 484eca5548
4 files changed
+71 -121

No files matched your search

@@ -1,26 +1,17 @@
<template>
<div class="px-5 py-5 border-bottom" v-if="description" >
<p>Popis zadania</p>
<section v-html="description" class="description-detail px-2 py-2 w-100 rounded mt-2" />
</div>
<div v-if="masterTaskDescLinks?.length > 0" class="px-5 d-flex flex-column">
<p class="py-3">Odkazy na server</p>
<div v-for="index in masterTaskDescLinks" :key="index" class="server-links my-1 rounded-pill text-truncate position-relative">
<a :href="index">{{ index }}</a>
<p v-if="!copiedIndices.includes('subtask-' + index)" class="copy-btn" @click.stop="copyToClipboard('subtask-', index)">Copy</p>
<p v-else class="copying-btn">Copied!</p>
</div>
<section v-html="preparedDescription" class="description-detail px-2 py-2 w-100 rounded mt-2" />
</div>
<div class="px-5 py-5 border-bottom" v-if="inheritedDescription">
<p>Popis mastertasku</p>
<section v-html="inheritedDescription" class="description-detail px-2 py-2 w-100 rounded mt-2" />
<section v-html="preparedInheritedDescription" class="description-detail px-2 py-2 w-100 rounded mt-2" />
</div>
</template>
<script>
import { getServerLinks, detectOS } from '@/plugins/tm@_utils/server-links.utils'
import { prepareHTMLDescription } from '@/plugins/tm@_utils/server-links.utils'
export default {
props: {
@@ -37,29 +28,15 @@ export default {
data() {
return {
copiedIndices: []
copiedIndices: [],
preparedDescription: '',
preparedInheritedDescription: ''
}
},
computed: {
masterTaskDescLinks() {
return getServerLinks(this.description)
}
},
methods: {
copyToClipboard(prefix, index) {
const fullIndex = prefix + index
const os = detectOS()
navigator.clipboard.writeText(os + ': ' + index).then(() => {
this.copiedIndices.push(fullIndex)
setTimeout(() => {
const idx = this.copiedIndices.indexOf(fullIndex)
if (idx > -1)
this.copiedIndices.splice(idx, 1)
}, 1000)
})
}
mounted() {
this.preparedDescription = prepareHTMLDescription(this.description)
this.preparedInheritedDescription = prepareHTMLDescription(this.inheritedDescription)
}
}
</script>