1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-07 18:25:45 +08:00

Support Option Traslation (#821)

* support trastation

* minimal changes

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-05-07 15:47:40 -04:00 committed by GitHub
parent a967a1f942
commit cc7fc71fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 13 deletions

View File

@ -42,7 +42,6 @@
size="medium"
style="width: 100%;"
filterable
@change="getTranslation"
>
<!-- <el-option
key="blank-option"
@ -58,17 +57,35 @@
</el-select>
</el-form-item>
<el-form-item
:label="$t('field.container.codeTranslation')"
:label="$t('field.codeTranslation') + fieldAttributes.name"
:required="true"
>
<el-input
v-model="translatedValue"
:disabled="isEmptyValue(langValue)"
@change="changeTranslationValue"
/>
</el-form-item>
</el-form>
</div>
<br>
<el-row>
<el-col :span="24">
<samp style="float: right; padding-right: 10px;">
<el-button
type="danger"
class="custom-button-address-location"
icon="el-icon-close"
@click="close()"
/>
<el-button
type="primary"
class="custom-button-address-location"
icon="el-icon-check"
@click="changeTranslationValue(translatedValue)"
/>
</samp>
</el-col>
</el-row>
</el-card>
</template>
@ -110,7 +127,7 @@ export default {
const values = this.$store.getters.getTranslationByLanguage({
containerUuid: this.fieldAttributes.containerUuid,
language: this.langValue,
recordUuid: this.recordUuid
recordUuid: this.fieldAttributes.recordUuid
})
if (this.isEmptyValue(values)) {
return undefined
@ -131,6 +148,7 @@ export default {
}
},
created() {
this.getTranslation()
let langMatch = this.languageList.find(itemLanguage => {
return itemLanguage.languageISO === getLanguage()
})
@ -151,7 +169,7 @@ export default {
this.isLoading = true
this.$store.dispatch('getTranslationsFromServer', {
containerUuid: this.fieldAttributes.containerUuid,
recordUuid: this.recordUuid,
recordUuid: this.fieldAttributes.recordUuid,
tableName: this.fieldAttributes.tableName,
language: this.langValue
})
@ -164,8 +182,14 @@ export default {
containerUuid: this.fieldAttributes.containerUuid,
language: this.langValue,
columnName: this.fieldAttributes.columnName,
recordUuid: this.fieldAttributes.recordUuid,
value
})
this.close()
},
close() {
this.$children[0].visible = false
this.$store.commit('changeShowRigthPanel', false)
}
}
}

View File

@ -145,7 +145,7 @@
<div v-if="option.name !== $t('language')" style="margin-right: 5%;padding-top: 3%;">
<i :class="option.icon" style="font-weight: bolder;" />
</div>
<div v-else style="margin-right: 5%">
<div v-else style="margin-right: 5%; padding-left: 8%;">
<svg-icon :icon-class="option.icon" style="margin-right: 5px;" />
</div>
<div>

View File

@ -330,7 +330,7 @@ export default {
info: 'Information',
calculator: 'Calculator',
preference: 'Preference',
codeTranslation: 'Traduccion de Codigo',
codeTranslation: 'Translation Of ',
container: {
help: 'Help',
description: 'Description'

View File

@ -306,7 +306,7 @@ export default {
info: 'Informacion',
calculator: 'Calculadora',
preference: 'Preferencia',
codeTranslation: 'Traduccion de Codigo',
codeTranslation: 'Traduccion de ',
container: {
help: 'Ayuda',
description: 'Descripción'

View File

@ -93,8 +93,7 @@ const languageControl = {
console.warn(translationResponse)
return
}
const { values, uuid } = translationResponse.translationsList[0]
const { values, uuid, language } = translationResponse.translationsList[0]
dispatch('setTranslation', {
containerUuid,
tableName,
@ -116,6 +115,7 @@ const languageControl = {
containerUuid,
language,
columnName,
recordUuid,
value
}) {
return new Promise(resolve => {
@ -125,7 +125,6 @@ const languageControl = {
const translationSelected = translationData.translations.find(itemTranslation => {
return itemTranslation.language === language
})
const values = translationSelected.values
// not change value
if (values[columnName] === value) {
@ -133,9 +132,9 @@ const languageControl = {
return value
}
requestUpdateEntity({
return requestUpdateEntity({
tableName: `${translationData.tableName}_Trl`, // '_Trl' is suffix for translation tables
recordUuid: translationSelected.uuid,
recordUuid,
attributesList: [{
columnName,
value
@ -151,6 +150,7 @@ const languageControl = {
newValues
})
resolve(newValues)
return newValues
})
.catch(error => {
console.warn(`Error Update Translation ${error.message}. Code: ${error.code}.`)