2023-05-03 21:31:01 +02:00
|
|
|
<script setup="setup">
|
2023-11-13 00:22:34 +01:00
|
|
|
|
2023-12-08 15:00:40 +01:00
|
|
|
import { stripHtml } from 'string-strip-html'
|
|
|
|
|
2023-12-16 01:53:05 +01:00
|
|
|
const { etherFetch } = useEtherpadApi()
|
2024-03-05 22:48:42 +01:00
|
|
|
const { poskrolaj } = useUi()
|
|
|
|
|
2023-05-03 21:31:01 +02:00
|
|
|
const store = usePojmiStore()
|
2024-04-01 19:59:09 +02:00
|
|
|
const nastavitveStore = useNastavitveStore()
|
2024-01-17 20:24:11 +01:00
|
|
|
const route = useRoute()
|
2023-05-03 21:31:01 +02:00
|
|
|
|
2024-04-01 20:36:28 +02:00
|
|
|
const { izbraniJezik } = storeToRefs(nastavitveStore)
|
|
|
|
|
2024-07-24 14:38:45 +02:00
|
|
|
const routeName = computed(() => route.name)
|
|
|
|
|
2023-05-03 21:31:01 +02:00
|
|
|
const props = defineProps({
|
2024-07-11 11:47:49 +02:00
|
|
|
pojemid: String
|
2023-05-03 21:31:01 +02:00
|
|
|
})
|
|
|
|
|
2024-07-11 11:47:49 +02:00
|
|
|
if (props.pojemid && !(props.pojemid in store.pojmi)) {
|
2024-04-01 20:36:28 +02:00
|
|
|
await store.naloziPojme(izbraniJezik.value)
|
2024-01-24 16:44:09 +01:00
|
|
|
}
|
|
|
|
|
2024-04-01 19:59:09 +02:00
|
|
|
watch(izbraniJezik, jezik => {
|
2024-07-24 14:38:45 +02:00
|
|
|
console.log('PONOVNO NALAGAM POJME!', jezik)
|
2024-04-01 19:59:09 +02:00
|
|
|
store.naloziPojme(jezik)
|
|
|
|
})
|
|
|
|
|
2024-07-11 11:47:49 +02:00
|
|
|
const pojem = computed(() => store.pojmi[props.pojemid])
|
2024-01-24 18:54:28 +01:00
|
|
|
const revisionId = computed(() => pojem.value ? pojem.value.id : null)
|
2023-05-03 21:31:01 +02:00
|
|
|
|
2023-11-13 00:22:34 +01:00
|
|
|
const urejanje = ref(false)
|
2024-01-17 20:24:11 +01:00
|
|
|
const container = ref(null)
|
2024-01-24 17:37:41 +01:00
|
|
|
const obrazec = ref(null)
|
2023-11-13 00:22:34 +01:00
|
|
|
|
|
|
|
const urediPojem = async () => {
|
|
|
|
// Ustvari pad s tekstom pojma, ce se ne obstaja
|
2023-12-08 15:00:40 +01:00
|
|
|
const tekstPojma = stripHtml(pojem.value.tekst).result
|
2023-12-16 01:53:05 +01:00
|
|
|
const resp = await etherFetch('/createPad', {
|
2024-07-24 14:38:45 +02:00
|
|
|
padID: izbraniJezik.value + '-' + revisionId.value,
|
2023-12-16 01:53:05 +01:00
|
|
|
text: tekstPojma
|
2023-12-08 15:00:40 +01:00
|
|
|
})
|
2023-11-13 00:22:34 +01:00
|
|
|
urejanje.value = true
|
|
|
|
}
|
|
|
|
|
2024-01-17 20:24:11 +01:00
|
|
|
onMounted(() => {
|
2024-01-24 18:54:28 +01:00
|
|
|
// Prazen pojem? Nazaj na manifest
|
2024-05-17 17:18:51 +02:00
|
|
|
if ((!pojem.value || !pojem.value.id) && store.pojmi) {
|
2024-05-31 17:44:04 +02:00
|
|
|
navigateTo(localePath('manifest') + '#skrol')
|
2024-01-24 18:54:28 +01:00
|
|
|
}
|
|
|
|
|
2024-07-24 14:38:45 +02:00
|
|
|
// Poskrolaj na pojem
|
|
|
|
poskrolaj(container.value.parentNode)
|
|
|
|
|
|
|
|
// Link na editiranje pojma? odpri editiranje
|
|
|
|
if (routeName.value.startsWith('pojem_uredi')) {
|
|
|
|
urediPojem()
|
2024-03-05 22:48:42 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
onUpdated(() => {
|
|
|
|
if (route.params.guid === revisionId.value) {
|
|
|
|
poskrolaj(obrazec.value)
|
2024-01-17 20:24:11 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2023-05-03 21:31:01 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-01-24 16:44:09 +01:00
|
|
|
<section ref="container">
|
2024-04-01 21:23:23 +02:00
|
|
|
<div v-if="!urejanje" class="gumb" @click="urediPojem">{{ $t('Uredi')}}</div>
|
2024-01-24 16:44:09 +01:00
|
|
|
<div v-if="pojem" class="pojem">
|
2024-05-31 17:44:04 +02:00
|
|
|
<h2>
|
2024-07-11 11:47:49 +02:00
|
|
|
{{ pojem.naslov }}
|
2024-06-14 13:45:13 +02:00
|
|
|
<StrojniPrevod v-if="pojem.strojni_prevod" />
|
2024-05-31 17:44:04 +02:00
|
|
|
</h2>
|
2023-12-16 01:53:05 +01:00
|
|
|
<div class="tekst" v-html="pojem.tekst" />
|
2023-11-13 00:22:34 +01:00
|
|
|
</div>
|
2024-03-05 22:48:42 +01:00
|
|
|
<div class="obrazec" ref="obrazec">
|
|
|
|
<PojemForm v-if="urejanje"
|
|
|
|
ref="obrazec"
|
|
|
|
:revisionId="revisionId"
|
|
|
|
:pojem="pojem"
|
2024-07-24 14:38:45 +02:00
|
|
|
:onZapri="() => navigateTo(localePath({ name: 'pojem_poglej', params: { pojemid: revisionId }}))" />
|
2024-03-05 22:48:42 +01:00
|
|
|
</div>
|
2023-05-03 21:31:01 +02:00
|
|
|
</section>
|
|
|
|
</template>
|
2023-12-08 15:00:40 +01:00
|
|
|
|
|
|
|
<style scoped>
|
2024-01-24 17:37:41 +01:00
|
|
|
section {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2024-01-19 15:29:25 +01:00
|
|
|
|
2024-01-24 16:44:09 +01:00
|
|
|
.pojem {
|
2024-01-07 22:33:20 +01:00
|
|
|
position: relative;
|
|
|
|
width: 50%;
|
2024-01-24 16:44:09 +01:00
|
|
|
float: left;
|
2024-01-07 22:33:20 +01:00
|
|
|
}
|
2024-01-19 15:29:25 +01:00
|
|
|
|
|
|
|
h2 {
|
|
|
|
text-transform: uppercase;
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
2024-01-24 16:44:09 +01:00
|
|
|
|
|
|
|
form.pojem {
|
2024-03-05 22:48:42 +01:00
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.obrazec {
|
2024-01-24 16:44:09 +01:00
|
|
|
width: calc(50% - 32px);
|
|
|
|
margin-left: 32px;
|
|
|
|
float: right;
|
|
|
|
}
|
|
|
|
|
2024-01-07 22:33:20 +01:00
|
|
|
.gumb {
|
2024-01-24 16:44:09 +01:00
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
2024-01-07 22:33:20 +01:00
|
|
|
right: 0;
|
2024-01-24 16:44:09 +01:00
|
|
|
float: right;
|
2024-01-07 22:33:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
2024-01-24 16:44:09 +01:00
|
|
|
.pojem {
|
2024-01-07 22:33:20 +01:00
|
|
|
min-height: 4rem;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2024-01-19 12:42:02 +01:00
|
|
|
|
2024-03-05 22:48:42 +01:00
|
|
|
.obrazec {
|
|
|
|
width: 100%;
|
2024-01-24 16:44:09 +01:00
|
|
|
margin-left: 0;
|
2024-03-05 22:48:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
form.pojem {
|
2024-01-24 16:44:09 +01:00
|
|
|
min-height: 70vh;
|
2024-03-05 14:34:46 +01:00
|
|
|
width: 100%;
|
|
|
|
margin-left: 0;
|
2024-01-07 22:33:20 +01:00
|
|
|
}
|
2024-01-06 18:48:22 +01:00
|
|
|
}
|
2023-12-08 15:00:40 +01:00
|
|
|
</style>
|