Skip to content

Commit 7335f59

Browse files
boubakerexo-swf
authored andcommitted
feat: Allow to Add Specific Translation field in Translation Reusable UI Component
1 parent 0bff3ff commit 7335f59

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

webapp/src/main/webapp/vue-apps/component-translation-field/components/TranslationDrawer.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
<template #title>
3131
{{ $t(title) }}
3232
</template>
33-
<template v-if="translations" #content>
33+
<template v-if="drawer && translations" #content>
3434
<v-form ref="form">
3535
<v-row
3636
v-for="(language, index) in existingLanguages"
3737
:key="language"
3838
class="mx-0 mb-0 mt-4 max-width-fit"
3939
no-gutters>
40-
<v-col cols="8" class="px-2">
40+
<v-col :cols="componentName ? 12 : 8" class="px-2">
4141
<v-card
4242
v-if="richEditor"
4343
class="text-truncate border-color rounder full-height pe-2 d-flex align-center"
@@ -55,6 +55,19 @@
5555
class="d-flex text-truncate full-width mt-2"
5656
flat />
5757
</v-card>
58+
<component
59+
v-else-if="componentName"
60+
:is="componentName"
61+
:name="`${language}-translation-value`"
62+
:value="translations[language]"
63+
:autofocus="language === defaultLanguage && 'autofocus'"
64+
:disabled="loading"
65+
:rules="rules || []"
66+
class="border-box-sizing pt-0"
67+
type="text"
68+
outlined
69+
dense
70+
@input="updateValue(language, $event)" />
5871
<v-text-field
5972
v-else
6073
:name="`${language}-translation-value`"
@@ -68,7 +81,7 @@
6881
dense
6982
@input="updateValue(language, $event)" />
7083
</v-col>
71-
<v-col cols="4">
84+
<v-col :cols="componentName ? 12 : 4" :class="componentName && 'order-first pb-1 px-2'">
7285
<div class="d-flex max-width-fit">
7386
<div class="flex-grow-1 text-truncate">
7487
<select
@@ -203,6 +216,10 @@ export default {
203216
type: Boolean,
204217
default: false
205218
},
219+
componentName: {
220+
type: String,
221+
default: null
222+
},
206223
},
207224
data: () => ({
208225
drawer: false,

webapp/src/main/webapp/vue-apps/component-translation-field/components/TranslationTextField.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
:rich-editor-oembed="richEditorOembed"
117117
:content-link-enabled="contentLinkEnabled"
118118
:no-expand-icon="noExpandIcon"
119+
:component-name="componentName"
119120
:rules="rules || []"
120121
@input="emitUpdateValues" />
121122
</div>
@@ -207,6 +208,10 @@ export default {
207208
type: Boolean,
208209
default: false
209210
},
211+
componentName: {
212+
type: String,
213+
default: null
214+
},
210215
},
211216
data: () => ({
212217
initialized: false,
@@ -249,6 +254,7 @@ export default {
249254
watch: {
250255
value: {
251256
immediate: true,
257+
deep: true,
252258
handler: function() {
253259
this.setValuesPerLanguage(this.value && JSON.parse(JSON.stringify(this.value)) || {});
254260
const defaultLanguageValue = this.defaultLocale && this.valuesPerLanguage[this.defaultLocale.replace('_', '-')] || '';

0 commit comments

Comments
 (0)