Created
November 22, 2018 09:03
-
-
Save nulpatrol/a85a2218b33683fcdd8eded1a09602ea to your computer and use it in GitHub Desktop.
Locales.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div v-show="showComponent" class="form-group__bordered"> | |
<h4 class="text-center" v-if="groupName.length > 0"> | |
{{ groupName }} | |
</h4> | |
<div class="form-group" | |
v-for="locale in localesAll" | |
:key="locale.id"> | |
<label :for="`localized-value-${locale.abbr}`"> | |
{{ $t('translation.valueForLocale') }} {{ locale.abbr.toUpperCase() }} | |
</label> | |
<input :id="`localized-value-${locale.abbr}`" | |
type="text" | |
class="form-control" | |
:name="`localized-value-${locale.abbr}`" | |
v-validate="'required|max:255'" | |
v-model="values[locale.id]" | |
@change="updateValues" | |
required | |
/> | |
<small class="invalid-feedback"> | |
{{ errors.first('attributesForm.attribute-type') }} | |
</small> | |
</div> | |
</div> | |
</template> | |
<script> | |
import localesMixin from '../../mixins/locales'; | |
export default { | |
mixins: [localesMixin], | |
props: { | |
groupName: { | |
type: String, | |
default: '', | |
}, | |
value: { | |
type: Object, | |
required: true, | |
}, | |
}, | |
data() { | |
return { | |
values: {}, | |
showComponent: false, | |
}; | |
}, | |
watch: { | |
value() { | |
this.values = JSON.parse(JSON.stringify(this.value)); | |
}, | |
}, | |
async mounted() { | |
this.showComponent = true; | |
this.values = JSON.parse(JSON.stringify(this.value)); | |
}, | |
methods: { | |
updateValues() { | |
this.$emit('input', this.values); | |
}, | |
}, | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment