Commit 534a6da2 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

move content suggestion logic into separate component

parent a6e06b2b
<template>
<app-markdown>
<i18n :path="missingTextTranslationKey">
<template v-slot:suggest_content
v-if="suggestData">{{ '\n' + $t('suggest_content.suggest', suggestData) }}</template>
</i18n>
</app-markdown>
</template>
<script>
import { renderSimpleTemplateString } from '../../util'
export default {
props: {
missingTextTranslationKey: String,
context: Object
},
computed: {
suggestData () {
const { suggestContent: suggest } = this.env
if (suggest) {
const subject = renderSimpleTemplateString(suggest.subject, this.context)
return {
suggest_name: suggest.name,
suggest_address: `mailto:${suggest.address}?subject=${encodeURIComponent(subject)}`
}
}
return null
}
},
inject: ['env']
}
</script>
<i18n lang="yaml">
en:
suggest_content.suggest: >
Maybe you can help by suggesting one?
Write to [{suggest_name}]({suggest_address}).
de:
suggest_content.suggest: >
Vielleicht kannst Du aushelfen und hast einen Vorschlag?
Schreib an [{suggest_name}]({suggest_address}).
</i18n>
{}
{
"recording_page.missing_description": "Zwar hat sich eine Person die Mühe gemacht, diesen Beitrag in die Mediathek einzustellen, aber leider fehlte ihr die Zeit oder die Möglichkeiten eine Beschreibung hinzuzufügen.\n\n{suggest_content}",
"series_page.missing_description": "Leider hatte bisher niemand die Zeit oder die Möglichkeiten eine Beschreibung für diese Sendereihe hinzuzufügen.\n\n{suggest_content}"
}
{}
{
"recording_page.missing_description": "Though someone made the effort to add this post, they didn’t have the time or means to add a proper description.\n\n{suggest_content}",
"series_page.missing_description": "Nobody had the time or means to add a proper description for this program yet.\n\n{suggest_content}"
}
......@@ -17,12 +17,8 @@
<app-header :title="$t('recording_page.info')" :level="2" :display-level="4" class="mb-3"/>
<div class="mb-2">
<app-markdown v-if="recording.description">{{ recording.description }}</app-markdown>
<app-markdown v-else>
<i18n path="recording_page.missing_description">
<template v-slot:suggest_content
v-if="suggestData">{{ '\n' + $t('recording_page.suggest_content', suggestData) }}</template>
</i18n>
</app-markdown>
<SuggestContent v-else missing-text-translation-key="recording_page.missing_description"
:context="recording"/>
</div>
<app-field>
<ul class="d-inline hyphens ma-0 pa-0 opaque-7">
......@@ -62,13 +58,13 @@
<script>
import RecordingPreview from '../components/model/RecordingPreview'
import { renderSimpleTemplateString } from '../util'
import { recordingTracks } from '../components/model/mixins'
import PlayPauseButton from '../components/player/PlayPauseButton'
import License from '../components/generic/License'
import SuggestContent from '../components/generic/SuggestContent'
export default {
components: { License, PlayPauseButton, RecordingPreview },
components: { License, PlayPauseButton, RecordingPreview, SuggestContent },
mixins: [recordingTracks],
props: {
recording: {
......@@ -83,17 +79,6 @@
omit: this.recording.id,
is_available: 1
}
},
suggestData () {
if (this.env.suggestContent) {
const suggest = this.env.suggestContent
const subject = renderSimpleTemplateString(suggest.subject, this.recording)
return {
suggest_name: suggest.name,
suggest_address: `mailto:${suggest.address}?subject=${encodeURIComponent(subject)}`
}
}
return null
}
},
inject: ['dataSources', 'env']
......@@ -107,14 +92,6 @@
recording_page.similar_recordings: Similar Posts
recording_page.no_similar_recordings: >
Unfortunately we didn’t find any similar content for this post.
recording_page.missing_description: >
Though someone made the effort to add this post, they didn’t have the time or means
to add a proper description.
{suggest_content}
recording_page.suggest_content: >
Maybe you can help by suggesting one?
Write to [{suggest_name}]({suggest_address}).
de:
recording_page.download_name: Beitrag
recording_page.info: Über diesen Beitrag
......@@ -122,13 +99,4 @@
recording_page.no_similar_recordings: >
Leider haben wir zu diesem Beitrag keine ähnlichen Inhalte gefunden, die wir
Dir hier präsentieren könnten.
recording_page.missing_description: >
Zwar hat sich eine Person die Mühe gemacht, diesen Beitrag in die Mediathek
einzustellen, aber leider fehlte ihr die Zeit oder die Möglichkeiten eine
Beschreibung hinzuzufügen.
{suggest_content}
recording_page.suggest_content: >
Vielleicht kannst Du aushelfen und hast einen Vorschlag?
Schreib an [{suggest_name}]({suggest_address}).
</i18n>
<template>
<app-page :title="series.name">
<app-container class="my-5">
<app-header :title="series.name" class="mb-4"/>
<app-header :title="series.name" class="mb-3"/>
<div class="mb-2">
<app-markdown v-if="series.description">{{ series.description }}</app-markdown>
<SuggestContent v-else missing-text-translation-key="series_page.missing_description"
:context="series"/>
</div>
<app-auto-grid>
<div>
<h2 class="t-4 mt-5">Kommende Sendungen</h2>
......@@ -12,8 +17,10 @@
</template>
<script>
import SuggestContent from '../components/generic/SuggestContent'
export default {
name: 'SeriesPage',
components: { SuggestContent },
props: {
series: Object
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment