poc
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-05-31 11:34:34 +02:00
parent 5799a1121b
commit 4fe720c090
2 changed files with 20 additions and 11 deletions

View File

@ -0,0 +1,16 @@
import { useRouter, useRoute } from 'vue-router';
export function useNavigate() {
const router = useRouter();
const route = useRoute();
function navigate(id, action = 'Card') {
router.push({ name: `${route.meta.moduleName}${action}`, params: { id } });
}
function redirectToView(name, action = 'Create') {
router.push({ name: name ?? `${route.meta.moduleName}${action}` });
}
return { navigate, redirectToView };
}

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import CardList from 'src/components/ui/CardList.vue'; import CardList from 'src/components/ui/CardList.vue';
@ -11,20 +10,14 @@ import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters/index'; import { toDate } from 'src/filters/index';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useNavigate } from 'src/composables/useNavigate';
const stateStore = useStateStore(); const stateStore = useStateStore();
const router = useRouter(); const { redirectToView, navigate } = useNavigate();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
function navigate(id) {
router.push({ path: `/entry/${id}` });
}
const redirectToCreateView = () => {
router.push({ name: 'EntryCreate' });
};
onMounted(async () => { onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
}); });
@ -121,7 +114,7 @@ onMounted(async () => {
</div> </div>
</QPage> </QPage>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" /> <QBtn fab icon="add" color="primary" @click="redirectToView()" />
<QTooltip> <QTooltip>
{{ t('entry.list.newEntry') }} {{ t('entry.list.newEntry') }}
</QTooltip> </QTooltip>