1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +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" size="medium"
style="width: 100%;" style="width: 100%;"
filterable filterable
@change="getTranslation"
> >
<!-- <el-option <!-- <el-option
key="blank-option" key="blank-option"
@ -58,17 +57,35 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('field.container.codeTranslation')" :label="$t('field.codeTranslation') + fieldAttributes.name"
:required="true" :required="true"
> >
<el-input <el-input
v-model="translatedValue" v-model="translatedValue"
:disabled="isEmptyValue(langValue)" :disabled="isEmptyValue(langValue)"
@change="changeTranslationValue"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </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> </el-card>
</template> </template>
@ -110,7 +127,7 @@ export default {
const values = this.$store.getters.getTranslationByLanguage({ const values = this.$store.getters.getTranslationByLanguage({
containerUuid: this.fieldAttributes.containerUuid, containerUuid: this.fieldAttributes.containerUuid,
language: this.langValue, language: this.langValue,
recordUuid: this.recordUuid recordUuid: this.fieldAttributes.recordUuid
}) })
if (this.isEmptyValue(values)) { if (this.isEmptyValue(values)) {
return undefined return undefined
@ -131,6 +148,7 @@ export default {
} }
}, },
created() { created() {
this.getTranslation()
let langMatch = this.languageList.find(itemLanguage => { let langMatch = this.languageList.find(itemLanguage => {
return itemLanguage.languageISO === getLanguage() return itemLanguage.languageISO === getLanguage()
}) })
@ -151,7 +169,7 @@ export default {
this.isLoading = true this.isLoading = true
this.$store.dispatch('getTranslationsFromServer', { this.$store.dispatch('getTranslationsFromServer', {
containerUuid: this.fieldAttributes.containerUuid, containerUuid: this.fieldAttributes.containerUuid,
recordUuid: this.recordUuid, recordUuid: this.fieldAttributes.recordUuid,
tableName: this.fieldAttributes.tableName, tableName: this.fieldAttributes.tableName,
language: this.langValue language: this.langValue
}) })
@ -164,8 +182,14 @@ export default {
containerUuid: this.fieldAttributes.containerUuid, containerUuid: this.fieldAttributes.containerUuid,
language: this.langValue, language: this.langValue,
columnName: this.fieldAttributes.columnName, columnName: this.fieldAttributes.columnName,
recordUuid: this.fieldAttributes.recordUuid,
value 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%;"> <div v-if="option.name !== $t('language')" style="margin-right: 5%;padding-top: 3%;">
<i :class="option.icon" style="font-weight: bolder;" /> <i :class="option.icon" style="font-weight: bolder;" />
</div> </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;" /> <svg-icon :icon-class="option.icon" style="margin-right: 5px;" />
</div> </div>
<div> <div>

View File

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

View File

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

View File

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