mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refactor ContributionForm to deal with posts with no languages
This commit is contained in:
parent
a099c209a8
commit
614a7eebc1
@ -15,7 +15,7 @@
|
|||||||
model="language"
|
model="language"
|
||||||
:options="form.languageOptions"
|
:options="form.languageOptions"
|
||||||
icon="globe"
|
icon="globe"
|
||||||
:placeholder="locale"
|
:placeholder="form.placeholder"
|
||||||
:label="$t('contribution.languageSelectLabel')"
|
:label="$t('contribution.languageSelectLabel')"
|
||||||
/>
|
/>
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
@ -64,6 +64,7 @@ export default {
|
|||||||
content: '',
|
content: '',
|
||||||
language: null,
|
language: null,
|
||||||
languageOptions: [],
|
languageOptions: [],
|
||||||
|
placeholder: '',
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
title: { required: true, min: 3, max: 64 },
|
title: { required: true, min: 3, max: 64 },
|
||||||
@ -88,13 +89,15 @@ export default {
|
|||||||
this.form.content = contribution.content
|
this.form.content = contribution.content
|
||||||
this.form.title = contribution.title
|
this.form.title = contribution.title
|
||||||
this.form.language = this.locale
|
this.form.language = this.locale
|
||||||
|
this.form.placeholder = this.locale
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
locale() {
|
locale() {
|
||||||
let locale
|
const locale = this.contribution.language
|
||||||
locale = locales.find(this.returnLocaleName)
|
? locales.find(loc => this.contribution.language === loc.code)
|
||||||
|
: locales.find(loc => this.$i18n.locale() === loc.code)
|
||||||
return locale.name
|
return locale.name
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -137,14 +140,6 @@ export default {
|
|||||||
// this.form.content = value
|
// this.form.content = value
|
||||||
this.$refs.contributionForm.update('content', value)
|
this.$refs.contributionForm.update('content', value)
|
||||||
},
|
},
|
||||||
returnLocaleName(locale) {
|
|
||||||
if (
|
|
||||||
(this.contribution && this.contribution.language === locale.code) ||
|
|
||||||
(!this.contribution && this.$i18n.locale() === locale.code)
|
|
||||||
) {
|
|
||||||
return locale
|
|
||||||
}
|
|
||||||
},
|
|
||||||
availableLocales() {
|
availableLocales() {
|
||||||
orderBy(locales, 'name').map(locale => {
|
orderBy(locales, 'name').map(locale => {
|
||||||
this.form.languageOptions.push({ label: locale.name, value: locale.code })
|
this.form.languageOptions.push({ label: locale.name, value: locale.code })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user