mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
script[setup]: interfaces/system-collection (#18395)
* script[setup]: interfaces/system-collection * Apply latest from main * Align default value of includeSingleton
This commit is contained in:
@@ -8,63 +8,52 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { useCollectionsStore } from '@/stores/collections';
|
||||
import { computed, defineComponent } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
includeSystem: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
includeSingleton: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
emits: ['input'],
|
||||
setup(props) {
|
||||
const { t } = useI18n();
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: string | null;
|
||||
disabled?: boolean;
|
||||
includeSystem?: boolean;
|
||||
includeSingleton?: boolean;
|
||||
}>(),
|
||||
{ includeSingleton: true }
|
||||
);
|
||||
|
||||
const collectionsStore = useCollectionsStore();
|
||||
defineEmits<{
|
||||
(e: 'input', value: string | null): void;
|
||||
}>();
|
||||
|
||||
const collections = computed(() => {
|
||||
let collections = collectionsStore.collections;
|
||||
const { t } = useI18n();
|
||||
|
||||
if (!props.includeSingleton) {
|
||||
collections = collections.filter((collection) => collection?.meta?.singleton === false);
|
||||
}
|
||||
const collectionsStore = useCollectionsStore();
|
||||
|
||||
return [
|
||||
...collections.filter((collection) => collection.collection.startsWith('directus_') === false),
|
||||
...(props.includeSystem ? collectionsStore.crudSafeSystemCollections : []),
|
||||
];
|
||||
});
|
||||
const collections = computed(() => {
|
||||
let collections = collectionsStore.collections;
|
||||
|
||||
const items = computed(() => {
|
||||
return collections.value.reduce<{ text: string; value: string }[]>((acc, collection) => {
|
||||
if (collection.type !== 'alias') {
|
||||
acc.push({
|
||||
text: collection.name,
|
||||
value: collection.collection,
|
||||
});
|
||||
}
|
||||
if (!props.includeSingleton) {
|
||||
collections = collections.filter((collection) => collection?.meta?.singleton === false);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
});
|
||||
return [
|
||||
...collections.filter((collection) => collection.collection.startsWith('directus_') === false),
|
||||
...(props.includeSystem ? collectionsStore.crudSafeSystemCollections : []),
|
||||
];
|
||||
});
|
||||
|
||||
return { items, t };
|
||||
},
|
||||
const items = computed(() => {
|
||||
return collections.value.reduce<{ text: string; value: string }[]>((acc, collection) => {
|
||||
if (collection.type !== 'alias') {
|
||||
acc.push({
|
||||
text: collection.name,
|
||||
value: collection.collection,
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user