56 lines
1.3 KiB
Vue
56 lines
1.3 KiB
Vue
<script setup="setup">
|
|
|
|
import { stripHtml } from 'string-strip-html'
|
|
|
|
const { etherpadApiUrl, etherpadPrefix } = useRuntimeConfig().public
|
|
|
|
const store = usePojmiStore()
|
|
|
|
const props = defineProps({
|
|
naslov: String
|
|
})
|
|
|
|
const pojem = computed(() => store.pojmi[props.naslov])
|
|
const revisionId = computed(() => pojem.value.id)
|
|
|
|
await store.naloziPojme()
|
|
|
|
const urejanje = ref(false)
|
|
|
|
const urediPojem = async () => {
|
|
// Ustvari pad s tekstom pojma, ce se ne obstaja
|
|
const tekstPojma = stripHtml(pojem.value.tekst).result
|
|
const resp = await $fetch(`${etherpadApiUrl}/createPad?padID=${etherpadPrefix + revisionId.value}`, {
|
|
method: 'post',
|
|
body: {
|
|
text: tekstPojma
|
|
}
|
|
})
|
|
urejanje.value = true
|
|
}
|
|
|
|
const brisiPojem = async () => {
|
|
const resp = await $fetch(`${etherpadApiUrl}/deletePad?padID=${etherpadPrefix + revisionId.value}`)
|
|
alert('pad izbrisan')
|
|
}
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<section class="pojem">
|
|
<h2>{{ pojem.naslov }}</h2>
|
|
<div class="tekst" v-html="pojem.tekst" />
|
|
<div class="gumb" @click="urediPojem">Uredi</div>
|
|
<div class="gumb" @click="brisiPojem">Briši (pad)</div>
|
|
<div v-if="urejanje" class="pojem">
|
|
<PojemForm :revisionId="revisionId" />
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.gumb {
|
|
margin-right: 1rem;
|
|
}
|
|
</style>
|