Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[S97.PS001] categoria-assunto #112

Open
wants to merge 1 commit into
base: homol
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions frontend/src/router/administracao.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useResourcesStore,
useDocumentTypesStore,
} from '@/stores';
import { useAssuntosStore } from '@/stores/assuntosPs.store';

import LoadingComponent from '@/components/LoadingComponent.vue';
import { Administracao } from '@/views';
Expand Down Expand Up @@ -93,7 +94,7 @@ const rotasParaMenuSecundário = [
'equipamentosLista',
'tipoDeAditivosListar',
'variaveisCategoricasListar',
'categoriaAssuntosListar',
'categoriaAssunto.listar',
'assuntosListar',
'modalidadesListar',
'fontesListar',
Expand Down Expand Up @@ -990,29 +991,29 @@ export default [
component: () => import('@/views/ps.categoriaAssunto/CategoriaAssuntoRaiz.vue'),
meta: {
limitarÀsPermissões: 'AssuntoVariavel.',
título: 'Categoria de Assuntos',
rotasParaMenuSecundário,
},
children: [
{
name: 'categoriaAssuntosListar',
name: 'categoriaAssunto.listar',
path: '',
component: () => import('@/views/ps.categoriaAssunto/CategoriaAssuntoLista.vue'),
meta: {
título: 'Categoria de Assuntos',
},
},
{
name: 'categoriaAssuntosCriar',
name: 'categoriaAssunto.novo',
path: 'novo',
component: () => import('@/views/ps.categoriaAssunto/CategoriaAssuntoCriarEditar.vue'),
meta: {
título: 'Nova categoria de assunto',
rotasParaMigalhasDePão: ['categoriaAssuntosListar'],
rotasParaMigalhasDePão: ['categoriaAssunto.listar'],
rotaDeEscape: 'categoriaAssunto.listar',
},
},
{
name: 'categoriaAssuntosEditar',
name: 'categoriaAssunto.editar',
path: ':categoriaAssuntoId',
component: () => import('@/views/ps.categoriaAssunto/CategoriaAssuntoCriarEditar.vue'),
props: ({ params }) => ({
Expand All @@ -1022,10 +1023,10 @@ export default [
Number.parseInt(params.categoriaAssuntoId, 10) || undefined,
},
}),

meta: {
título: 'Editar categoria de assunto',
rotasParaMigalhasDePão: ['categoriaAssuntosListar'],
título: () => useAssuntosStore().categoriaParaEdicao.nome,
rotasParaMigalhasDePão: ['categoriaAssunto.listar'],
rotaDeEscape: 'categoriaAssunto.listar',
},
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<template>
<MigalhasDePão class="mb1" />

<header class="flex spacebetween center mb2">
<TítuloDePágina />

<hr class="ml2 f1">
<CheckClose />

<CheckClose :formulario-sujo="formularioSujo" />
</header>

<Form
Expand Down Expand Up @@ -53,7 +56,9 @@
<span
v-if="chamadasPendentes?.emFoco"
class="spinner"
>Carregando</span>
>
Carregando
</span>

<div
v-if="erro"
Expand All @@ -66,12 +71,14 @@
</template>

<script setup>
import { storeToRefs } from 'pinia';
import {
ErrorMessage, Field, Form, useIsFormDirty,
} from 'vee-validate';
import { useRoute, useRouter } from 'vue-router';
import { categoriaAssunto as schema } from '@/consts/formSchemas';
import { useAlertStore } from '@/stores/alert.store';
import { useAssuntosStore } from '@/stores/assuntosPs.store';
import { storeToRefs } from 'pinia';
import { ErrorMessage, Field, Form } from 'vee-validate';
import { useRoute, useRouter } from 'vue-router';

const router = useRouter();
const route = useRoute();
Expand All @@ -82,6 +89,8 @@ const props = defineProps({
},
});

const formularioSujo = useIsFormDirty();

const alertStore = useAlertStore();
const assuntosStore = useAssuntosStore();
const {
Expand All @@ -108,7 +117,7 @@ async function onSubmit(values) {
if (response) {
alertStore.success(msg);
assuntosStore.$reset();
router.push({ name: 'categoriaAssuntosListar' });
router.push({ name: route.meta.rotaDeEscape });
}
} catch (error) {
alertStore.error(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TítuloDePágina />
<hr class="ml2 f1">
<SmaeLink
:to="{ name: 'categoriaAssuntosCriar' }"
:to="{ name: 'categoriaAssunto.novo' }"
class="btn big ml1"
>
Nova categoria de assunto
Expand Down Expand Up @@ -37,7 +37,7 @@
<td>
<router-link
:to="{
name: 'categoriaAssuntosEditar',
name: 'categoriaAssunto.editar',
params: { categoriaAssuntoId: item.id }
}"
class="tprimary"
Expand All @@ -58,7 +58,7 @@
<svg
width="20"
height="20"
><use xlink:href="#i_remove" /></svg>
><use xlink:href="#i_waste" /></svg>
</button>
</td>
</tr>
Expand Down