0
0
Fork 0

fix: refs #4774 fix front table

This commit is contained in:
Carlos Satorres 2024-10-18 07:55:02 +02:00
parent cd1c70850e
commit 4e8ffacea2
8 changed files with 137 additions and 69 deletions

View File

@ -826,7 +826,7 @@ export default {
notifications: 'Notifications', notifications: 'Notifications',
workerCreate: 'New worker', workerCreate: 'New worker',
department: 'Department', department: 'Department',
TraductionsVn: 'Traductions', TranslationsVn: 'Translations',
}, },
list: { list: {
name: 'Name', name: 'Name',

View File

@ -1,4 +1,4 @@
import TraductionsVn from 'src/pages/Worker/TraductionsVn.vue'; import TranslationsVn from 'src/pages/Worker/TranslationsVn.vue';
export default { export default {
globals: { globals: {
@ -819,6 +819,10 @@ export default {
hasToSendMail: 'Enviar fichadas por mail', hasToSendMail: 'Enviar fichadas por mail',
departmentRemoved: 'Departamento eliminado', departmentRemoved: 'Departamento eliminado',
}, },
TranslationsVn: {
OriginalLanguage: 'Idioma Original',
SecondLanguage: 'Idioma Secundario',
},
worker: { worker: {
pageTitles: { pageTitles: {
workers: 'Trabajadores', workers: 'Trabajadores',
@ -828,7 +832,7 @@ export default {
notifications: 'Notificaciones', notifications: 'Notificaciones',
workerCreate: 'Nuevo trabajador', workerCreate: 'Nuevo trabajador',
department: 'Departamentos', department: 'Departamentos',
TraductionsVn: 'Traducciones', TranslationsVn: 'Traducciones',
}, },
list: { list: {
name: 'Nombre', name: 'Nombre',
@ -890,14 +894,7 @@ export default {
bankEntity: 'Swift / BIC', bankEntity: 'Swift / BIC',
}, },
imageNotFound: 'No se ha encontrado la imagen', imageNotFound: 'No se ha encontrado la imagen',
},
TraductionsVn: {
pageTitles: {
TraductionsVn: 'Traducciones',
},
OriginalLanguage: 'Idioma Original',
SecondLanguage: 'Idioma Secundario',
},
wagon: { wagon: {
pageTitles: { pageTitles: {
wagons: 'Vagones', wagons: 'Vagones',

View File

@ -1,53 +0,0 @@
<script setup>
import { useStateStore } from 'src/stores/useStateStore';
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
const { t } = useI18n();
const columns = computed(() => [
{
name: 'originalLang',
label: t('OriginalLanguage'),
align: 'left',
},
{
name: 'secondLang',
label: t('SecondLanguage'),
align: 'left',
},
]);
</script>
<template>
<QDrawer v-model="useStateStore.rightDrawer" side="right" :width="300" show-if-above>
<VnSelectFilter
class="q-mb-md q-mt-xl"
outlined
v-model="model"
:options="options"
:label="t('Table')"
/>
<VnSelectFilter
class="q-mb-md"
outlined
v-model="model"
:options="options"
:label="t('Language')"
/>
<VnSelectFilter outlined v-model="model" :options="options" :label="t('Table')" />
</QDrawer>
<QTable
:rows="rows"
:columns="columns"
row-key="id"
class="full-width q-mt-md"
:grid="$q.screen.lt.md"
:no-data-label="t('globals.noResults')"
>
</QTable>
</template>
<i18n>
</i18n>

View File

@ -0,0 +1,104 @@
<script setup>
import { ref } from 'vue';
import { useStateStore } from 'src/stores/useStateStore';
import { computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import axios from 'axios';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n();
const columns = computed(() => [
{
align: 'left',
name: 'companyFk',
label: t('company18n'),
chip: {
condition: () => true,
},
isId: true,
},
{
align: 'left',
name: 'footnotes',
label: t('defaultLang(en)'),
},
{
align: 'left',
name: 'secondLang',
label: t('secondLang'),
},
]);
const tableRef = ref({});
const langs = ref([]);
const pk = ref('companyFk');
const value = ref('footnotes');
const lang = ref('es');
const originalData = ref();
const englishData = ref();
// onMounted(() => {
// loadTable();
// });
async function loadTable() {
console.log('lang.value.code: ', lang.value);
const data = tableRef.value.CrudModelRef.formData;
if (!originalData.value) originalData.value = data;
const en = originalData.value.filter((d) => d.lang === 'en');
for (const translation of en) {
translation['secondLang'] = originalData.value.find(
(d) => d[pk.value] == translation[pk.value] && d['lang'] == lang.value
)?.[value.value];
}
console.log('data: ', en);
tableRef.value.CrudModelRef.formData = en;
}
function resetOriginalData() {
originalData.value = null;
}
</script>
<template>
<FetchData url="Languages" @on-fetch="(data) => (langs = data)" auto-load />
<VnSubToolbar />
<VnTable
ref="tableRef"
data-key="translations"
url="CompanyI18ns"
:columns="columns"
:right-search="false"
:is-editable="true"
auto-load
@on-fetch="loadTable()"
>
<template #top-left>
<div class="row no-wrap q-gutter-x-sm">
<VnSelect
v-model="lang"
:options="langs"
option-label="code"
option-value="code"
@update:model-value="resetOriginalData()"
/>
<VnSelect
:label="t('lang')"
v-model="lang"
:options="langs"
option-label="code"
option-value="code"
@update:model-value="loadTable()"
/>
</div>
</template>
</VnTable>
</template>
<i18n>
</i18n>

View File

@ -22,6 +22,7 @@ import Account from './account';
import Monitor from './monitor'; import Monitor from './monitor';
import MailAlias from './mailAlias'; import MailAlias from './mailAlias';
import Role from './role'; import Role from './role';
import TranslationsVn from './translationsVn.js';
export default [ export default [
Item, Item,
@ -48,4 +49,5 @@ export default [
MailAlias, MailAlias,
Monitor, Monitor,
Role, Role,
TranslationsVn,
]; ];

View File

@ -0,0 +1,16 @@
import { RouterView } from 'vue-router';
export default {
path: '/translations',
name: 'Translations',
meta: {
title: 'translations',
icon: 'history_edu',
moduleName: 'Translations',
},
component: RouterView,
menus: {
main: [],
card: [],
},
};

View File

@ -12,7 +12,7 @@ export default {
component: RouterView, component: RouterView,
redirect: { name: 'WorkerMain' }, redirect: { name: 'WorkerMain' },
menus: { menus: {
main: ['WorkerList', 'WorkerDepartment', 'TraductionsVn'], main: ['WorkerList', 'WorkerDepartment', 'TranslationsVn'],
card: [ card: [
'WorkerBasicData', 'WorkerBasicData',
'WorkerNotes', 'WorkerNotes',
@ -55,13 +55,13 @@ export default {
component: () => import('src/pages/Worker/WorkerDepartment.vue'), component: () => import('src/pages/Worker/WorkerDepartment.vue'),
}, },
{ {
path: 'traductionsVn', path: 'translations',
name: 'TraductionsVn', name: 'TranslationsVn',
meta: { meta: {
title: 'TraductionsVn', title: 'translations',
icon: 'history_edu', icon: 'history_edu',
}, },
component: () => import('src/pages/Worker/TraductionsVn.vue'), component: () => import('src/pages/Worker/TranslationsVn.vue'),
}, },
{ {
path: 'create', path: 'create',

View File

@ -22,6 +22,7 @@ import zone from 'src/router/modules/zone';
import account from './modules/account'; import account from './modules/account';
import monitor from 'src/router/modules/monitor'; import monitor from 'src/router/modules/monitor';
import mailAlias from './modules/mailAlias'; import mailAlias from './modules/mailAlias';
import translationsVn from './modules/translationsVn';
const routes = [ const routes = [
{ {
@ -97,6 +98,7 @@ const routes = [
account, account,
role, role,
mailAlias, mailAlias,
translationsVn,
{ {
path: '/:catchAll(.*)*', path: '/:catchAll(.*)*',
name: 'NotFound', name: 'NotFound',