0
0
Fork 0

refs #5056 refresh list when delete

This commit is contained in:
Alexandre Riera 2023-03-23 10:34:22 +01:00
parent 8877f97e93
commit a92bc8c713
4 changed files with 33 additions and 12 deletions

View File

@ -401,13 +401,14 @@ export default {
submit: 'Submit', submit: 'Submit',
reset: 'Reset', reset: 'Reset',
trayColor: 'Tray color', trayColor: 'Tray color',
removeItem: 'Wagon type removed successfully',
}, },
list: { list: {
plate: 'Plate', plate: 'Plate',
volume: 'Volume', volume: 'Volume',
type: 'Type', type: 'Type',
remove: 'Remove' remove: 'Remove',
removeItem: 'Wagon removed successfully',
}, },
create: { create: {
plate: 'Plate', plate: 'Plate',

View File

@ -401,12 +401,14 @@ export default {
submit: 'Guardar', submit: 'Guardar',
reset: 'Deshacer cambios', reset: 'Deshacer cambios',
trayColor: 'Color de la bandeja', trayColor: 'Color de la bandeja',
removeItem: 'Tipo de vagón borrado correctamente',
}, },
list: { list: {
plate: 'Matrícula', plate: 'Matrícula',
volume: 'Volumen', volume: 'Volumen',
type: 'Tipo', type: 'Tipo',
remove: 'Borrar' remove: 'Borrar',
removeItem: 'Vagón borrado correctamente',
}, },
create: { create: {
plate: 'Matrícula', plate: 'Matrícula',

View File

@ -1,9 +1,15 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { useQuasar } from 'quasar';
import Paginate from 'src/components/PaginateData.vue'; import Paginate from 'src/components/PaginateData.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const quasar = useQuasar();
const arrayData = useArrayData('WagonTypeList');
const store = arrayData.store;
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
@ -15,13 +21,17 @@ function create() {
router.push({ path: `/wagon/type/create` }); router.push({ path: `/wagon/type/create` });
} }
async function remove(id) { async function remove(row) {
try { try {
const id = row.id;
await axios await axios
.delete(`WagonTypes/deleteWagonType`, { params: { id } }) .delete(`WagonTypes/deleteWagonType`, { params: { id } })
.then(async () => { .then(async () => {
// TODO: RELOAD PAGE quasar.notify({
// router.push({ path: `/wagon/type/list` }); message: t('wagon.type.removeItem'),
type: 'positive',
});
store.data.splice(store.data.indexOf(row), 1);
}); });
} catch (error) { } catch (error) {
// //
@ -67,7 +77,7 @@ async function remove(id) {
round round
color="primary" color="primary"
icon="delete" icon="delete"
@click="remove(row.id)" @click="remove(row)"
> >
<q-tooltip> <q-tooltip>
{{ t('wagon.list.remove') }} {{ t('wagon.list.remove') }}

View File

@ -1,9 +1,14 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { useQuasar } from 'quasar';
import Paginate from 'src/components/PaginateData.vue'; import Paginate from 'src/components/PaginateData.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const quasar = useQuasar();
const arrayData = useArrayData('WagonList');
const store = arrayData.store;
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
@ -24,11 +29,14 @@ function create() {
router.push({ path: `/wagon/create` }); router.push({ path: `/wagon/create` });
} }
async function remove(id) { async function remove(row) {
try { try {
await axios.delete(`Wagons/${id}`).then(async () => { await axios.delete(`Wagons/${row.id}`).then(async () => {
// TODO: RELOAD PAGE quasar.notify({
// router.push({ path: `/wagon/list` }); message: t('wagon.list.removeItem'),
type: 'positive',
});
store.data.splice(store.data.indexOf(row), 1);
}); });
} catch (error) { } catch (error) {
// //
@ -103,7 +111,7 @@ async function remove(id) {
round round
color="primary" color="primary"
icon="delete" icon="delete"
@click="remove(row.id)" @click="remove(row)"
> >
<q-tooltip> <q-tooltip>
{{ t('wagon.list.remove') }} {{ t('wagon.list.remove') }}