diff --git a/app/src/components/v-button/v-button.vue b/app/src/components/v-button/v-button.vue index 344d313deb..976dfdf3d3 100644 --- a/app/src/components/v-button/v-button.vue +++ b/app/src/components/v-button/v-button.vue @@ -4,19 +4,17 @@ import { defineComponent, computed, PropType } from 'vue'; -import { RouteLocation } from 'vue-router'; +import { RouteLocation, useRoute, useLink } from 'vue-router'; import useSizeClass, { sizeProps } from '@/composables/size-class'; import { useGroupable } from '@/composables/groupable'; import { notEmpty } from '@/utils/is-empty'; +import { isEqual } from 'lodash'; export default defineComponent({ emits: ['click'], @@ -93,10 +92,18 @@ export default defineComponent({ type: String, default: null, }, + active: { + type: Boolean, + default: undefined, + }, exact: { type: Boolean, default: false, }, + query: { + type: Boolean, + default: false, + }, secondary: { type: Boolean, default: false, @@ -125,6 +132,9 @@ export default defineComponent({ ...sizeProps, }, setup(props, { emit }) { + const route = useRoute(); + + const { route: linkRoute, isActive, isExactActive } = useLink(props); const sizeClass = useSizeClass(props); const component = computed<'a' | 'router-link' | 'button'>(() => { @@ -139,7 +149,23 @@ export default defineComponent({ group: 'item-group', }); - return { sizeClass, onClick, component, active, toggle }; + const isActiveRoute = computed(() => { + if (props.active !== undefined) return props.active; + + if (props.to) { + const isQueryActive = !props.query || isEqual(route.query, linkRoute.value.query); + + if (!props.exact) { + return (isActive.value && isQueryActive) || active.value; + } else { + return (isExactActive.value && isQueryActive) || active.value; + } + } + + return false; + }); + + return { sizeClass, onClick, component, isActiveRoute, toggle }; function onClick(event: MouseEvent) { if (props.loading === true) return; @@ -157,11 +183,11 @@ export default defineComponent({ --v-button-height: 44px; --v-button-color: var(--foreground-inverted); --v-button-color-hover: var(--foreground-inverted); - --v-button-color-activated: var(--foreground-inverted); + --v-button-color-active: var(--foreground-inverted); --v-button-color-disabled: var(--foreground-subdued); --v-button-background-color: var(--primary); --v-button-background-color-hover: var(--primary-125); - --v-button-background-color-activated: var(--primary); + --v-button-background-color-active: var(--primary); --v-button-background-color-disabled: var(--background-normal); --v-button-font-size: 16px; --v-button-font-weight: 600; @@ -177,10 +203,10 @@ export default defineComponent({ .secondary { --v-button-color: var(--foreground-normal); --v-button-color-hover: var(--foreground-normal); - --v-button-color-activated: var(--foreground-normal); + --v-button-color-active: var(--foreground-normal); --v-button-background-color: var(--border-subdued); --v-button-background-color-hover: var(--background-normal-alt); - --v-button-background-color-activated: var(--background-normal-alt); + --v-button-background-color-active: var(--background-normal-alt); } .v-button.full-width { @@ -248,7 +274,7 @@ export default defineComponent({ background-color: transparent; } -.outlined:not(.activated):hover { +.outlined:not(.active):hover { color: var(--v-button-background-color-hover); background-color: transparent; border-color: var(--v-button-background-color-hover); @@ -338,12 +364,11 @@ export default defineComponent({ --v-progress-circular-background-color: transparent; } -.activated, .active { - --v-button-color: var(--v-button-color-activated) !important; - --v-button-color-hover: var(--v-button-color-activated) !important; - --v-button-background-color: var(--v-button-background-color-activated) !important; - --v-button-background-color-hover: var(--v-button-background-color-activated) !important; + --v-button-color: var(--v-button-color-active) !important; + --v-button-color-hover: var(--v-button-color-active) !important; + --v-button-background-color: var(--v-button-background-color-active) !important; + --v-button-background-color-hover: var(--v-button-background-color-active) !important; } .tile { diff --git a/app/src/components/v-drawer/v-drawer.vue b/app/src/components/v-drawer/v-drawer.vue index 19c298466e..f2068a767f 100644 --- a/app/src/components/v-drawer/v-drawer.vue +++ b/app/src/components/v-drawer/v-drawer.vue @@ -149,7 +149,7 @@ body { .header-icon { --v-button-background-color: var(--background-normal); - --v-button-background-color-activated: var(--background-normal); + --v-button-background-color-active: var(--background-normal); --v-button-background-color-hover: var(--background-normal-alt); --v-button-color-disabled: var(--foreground-normal); } diff --git a/app/src/components/v-list/v-list-item.vue b/app/src/components/v-list/v-list-item.vue index e98d1f8d14..aa80c2f00e 100644 --- a/app/src/components/v-list/v-list-item.vue +++ b/app/src/components/v-list/v-list-item.vue @@ -2,12 +2,10 @@ -import { RouteLocation } from 'vue-router'; +import { RouteLocation, useLink, useRoute } from 'vue-router'; import { defineComponent, PropType, computed } from 'vue'; import { useGroupable } from '@/composables/groupable'; +import { isEqual } from 'lodash'; export default defineComponent({ props: { @@ -56,7 +55,7 @@ export default defineComponent({ }, active: { type: Boolean, - default: false, + default: undefined, }, dashed: { type: Boolean, @@ -66,6 +65,10 @@ export default defineComponent({ type: Boolean, default: false, }, + query: { + type: Boolean, + default: false, + }, download: { type: String, default: null, @@ -80,6 +83,10 @@ export default defineComponent({ }, }, setup(props) { + const route = useRoute(); + + const { route: linkRoute, isActive, isExactActive } = useLink(props); + const component = computed(() => { if (props.to) return 'router-link'; if (props.href) return 'a'; @@ -92,7 +99,23 @@ export default defineComponent({ const isLink = computed(() => Boolean(props.to || props.href || props.clickable)); - return { component, isLink }; + const isActiveRoute = computed(() => { + if (props.active !== undefined) return props.active; + + if (props.to) { + const isQueryActive = !props.query || isEqual(route.query, linkRoute.value.query); + + if (!props.exact) { + return isActive.value && isQueryActive; + } else { + return isExactActive.value && isQueryActive; + } + } + + return false; + }); + + return { component, isLink, isActiveRoute }; }, }); diff --git a/app/src/displays/related-values/related-values.vue b/app/src/displays/related-values/related-values.vue index 86e6960dea..3665c49214 100644 --- a/app/src/displays/related-values/related-values.vue +++ b/app/src/displays/related-values/related-values.vue @@ -104,7 +104,7 @@ export default defineComponent({ if (!relatedCollection.value || !primaryKeyField.value) return null; const primaryKey = item[primaryKeyField.value.field]; - return `/collections/${relatedCollection.value}/-/${encodeURIComponent(primaryKey)}`; + return `/collections/${relatedCollection.value}/${encodeURIComponent(primaryKey)}`; } }, }); diff --git a/app/src/interfaces/input-rich-text-md/input-rich-text-md.vue b/app/src/interfaces/input-rich-text-md/input-rich-text-md.vue index aa7d90a69b..4a068c7416 100644 --- a/app/src/interfaces/input-rich-text-md/input-rich-text-md.vue +++ b/app/src/interfaces/input-rich-text-md/input-rich-text-md.vue @@ -519,8 +519,8 @@ textarea { --v-button-color: var(--foreground-subdued); --v-button-background-color-hover: var(--border-normal); --v-button-color-hover: var(--foreground-normal); - --v-button-background-color-activated: var(--border-normal); - --v-button-color-activated: var(--foreground-normal); + --v-button-background-color-active: var(--border-normal); + --v-button-color-active: var(--foreground-normal); } } diff --git a/app/src/layouts/calendar/index.ts b/app/src/layouts/calendar/index.ts index 35fbadd769..7b0e899cfe 100644 --- a/app/src/layouts/calendar/index.ts +++ b/app/src/layouts/calendar/index.ts @@ -188,7 +188,7 @@ export default defineLayout({ const endpoint = collection.value.startsWith('directus') ? collection.value.substring(9) : `/collections/${collection.value}`; - router.push(`${endpoint}/-/${primaryKey}`); + router.push(`${endpoint}/${primaryKey}`); }, async eventChange(info) { if (!collection.value || !startDateField.value || !startDateFieldInfo.value) return; diff --git a/app/src/layouts/cards/index.ts b/app/src/layouts/cards/index.ts index 0cf2ba9ec3..dd63334d44 100644 --- a/app/src/layouts/cards/index.ts +++ b/app/src/layouts/cards/index.ts @@ -81,7 +81,7 @@ export default defineLayout({ }); const newLink = computed(() => { - return `/collections/${collection.value}/-/+`; + return `/collections/${collection.value}/+`; }); const showingCount = computed(() => { @@ -273,7 +273,7 @@ export default defineLayout({ function getLinkForItem(item: Record) { if (!primaryKeyField.value) return; - return `/collections/${props.collection}/-/${encodeURIComponent(item[primaryKeyField.value.field])}`; + return `/collections/${props.collection}/${encodeURIComponent(item[primaryKeyField.value.field])}`; } function selectAll() { diff --git a/app/src/layouts/tabular/index.ts b/app/src/layouts/tabular/index.ts index 77786c2a6a..9e953750dc 100644 --- a/app/src/layouts/tabular/index.ts +++ b/app/src/layouts/tabular/index.ts @@ -362,7 +362,7 @@ export default defineLayout({ } else { const primaryKey = item[primaryKeyField.value.field]; - router.push(`/collections/${collection.value}/-/${encodeURIComponent(primaryKey)}`); + router.push(`/collections/${collection.value}/${encodeURIComponent(primaryKey)}`); } } diff --git a/app/src/modules/activity/routes/item.vue b/app/src/modules/activity/routes/item.vue index cd49c3d7f7..9bb6072f46 100644 --- a/app/src/modules/activity/routes/item.vue +++ b/app/src/modules/activity/routes/item.vue @@ -89,7 +89,7 @@ export default defineComponent({ const openItemLink = computed(() => { if (!item.value) return; - return `/collections/${item.value.collection}/-/${encodeURIComponent(item.value.item)}`; + return `/collections/${item.value.collection}/${encodeURIComponent(item.value.item)}`; }); watch(() => props.primaryKey, loadActivity, { immediate: true }); diff --git a/app/src/modules/collections/components/navigation-bookmark.vue b/app/src/modules/collections/components/navigation-bookmark.vue index f5d81ba3be..b2c1cabcb1 100644 --- a/app/src/modules/collections/components/navigation-bookmark.vue +++ b/app/src/modules/collections/components/navigation-bookmark.vue @@ -1,5 +1,5 @@ - + @@ -65,13 +65,7 @@