mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add page titles (#4775)
* restructure template rendering * add useTitle composable * Split up render-string-template from getFieldsFromTemplate Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -207,6 +207,8 @@ import useShortcut from '@/composables/use-shortcut';
|
||||
import { NavigationGuard } from 'vue-router';
|
||||
import { usePermissions } from '@/composables/use-permissions';
|
||||
import unsavedChanges from '@/composables/unsaved-changes';
|
||||
import { useTitle } from '@/composables/use-title';
|
||||
import { renderStringTemplate } from '@/utils/render-string-template';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'collections-item',
|
||||
@@ -300,6 +302,24 @@ export default defineComponent({
|
||||
: i18n.t('editing_in', { collection: collectionInfo.value?.name });
|
||||
});
|
||||
|
||||
const tabTitle = computed(() => {
|
||||
let tabTitle = (collectionInfo.value?.name || '') + ' | ';
|
||||
|
||||
if (collectionInfo.value && collectionInfo.value.meta) {
|
||||
if (collectionInfo.value.meta.singleton === true) {
|
||||
return tabTitle + collectionInfo.value.name;
|
||||
} else if (isNew.value === false && collectionInfo.value.meta.display_template) {
|
||||
const { displayValue } = renderStringTemplate(collectionInfo.value.meta.display_template, templateValues);
|
||||
|
||||
if (displayValue.value !== undefined) return tabTitle + displayValue.value;
|
||||
}
|
||||
}
|
||||
|
||||
return tabTitle + title.value;
|
||||
});
|
||||
|
||||
useTitle(tabTitle);
|
||||
|
||||
const archiveTooltip = computed(() => {
|
||||
if (archiveAllowed.value === false) return i18n.t('not_allowed');
|
||||
if (isArchived.value === true) return i18n.t('unarchive');
|
||||
|
||||
Reference in New Issue
Block a user