2020-07-22 13:19:23 -07:00
|
|
|
|
<template>
|
2021-08-07 01:04:47 -07:00
|
|
|
|
<LazyHydrate when-visible>
|
2021-07-22 11:33:18 -07:00
|
|
|
|
<div class="my-2 clearfix" v-if="!deleted">
|
2021-01-04 15:07:10 -08:00
|
|
|
|
<h3 class="h6">
|
|
|
|
|
<Icon :v="source.icon()"/>
|
2021-03-19 12:37:47 -07:00
|
|
|
|
<strong><Spelling v-if="source.author" :text="source.author.replace('^', '')"/><span v-if="source.author"> – </span><em><a v-if="source.link" :href="source.link" target="_blank" rel="noopener"><Spelling :text="addMarks(source.title)"></Spelling></a><Spelling v-else :text="addMarks(source.title)"></Spelling></em></strong><template v-if="source.extra"> (<Spelling :text="source.extra"/>)</template>, {{source.year}}<template v-if="source.comment">; <Spelling :text="source.comment"/></template>
|
2021-01-04 15:07:10 -08:00
|
|
|
|
</h3>
|
2020-12-30 15:03:30 -08:00
|
|
|
|
<ul class="list-inline" v-if="manage && $isGranted('sources')">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<li v-if="!source.approved" class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<span class="badge bg-danger">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="map-marker-question"/>
|
|
|
|
|
<T>nouns.pending</T>
|
|
|
|
|
</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li v-if="source.submitter" class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<nuxt-link :to="`/@${source.submitter}`" class="badge bg-light text-dark border btn-sm m-1">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="user"/>
|
|
|
|
|
<span class="btn-label">
|
|
|
|
|
<T>crud.author</T>:
|
|
|
|
|
@{{source.submitter}}
|
|
|
|
|
</span>
|
|
|
|
|
</nuxt-link>
|
|
|
|
|
</li>
|
|
|
|
|
<li v-if="!source.approved" class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<a href="#" class="badge bg-success btn-sm m-1" @click.prevent="approve()">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="check"/>
|
|
|
|
|
<span class="btn-label"><T>crud.approve</T></span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li v-else class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<a href="#" class="badge bg-light text-dark border border-secondary btn-sm m-1" @click.prevent="hide()">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="times"/>
|
|
|
|
|
<span class="btn-label"><T>crud.hide</T></span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<a href="#" class="badge bg-light text-dark border border-danger btn-sm m-1" @click.prevent="remove()">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="trash"/>
|
|
|
|
|
<span class="btn-label"><T>crud.remove</T></span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="list-inline-item">
|
2021-01-22 14:54:24 -08:00
|
|
|
|
<a href="#" class="badge bg-light text-dark border border-primary btn-sm m-1" @click.prevent="$emit('edit-source', source)">
|
2020-12-05 11:37:10 -08:00
|
|
|
|
<Icon v="pen"/>
|
|
|
|
|
<span class="btn-label">
|
|
|
|
|
<T>crud.edit</T>
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="list-inline-item">
|
2021-03-24 11:29:25 -07:00
|
|
|
|
<span v-for="p in source.pronouns" :class="['badge', pronounLibrary.isCanonical(p) || (config.sources.extraTypes || []).includes(p) ? 'bg-success' : 'bg-danger', 'm-1']">
|
2021-03-19 12:34:34 -07:00
|
|
|
|
<Spelling :text="p"/>
|
2020-12-05 11:37:10 -08:00
|
|
|
|
</span>
|
|
|
|
|
</li>
|
2021-01-04 13:46:57 -08:00
|
|
|
|
<li class="list-inline-item" v-if="source.key">
|
2021-04-01 09:24:47 -07:00
|
|
|
|
<span class="badge bg-primary text-white">
|
2021-01-04 13:46:57 -08:00
|
|
|
|
<T>sources.submit.key</T>: {{source.key}}
|
|
|
|
|
</span>
|
|
|
|
|
</li>
|
2020-12-05 11:37:10 -08:00
|
|
|
|
</ul>
|
2021-01-07 13:18:52 -08:00
|
|
|
|
<div v-if="source.images.length" class="source-images">
|
2021-04-18 13:28:37 -07:00
|
|
|
|
<ImageThumb v-for="image in source.images" :key="image" :id="image" class="m-2" size="8rem"/>
|
2021-01-06 10:31:47 -08:00
|
|
|
|
</div>
|
2020-07-22 13:19:23 -07:00
|
|
|
|
<ul v-if="source.fragments.length">
|
2021-07-22 11:55:50 -07:00
|
|
|
|
<li v-for="fragment in source.fragments" class="text-break">
|
2021-11-15 13:17:50 -08:00
|
|
|
|
<T>quotation.start</T><Spelling :text="addMarks(fragment.replace(/\n/g, '<br/>'))"></Spelling><T>quotation.end</T>
|
2020-07-22 13:19:23 -07:00
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2021-01-04 15:07:10 -08:00
|
|
|
|
<div v-if="source.versions.length" class="my-3">
|
2021-01-06 08:11:26 -08:00
|
|
|
|
<p>
|
|
|
|
|
<button :class="['btn', versionsShown ? 'btn-primary' : 'btn-outline-primary', 'btn-sm']" @click="versionsShown = !versionsShown">
|
|
|
|
|
<Icon v="language"/>
|
|
|
|
|
<T>sources.otherVersions</T>
|
|
|
|
|
<Icon :v="versionsShown ? 'caret-up' : 'caret-down'"/>
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
2021-07-22 11:33:18 -07:00
|
|
|
|
<ul v-if="versionsShown" class="clearfix">
|
2021-07-22 11:20:48 -07:00
|
|
|
|
<li v-for="version in source.versions" v-if="locales[version.locale] !== undefined">
|
2021-01-06 08:11:26 -08:00
|
|
|
|
<h4 class="h6 mb-2">
|
2021-01-04 15:07:10 -08:00
|
|
|
|
<strong>
|
|
|
|
|
<a :href="`${locales[version.locale].url}/${version.pronouns[0]}`" target="_blank" rel="noopener">{{locales[version.locale].name}}</a>:
|
|
|
|
|
</strong>
|
|
|
|
|
</h4>
|
|
|
|
|
<Source :source="version"/>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2020-07-22 13:19:23 -07:00
|
|
|
|
</div>
|
2021-08-07 01:04:47 -07:00
|
|
|
|
</LazyHydrate>
|
2020-07-22 13:19:23 -07:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-12-05 11:37:10 -08:00
|
|
|
|
import {pronounLibrary} from "../src/data";
|
2021-08-07 01:04:47 -07:00
|
|
|
|
import LazyHydrate from 'vue-lazy-hydration';
|
2020-12-05 11:37:10 -08:00
|
|
|
|
|
2020-07-22 13:19:23 -07:00
|
|
|
|
export default {
|
2021-08-07 01:04:47 -07:00
|
|
|
|
components: { LazyHydrate },
|
2020-07-22 13:19:23 -07:00
|
|
|
|
props: {
|
2020-11-09 11:11:47 -08:00
|
|
|
|
source: { required: true },
|
2020-12-05 11:37:10 -08:00
|
|
|
|
manage: { type: Boolean },
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
pronounLibrary,
|
|
|
|
|
deleted: false,
|
2021-01-06 08:11:26 -08:00
|
|
|
|
versionsShown: false,
|
2020-12-05 11:37:10 -08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async approve() {
|
2021-06-09 09:06:32 -07:00
|
|
|
|
await this.$post(`/sources/approve/${this.source.id}`);
|
2020-12-05 11:37:10 -08:00
|
|
|
|
this.source.approved = true;
|
|
|
|
|
this.source.base = null;
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
},
|
|
|
|
|
async hide() {
|
2021-06-09 09:06:32 -07:00
|
|
|
|
await this.$post(`/sources/hide/${this.source.id}`);
|
2020-12-05 11:37:10 -08:00
|
|
|
|
this.source.approved = false;
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
},
|
|
|
|
|
async remove() {
|
|
|
|
|
await this.$confirm(this.$t('crud.removeConfirm'), 'danger');
|
|
|
|
|
|
2021-06-09 09:06:32 -07:00
|
|
|
|
await this.$post(`/sources/remove/${this.source.id}`);
|
2020-12-05 11:37:10 -08:00
|
|
|
|
this.deleted = true;
|
|
|
|
|
this.$forceUpdate();
|
|
|
|
|
},
|
2021-01-23 00:49:03 -08:00
|
|
|
|
addMarks(t) {
|
|
|
|
|
return t.replace(/\[\[/g, '<mark>').replace(/]]/g, '</mark>');
|
|
|
|
|
}
|
2020-07-22 13:19:23 -07:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2021-01-07 13:18:52 -08:00
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
@import "assets/variables";
|
|
|
|
|
|
|
|
|
|
@include media-breakpoint-down('sm', $grid-breakpoints) {
|
|
|
|
|
.source-images {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@include media-breakpoint-up('md', $grid-breakpoints) {
|
|
|
|
|
.source-images {
|
|
|
|
|
float: right;
|
|
|
|
|
max-width: 18rem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|