mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Add hide-archived default filter based on app toggle
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { usePresetsStore, useUserStore } from '@/stores';
|
||||
import { ref, Ref, computed, watch } from '@vue/composition-api';
|
||||
import { debounce } from 'lodash';
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
|
||||
import { Filter, Preset } from '@/types/';
|
||||
|
||||
@@ -8,6 +9,8 @@ export function usePreset(collection: Ref<string>, bookmark: Ref<number | null>
|
||||
const presetsStore = usePresetsStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const { info: collectionInfo } = useCollection(collection);
|
||||
|
||||
const bookmarkExists = computed(() => {
|
||||
if (!bookmark.value) return false;
|
||||
|
||||
@@ -156,11 +159,28 @@ export function usePreset(collection: Ref<string>, bookmark: Ref<number | null>
|
||||
};
|
||||
}
|
||||
|
||||
if (!localPreset.value.view_type)
|
||||
if (!localPreset.value.view_type) {
|
||||
localPreset.value = {
|
||||
...localPreset.value,
|
||||
view_type: 'tabular',
|
||||
};
|
||||
}
|
||||
|
||||
if (collectionInfo.value?.meta?.archive_field && collectionInfo.value?.meta?.archive_app_filter === true) {
|
||||
localPreset.value = {
|
||||
...localPreset.value,
|
||||
filters: [
|
||||
...(localPreset.value.filters || []),
|
||||
{
|
||||
key: 'hide-archived',
|
||||
field: collectionInfo.value.meta.archive_field,
|
||||
operator: 'neq',
|
||||
value: collectionInfo.value.meta.archive_value!,
|
||||
locked: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,10 +24,6 @@ function unbind(element: HTMLElement) {
|
||||
delete handlers[element.dataset.tooltip as string];
|
||||
}
|
||||
|
||||
function update(element: HTMLElement, binding: DirectiveBinding) {
|
||||
console.log(element);
|
||||
}
|
||||
|
||||
const Tooltip: DirectiveOptions = {
|
||||
bind,
|
||||
unbind,
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface CollectionRaw {
|
||||
archive_field: string | null;
|
||||
archive_value: string | null;
|
||||
unarchive_value: string | null;
|
||||
archive_app_filter: boolean;
|
||||
} | null;
|
||||
schema: Record<string, any>;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,11 @@
|
||||
</v-list>
|
||||
</v-menu>
|
||||
|
||||
<v-divider />
|
||||
<template v-if="showArchiveToggle">
|
||||
<v-divider />
|
||||
|
||||
<v-checkbox v-model="archived" :label="$t('show_archived_items')" />
|
||||
<v-checkbox v-model="archived" :label="$t('show_archived_items')" />
|
||||
</template>
|
||||
</drawer-detail>
|
||||
</template>
|
||||
|
||||
@@ -147,7 +149,9 @@ export default defineComponent({
|
||||
},
|
||||
});
|
||||
|
||||
const showArchiveToggle = computed(() => !!collectionInfo.value?.meta?.archive_field);
|
||||
const showArchiveToggle = computed(
|
||||
() => !!collectionInfo.value?.meta?.archive_field && !!collectionInfo.value?.meta?.archive_app_filter
|
||||
);
|
||||
|
||||
const archived = computed({
|
||||
get() {
|
||||
|
||||
Reference in New Issue
Block a user