ref #6248 breadcrumbs created #99
|
@ -7,6 +7,7 @@ import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import PinnedModules from './PinnedModules.vue';
|
import PinnedModules from './PinnedModules.vue';
|
||||||
import UserPanel from 'components/UserPanel.vue';
|
import UserPanel from 'components/UserPanel.vue';
|
||||||
|
import VnBreadcrumbs from './common/VnBreadcrumbs.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
@ -57,10 +58,7 @@ const pinnedModulesRef = ref();
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<QToolbarTitle shrink class="text-weight-bold" v-if="$q.screen.gt.sm">
|
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
|
||||||
{{ appName }}
|
|
||||||
<QBadge label="Beta" align="top" />
|
|
||||||
</QToolbarTitle>
|
|
||||||
<QSpace />
|
<QSpace />
|
||||||
<div id="searchbar" class="searchbar"></div>
|
<div id="searchbar" class="searchbar"></div>
|
||||||
<QSpace />
|
<QSpace />
|
||||||
|
@ -112,6 +110,7 @@ const pinnedModulesRef = ref();
|
||||||
<div id="actions-append"></div>
|
<div id="actions-append"></div>
|
||||||
</div>
|
</div>
|
||||||
</QToolbar>
|
</QToolbar>
|
||||||
|
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||||
</QHeader>
|
</QHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<script setup>
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { ref, watchEffect } from 'vue';
|
||||||
|
import { useQuasar } from 'quasar';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useCamelCase } from 'src/composables/useCamelCase';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const quasar = useQuasar();
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
let matched = ref([]);
|
||||||
|
let breadcrumbs = ref([]);
|
||||||
|
let root = ref(null);
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
matched.value = router.currentRoute.value.matched.filter(
|
||||||
|
(matched) => Object.keys(matched.meta).length
|
||||||
|
);
|
||||||
|
breadcrumbs.value.length = 0;
|
||||||
|
|
||||||
|
if (matched.value[0].name != 'Dashboard') {
|
||||||
|
root.value = useCamelCase(matched.value[0].path.substring(1).toLowerCase());
|
||||||
|
|
||||||
|
for (let index in matched.value)
|
||||||
|
breadcrumbs.value.push(getBreadcrumb(matched.value[index]));
|
||||||
|
|
||||||
|
breadcrumbs.value[breadcrumbs.value.length - 1].path = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getBreadcrumb(param) {
|
||||||
|
const breadcrumb = {
|
||||||
|
icon: param.meta.icon,
|
||||||
|
path: param.path,
|
||||||
|
root: root.value,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (quasar.screen.gt.sm) {
|
||||||
|
breadcrumb.name = param.name;
|
||||||
|
breadcrumb.title = useCamelCase(param.meta.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return breadcrumb;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<QBreadcrumbs v-if="breadcrumbs.length && $q.screen.gt.sm" class="q-pa-xs">
|
||||||
|
<QBreadcrumbsEl
|
||||||
|
v-for="(breadcrumb, index) of breadcrumbs"
|
||||||
|
:key="index"
|
||||||
|
:icon="breadcrumb.icon"
|
||||||
|
:label="t(`${breadcrumb.root}.pageTitles.${breadcrumb.title}`)"
|
||||||
|
:to="breadcrumb.path"
|
||||||
|
/>
|
||||||
|
</QBreadcrumbs>
|
||||||
|
<QBreadcrumbs v-else class="q-pa-xs">
|
||||||
|
<QBreadcrumbsEl
|
||||||
|
v-for="(breadcrumb, index) of breadcrumbs"
|
||||||
|
:key="index"
|
||||||
|
:icon="breadcrumb.icon"
|
||||||
|
:to="breadcrumb.path"
|
||||||
|
/>
|
||||||
|
</QBreadcrumbs>
|
||||||
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.q-breadcrumbs {
|
||||||
|
&__el,
|
||||||
|
> div {
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: $breakpoint-md) {
|
||||||
|
.q-breadcrumbs {
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&__el:not(:first-child):not(:last-child) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -105,7 +105,11 @@ async function search() {
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<QIcon v-if="props.info" name="info" class="cursor-info">
|
<QIcon
|
||||||
|
v-if="props.info && $q.screen.gt.xs"
|
||||||
|
name="info"
|
||||||
|
class="cursor-info"
|
||||||
|
>
|
||||||
<QTooltip>{{ props.info }}</QTooltip>
|
<QTooltip>{{ props.info }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function useCamelCase(value) {
|
||||||
|
return value.replace(/[-_](.)/g, (_, char) => char.toUpperCase());
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
export function useFirstUpper(str) {
|
||||||
|
return str && str.charAt(0).toUpperCase() + str.substr(1);
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<script setup>
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import LeftMenu from 'components/LeftMenu.vue';
|
||||||
|
|
||||||
|
const stateStore = useStateStore();
|
||||||
|
const route = useRoute();
|
||||||
|
const { t } = useI18n();
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
|
||||||
|
<QScrollArea class="fit">
|
||||||
|
<QSeparator />
|
||||||
|
<LeftMenu source="card" />
|
||||||
|
</QScrollArea>
|
||||||
|
</QDrawer>
|
||||||
|
<QPageContainer>
|
||||||
|
<QPage>
|
||||||
|
<div class="q-pa-md"><RouterView></RouterView></div>
|
||||||
|
</QPage>
|
||||||
|
</QPageContainer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Search customer: Buscar cliente
|
||||||
|
You can search by customer id or name: Puedes buscar por id o nombre del cliente
|
||||||
|
</i18n>
|
|
@ -21,13 +21,13 @@ export default {
|
||||||
redirect: { name: 'CmrList' },
|
redirect: { name: 'CmrList' },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'cmr/list',
|
path: 'cmr',
|
||||||
name: 'CmrList',
|
name: 'CmrList',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'cmrsList',
|
title: 'cmrsList',
|
||||||
icon: 'fact_check',
|
icon: 'fact_check',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Route/Cmr/CmrList.vue')
|
component: () => import('src/pages/Route/Cmr/CmrList.vue'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default {
|
||||||
title: 'wagonsList',
|
title: 'wagonsList',
|
||||||
icon: 'vn:trolley',
|
icon: 'vn:trolley',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/WagonList.vue')
|
component: () => import('src/pages/Wagon/WagonList.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'create',
|
path: 'create',
|
||||||
|
@ -36,7 +36,7 @@ export default {
|
||||||
title: 'wagonCreate',
|
title: 'wagonCreate',
|
||||||
icon: 'create',
|
icon: 'create',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/WagonCreate.vue')
|
component: () => import('src/pages/Wagon/WagonCreate.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id/edit',
|
path: ':id/edit',
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
||||||
title: 'wagonEdit',
|
title: 'wagonEdit',
|
||||||
icon: 'edit',
|
icon: 'edit',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/WagonCreate.vue')
|
component: () => import('src/pages/Wagon/WagonCreate.vue'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -62,7 +62,7 @@ export default {
|
||||||
title: 'typesList',
|
title: 'typesList',
|
||||||
icon: 'view_list',
|
icon: 'view_list',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/Type/WagonTypeList.vue')
|
component: () => import('src/pages/Wagon/Type/WagonTypeList.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'create',
|
path: 'create',
|
||||||
|
@ -71,7 +71,7 @@ export default {
|
||||||
title: 'typeCreate',
|
title: 'typeCreate',
|
||||||
icon: 'create',
|
icon: 'create',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue')
|
component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id/edit',
|
path: ':id/edit',
|
||||||
|
@ -80,9 +80,9 @@ export default {
|
||||||
title: 'typeEdit',
|
title: 'typeEdit',
|
||||||
icon: 'edit',
|
icon: 'edit',
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue')
|
component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
describe('VnBreadcrumbs', () => {
|
||||||
|
const firstCard = '.q-infinite-scroll > :nth-child(1)';
|
||||||
|
const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login('developer');
|
||||||
|
cy.visit('/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be breadcrumbs', () => {
|
||||||
|
cy.get('.q-breadcrumbs').should('not.exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get the correct breadcrumbs', () => {
|
||||||
|
cy.visit('#/customer/list');
|
||||||
|
cy.get('.q-breadcrumbs__el').should('have.length', 2);
|
||||||
|
|
||||||
|
cy.get(firstCard).click();
|
||||||
|
cy.get(`${lastBreadcrumb} > .q-icon`).should('have.text', 'launch');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue