mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Move some compositons, utils and types to shared (#8059)
* move composables, types and utils to shared * move composables, utils and types to shared * expose utils and composables in extensionsSDK * fix missing dependencies * Sort index.ts exports * Do the thing Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -45,11 +45,10 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, toRefs, ref, PropType, computed } from 'vue';
|
||||
import FieldListItem from '../v-field-template/field-list-item.vue';
|
||||
import { Collection, Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Collection, Relation } from '@directus/shared/types';
|
||||
import Draggable from 'vuedraggable';
|
||||
import useFieldTree from '@/composables/use-field-tree';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { FieldTree } from '../v-field-template/types';
|
||||
import hideDragImage from '@/utils/hide-drag-image';
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ import { defineComponent, toRefs, ref, watch, onMounted, onUnmounted, PropType }
|
||||
import FieldListItem from './field-list-item.vue';
|
||||
import useFieldTree from '@/composables/use-field-tree';
|
||||
import { FieldTree } from './types';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
|
||||
export default defineComponent({
|
||||
components: { FieldListItem },
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import { useCollection } from './use-collection';
|
||||
|
||||
export { useCollection };
|
||||
export default useCollection;
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores/';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { getRelationType } from '@/utils/get-relation-type';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { getRelationType } from '@directus/shared/utils';
|
||||
import { cloneDeep, orderBy } from 'lodash';
|
||||
import { Ref, ref, watch } from 'vue';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import api from '@/api';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { VALIDATION_TYPES } from '@/constants';
|
||||
import { i18n } from '@/lang';
|
||||
import { APIError } from '@/types';
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import { useItems } from './use-items';
|
||||
|
||||
export { useItems };
|
||||
export default useItems;
|
||||
@@ -3,7 +3,7 @@ import { Field } from '@directus/shared/types';
|
||||
import { computed, ComputedRef, Ref } from 'vue';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { isAllowed } from '../utils/is-allowed';
|
||||
import { useCollection } from './use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
|
||||
type UsablePermissions = {
|
||||
deleteAllowed: ComputedRef<boolean>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { usePresetsStore, useUserStore } from '@/stores';
|
||||
import { Filter, Preset } from '@directus/shared/types';
|
||||
import { debounce, isEqual } from 'lodash';
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import useSync from './use-sync';
|
||||
|
||||
export { useSync };
|
||||
export default useSync;
|
||||
@@ -1,31 +0,0 @@
|
||||
# Use Sync
|
||||
|
||||
```ts
|
||||
function useSync<T, K extends keyof T>(
|
||||
props: T,
|
||||
key: K,
|
||||
|
||||
emit: (event: string, ...args: any[]) => void
|
||||
): Ref<Readonly<T[K]>>;
|
||||
```
|
||||
|
||||
Small utility composition that allows you to easily setup the two-way binding with the prop:
|
||||
|
||||
```ts
|
||||
// Before
|
||||
|
||||
const internalOptions = computed({
|
||||
get() {
|
||||
return props.options;
|
||||
},
|
||||
set(val) {
|
||||
emit('update:options', val);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
```ts
|
||||
// after
|
||||
|
||||
const internalOptions = useSync(props, 'options', emit);
|
||||
```
|
||||
@@ -1,6 +1,6 @@
|
||||
import api from '@/api';
|
||||
import { Collection } from '@/types';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { Collection } from '@directus/shared/types';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { computed, Ref, ref, watch } from 'vue';
|
||||
|
||||
type UsableTemplateData = {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, toRefs } from 'vue';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { defineDisplay } from '@directus/shared/utils';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import getRelatedCollection from '@/utils/get-related-collection';
|
||||
import { ref } from 'vue';
|
||||
import options from './options.vue';
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, PropType, Ref } from 'vue';
|
||||
import getRelatedCollection from '@/utils/get-related-collection';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import ValueNull from '@/views/private/components/value-null';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -140,12 +140,12 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, PropType, ref, watch } from 'vue';
|
||||
import { useRelationsStore, useCollectionsStore, useFieldsStore } from '@/stores';
|
||||
import { Relation, Collection } from '@/types';
|
||||
import { Collection, Relation } from '@directus/shared/types';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection/';
|
||||
import DrawerItem from '@/views/private/components/drawer-item/';
|
||||
import api from '@/api';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { isPlainObject, cloneDeep } from 'lodash';
|
||||
import { getEndpoint } from '@/utils/get-endpoint';
|
||||
import { hideDragImage } from '@/utils/hide-drag-image';
|
||||
|
||||
@@ -101,7 +101,7 @@ import usePreview from './use-preview';
|
||||
import useEdit from './use-edit';
|
||||
import useSelection from './use-selection';
|
||||
import useSort from './use-sort';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import { usePermissionsStore, useUserStore } from '@/stores';
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation, Collection } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Collection, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { useCollectionsStore } from '@/stores';
|
||||
export default defineComponent({
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useCollectionsStore, useRelationsStore } from '@/stores/';
|
||||
import { Collection, Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Collection, Relation } from '@directus/shared/types';
|
||||
import { computed, ComputedRef, Ref } from 'vue';
|
||||
|
||||
export type RelationInfo = {
|
||||
|
||||
@@ -50,14 +50,13 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, ref, computed, PropType, onMounted, watch } from 'vue';
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useRelationsStore } from '@/stores';
|
||||
import api from '@/api';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import hideDragImage from '@/utils/hide-drag-image';
|
||||
import NestedDraggable from './nested-draggable.vue';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import { Relation } from '@/types';
|
||||
import { Filter, Relation } from '@directus/shared/types';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection';
|
||||
import DrawerItem from '@/views/private/components/drawer-item';
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -82,16 +82,15 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, ref, computed, watch, PropType } from 'vue';
|
||||
import api from '@/api';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useCollectionsStore, useRelationsStore, useFieldsStore, usePermissionsStore, useUserStore } from '@/stores/';
|
||||
import DrawerItem from '@/views/private/components/drawer-item';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection';
|
||||
import { Relation } from '@/types';
|
||||
import { Filter, Field } from '@directus/shared/types';
|
||||
import { Filter, Field, Relation } from '@directus/shared/types';
|
||||
import { isEqual, sortBy } from 'lodash';
|
||||
import { get } from 'lodash';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { addRelatedPrimaryKeyToFields } from '@/utils/add-related-primary-key-to-fields';
|
||||
import Draggable from 'vuedraggable';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation, Collection } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Collection, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { useCollectionsStore } from '@/stores/';
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -89,8 +89,8 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, ref, toRefs, watch, PropType } from 'vue';
|
||||
import { useCollectionsStore, useRelationsStore } from '@/stores/';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import api from '@/api';
|
||||
import DrawerItem from '@/views/private/components/drawer-item';
|
||||
import DrawerCollection from '@/views/private/components/drawer-collection';
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { useFieldsStore } from '@/stores/';
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@
|
||||
<script lang="ts">
|
||||
import LanguageSelect from './language-select.vue';
|
||||
import { computed, defineComponent, PropType, Ref, ref, toRefs, watch, unref } from 'vue';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useFieldsStore, useRelationsStore } from '@/stores/';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import api from '@/api';
|
||||
import { Relation } from '@/types';
|
||||
import { Relation } from '@directus/shared/types';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { cloneDeep, isEqual, assign } from 'lodash';
|
||||
import { notEmpty } from '@/utils/is-empty';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import api from '@/api';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { formatISO, parse, format } from 'date-fns';
|
||||
import useItems from '@/composables/use-items';
|
||||
import { useItems } from '@directus/shared/composables';
|
||||
import { router } from '@/router';
|
||||
import { useAppStore } from '@/stores/app';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import getFullcalendarLocale from '@/utils/get-fullcalendar-locale';
|
||||
import { renderPlainStringTemplate } from '@/utils/render-string-template';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
@@ -21,7 +21,7 @@ import CalendarActions from './actions.vue';
|
||||
import CalendarLayout from './calendar.vue';
|
||||
import CalendarOptions from './options.vue';
|
||||
import CalendarSidebar from './sidebar.vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { LayoutOptions } from './types';
|
||||
|
||||
export default defineLayout<LayoutOptions>({
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import { AppFilter } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -86,8 +86,8 @@ import Card from './components/card.vue';
|
||||
import CardsHeader from './components/header.vue';
|
||||
import useElementSize from '@/composables/use-element-size';
|
||||
import { Field, Item } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { Collection } from '@/types';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { Collection } from '@directus/shared/types';
|
||||
|
||||
export default defineComponent({
|
||||
components: { Card, CardsHeader },
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -6,14 +6,14 @@ import CardsActions from './actions.vue';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { toRefs, inject, computed, ref } from 'vue';
|
||||
import useCollection from '@/composables/use-collection/';
|
||||
import useItems from '@/composables/use-items';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useItems } from '@directus/shared/composables';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { useRelationsStore } from '@/stores/';
|
||||
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import { clone } from 'lodash';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { LayoutOptions, LayoutQuery } from './types';
|
||||
|
||||
export default defineLayout<LayoutOptions, LayoutQuery>({
|
||||
|
||||
@@ -49,7 +49,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import { Field } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import { LayoutQuery } from './types';
|
||||
import { AppFilter } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -10,12 +10,12 @@ import { toRefs, computed, ref, watch, Ref } from 'vue';
|
||||
import { toGeoJSON } from '@/utils/geometry';
|
||||
import { layers } from './style';
|
||||
import { useRouter } from 'vue-router';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { LayoutOptions, LayoutQuery } from './types';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import useCollection from '@/composables/use-collection/';
|
||||
import useItems from '@/composables/use-items';
|
||||
import { getFieldsFromTemplate } from '@/utils/get-fields-from-template';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useItems } from '@directus/shared/composables';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
import { Field, GeometryFormat, GeometryOptions } from '@directus/shared/types';
|
||||
|
||||
import { cloneDeep, merge } from 'lodash';
|
||||
|
||||
@@ -116,7 +116,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import MapComponent from './components/map.vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { GeometryOptions, Item } from '@directus/shared/types';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ import { defineComponent, PropType, toRefs } from 'vue';
|
||||
import { useAppStore } from '@/stores';
|
||||
import { getBasemapSources } from '@/utils/geometry/basemap';
|
||||
import { GeometryOptions, Item } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import { LayoutQuery } from './types';
|
||||
import { AppFilter } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -11,12 +11,12 @@ import { HeaderRaw, Item } from '@/components/v-table/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { debounce, clone } from 'lodash';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import useItems from '@/composables/use-items';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useItems } from '@directus/shared/composables';
|
||||
import adjustFieldsForDisplays from '@/utils/adjust-fields-for-displays';
|
||||
import hideDragImage from '@/utils/hide-drag-image';
|
||||
import { getDefaultDisplayForType } from '@/utils/get-default-display-for-type';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { LayoutOptions, LayoutQuery } from './types';
|
||||
|
||||
export default defineLayout<LayoutOptions, LayoutQuery>({
|
||||
|
||||
@@ -54,7 +54,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import Draggable from 'vuedraggable';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { Field } from '@directus/shared/types';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { AppFilter } from '@directus/shared/types';
|
||||
import { LayoutQuery } from './types';
|
||||
|
||||
|
||||
@@ -82,11 +82,10 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ComponentPublicInstance, defineComponent, PropType, ref } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import useShortcut from '@/composables/use-shortcut';
|
||||
import { Field, Item } from '@directus/shared/types';
|
||||
import { Field, Item, Collection } from '@directus/shared/types';
|
||||
import { HeaderRaw } from '@/components/v-table/types';
|
||||
import { Collection } from '@/types';
|
||||
|
||||
export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCollectionsStore, useUserStore } from '@/stores/';
|
||||
import { Collection } from '@/types';
|
||||
import { Collection } from '@directus/shared/types';
|
||||
import { computed, ComputedRef, Ref, ref } from 'vue';
|
||||
|
||||
export type NavItem = {
|
||||
|
||||
@@ -259,7 +259,7 @@ import CollectionsNavigation from '../components/navigation.vue';
|
||||
import CollectionsNavigationSearch from '../components/navigation-search.vue';
|
||||
import api from '@/api';
|
||||
import CollectionsNotFound from './not-found.vue';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useLayout } from '@/composables/use-layout';
|
||||
import usePreset from '@/composables/use-preset';
|
||||
import LayoutSidebarDetail from '@/views/private/components/layout-sidebar-detail';
|
||||
|
||||
@@ -198,7 +198,7 @@ import { defineComponent, computed, toRefs, ref, ComponentPublicInstance } from
|
||||
import CollectionsNavigationSearch from '../components/navigation-search.vue';
|
||||
import CollectionsNavigation from '../components/navigation.vue';
|
||||
import CollectionsNotFound from './not-found.vue';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import RevisionsDrawerDetail from '@/views/private/components/revisions-drawer-detail';
|
||||
import CommentsSidebarDetail from '@/views/private/components/comments-sidebar-detail';
|
||||
import useItem from '@/composables/use-item';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import api from '@/api';
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { defineModule } from '@directus/shared/utils';
|
||||
import { useCollectionsStore, useFieldsStore } from '@/stores';
|
||||
import RouterPass from '@/utils/router-passthrough';
|
||||
|
||||
@@ -100,7 +100,7 @@ import { defineComponent, ref, computed } from 'vue';
|
||||
import SettingsNavigation from '../../../components/navigation.vue';
|
||||
import { HeaderRaw } from '@/components/v-table/types';
|
||||
import { useCollectionsStore } from '@/stores/';
|
||||
import { Collection } from '@/types';
|
||||
import { Collection } from '@directus/shared/types';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { sortBy } from 'lodash';
|
||||
import CollectionOptions from './components/collection-options.vue';
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, ref } from 'vue';
|
||||
import { Collection } from '@/types';
|
||||
import { Collection } from '@directus/shared/types';
|
||||
import { useCollectionsStore } from '@/stores/';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, PropType } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
type Tab = {
|
||||
text: string;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -133,7 +133,7 @@ import api from '@/api';
|
||||
import { useFieldsStore, useRelationsStore, useCollectionsStore } from '@/stores/';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useDialogRoute } from '@/composables/use-dialog-route';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { getLocalTypeForField } from '../get-local-type';
|
||||
import { notify } from '@/utils/notify';
|
||||
import formatTitle from '@directus/format-title';
|
||||
|
||||
@@ -7,9 +7,17 @@
|
||||
|
||||
import { getDisplays } from '@/displays';
|
||||
import { getInterfaces } from '@/interfaces';
|
||||
import { DeepPartial, DisplayConfig, Field, InterfaceConfig, Item, LocalType } from '@directus/shared/types';
|
||||
import {
|
||||
DeepPartial,
|
||||
DisplayConfig,
|
||||
Field,
|
||||
InterfaceConfig,
|
||||
Item,
|
||||
LocalType,
|
||||
Collection,
|
||||
Relation,
|
||||
} from '@directus/shared/types';
|
||||
import { useCollectionsStore, useFieldsStore, useRelationsStore } from '@/stores/';
|
||||
import { Collection, Relation } from '@/types';
|
||||
|
||||
import { clone, throttle } from 'lodash';
|
||||
import { computed, ComputedRef, nextTick, reactive, watch, WatchStopHandle } from 'vue';
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, toRefs } from 'vue';
|
||||
import useCollection from '@/composables/use-collection/';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import Draggable from 'vuedraggable';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { useFieldsStore } from '@/stores/';
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed, toRefs, ref } from 'vue';
|
||||
import SettingsNavigation from '../../../components/navigation.vue';
|
||||
import useCollection from '@/composables/use-collection/';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import FieldsManagement from './components/fields-management.vue';
|
||||
|
||||
import useItem from '@/composables/use-item';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useFieldsStore, useRelationsStore } from '@/stores';
|
||||
import { Relation } from '@/types';
|
||||
import { LocalType } from '@directus/shared/types';
|
||||
import { LocalType, Relation } from '@directus/shared/types';
|
||||
|
||||
export function getLocalTypeForField(collection: string, field: string): LocalType | null {
|
||||
const fieldsStore = useFieldsStore();
|
||||
|
||||
@@ -124,8 +124,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, ref, reactive } from 'vue';
|
||||
import api from '@/api';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { useFieldsStore, useCollectionsStore, useRelationsStore } from '@/stores/';
|
||||
import { notify } from '@/utils/notify';
|
||||
import { useDialogRoute } from '@/composables/use-dialog-route';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, ref, computed } from 'vue';
|
||||
import SettingsNavigation from '../../components/navigation.vue';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useSettingsStore, useServerStore } from '@/stores';
|
||||
import ProjectInfoSidebarDetail from './components/project-info-sidebar-detail.vue';
|
||||
import { clone } from 'lodash';
|
||||
|
||||
@@ -47,8 +47,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, toRefs } from 'vue';
|
||||
import { Permission } from '@directus/shared/types';
|
||||
import { Collection } from '@/types';
|
||||
import { Permission, Collection } from '@directus/shared/types';
|
||||
import PermissionsOverviewToggle from './permissions-overview-toggle.vue';
|
||||
import useUpdatePermissions from '../composables/use-update-permissions';
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed, inject, ref, toRefs } from 'vue';
|
||||
import { Permission } from '@directus/shared/types';
|
||||
import { Collection } from '@/types';
|
||||
import { Permission, Collection } from '@directus/shared/types';
|
||||
import api from '@/api';
|
||||
import { useRouter } from 'vue-router';
|
||||
import useUpdatePermissions from '../composables/use-update-permissions';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import api from '@/api';
|
||||
import { Collection } from '@/types';
|
||||
import { Permission } from '@directus/shared/types';
|
||||
import { Permission, Collection } from '@directus/shared/types';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { inject, ref, Ref } from 'vue';
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Permission, Role } from '@directus/shared/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { useFieldsStore } from '@/stores';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Permission, Role } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Permission, Role } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed } from 'vue';
|
||||
import { Permission, Role } from '@directus/shared/types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -190,7 +190,7 @@ import { Field } from '@directus/shared/types';
|
||||
import UserInfoSidebarDetail from '../components/user-info-sidebar-detail.vue';
|
||||
import { getRootPath } from '@/utils/get-root-path';
|
||||
import useShortcut from '@/composables/use-shortcut';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { userName } from '@/utils/user-name';
|
||||
import { usePermissions } from '@/composables/use-permissions';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import api from '@/api';
|
||||
import { i18n } from '@/lang';
|
||||
import { Collection, CollectionRaw } from '@/types';
|
||||
import { Collection, CollectionRaw } from '@directus/shared/types';
|
||||
import { notEmpty } from '@/utils/is-empty/';
|
||||
import { notify } from '@/utils/notify';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import api from '@/api';
|
||||
import { i18n } from '@/lang';
|
||||
import { useRelationsStore } from '@/stores/';
|
||||
import { Relation } from '@/types';
|
||||
import { notEmpty } from '@/utils/is-empty/';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import formatTitle from '@directus/format-title';
|
||||
import { DeepPartial, Field, FieldRaw } from '@directus/shared/types';
|
||||
import { DeepPartial, Field, FieldRaw, Relation } from '@directus/shared/types';
|
||||
import { parseFilter } from '@/utils/parse-filter';
|
||||
import { merge, orderBy } from 'lodash';
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import api from '@/api';
|
||||
import { useFieldsStore } from '@/stores/';
|
||||
import { Relation } from '@/types';
|
||||
import { Relation } from '@directus/shared/types';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useRelationsStore = defineStore({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useFieldsStore } from '@/stores/';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
|
||||
/**
|
||||
* Adds the primary key field for any passed relational dot-notation field to the array of fields.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import filtersToQuery from './filters-to-query';
|
||||
|
||||
export { filtersToQuery };
|
||||
export default filtersToQuery;
|
||||
@@ -1,53 +0,0 @@
|
||||
# Filters to Query
|
||||
|
||||
Converts an array of filter objects to an object of query params.
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
const multipleFilters: Filter[] = [
|
||||
{
|
||||
field: 'title',
|
||||
operator: 'contains',
|
||||
value: 'directus',
|
||||
},
|
||||
{
|
||||
field: 'author',
|
||||
operator: 'eq',
|
||||
value: 1,
|
||||
},
|
||||
];
|
||||
|
||||
filtersToQuery(multipleFilters);
|
||||
|
||||
// {
|
||||
// _and: [
|
||||
// {
|
||||
// title: {
|
||||
// _contains: 'directus'
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// author: {
|
||||
// _eq: 1
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
const singleFilter: Filter[] = [
|
||||
{
|
||||
field: 'title',
|
||||
operator: 'contains',
|
||||
value: 'directus',
|
||||
},
|
||||
];
|
||||
|
||||
filtersToQuery(singleFilter);
|
||||
|
||||
// {
|
||||
// title: {
|
||||
// _contains: 'directus'
|
||||
// }
|
||||
// }
|
||||
```
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useFieldsStore, useRelationsStore } from '@/stores/';
|
||||
import { Relation } from '@/types';
|
||||
import { Relation } from '@directus/shared/types';
|
||||
|
||||
export default function getRelatedCollection(collection: string, field: string): string {
|
||||
const relationsStore = useRelationsStore();
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import moveInArray from './move-in-array';
|
||||
|
||||
export { moveInArray };
|
||||
export default moveInArray;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { render, renderFn, get } from 'micromustache';
|
||||
import { computed, ComputedRef, Ref, unref } from 'vue';
|
||||
import { getFieldsFromTemplate } from './get-fields-from-template';
|
||||
import { getFieldsFromTemplate } from '@directus/shared/utils';
|
||||
|
||||
type StringTemplate = {
|
||||
fieldsInTemplate: ComputedRef<string[]>;
|
||||
|
||||
@@ -49,7 +49,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, ref, computed, toRefs, watch } from 'vue';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import usePreset from '@/composables/use-preset';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useLayout } from '@/composables/use-layout';
|
||||
import SearchInput from '@/views/private/components/search-input';
|
||||
|
||||
|
||||
@@ -61,10 +61,9 @@ import api, { addTokenToURL } from '@/api';
|
||||
import { getRootPath } from '@/utils/get-root-path';
|
||||
import FilePreview from '@/views/private/components/file-preview';
|
||||
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { useFieldsStore, useRelationsStore } from '@/stores';
|
||||
import { Relation } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { Field, Relation } from '@directus/shared/types';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { usePermissions } from '@/composables/use-permissions';
|
||||
import useTemplateData from '@/composables/use-template-data';
|
||||
|
||||
@@ -38,7 +38,7 @@ import { defineComponent, ref, PropType, computed } from 'vue';
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import api from '@/api';
|
||||
import { getRootPath } from '@/utils/get-root-path';
|
||||
import filtersToQuery from '@/utils/filters-to-query';
|
||||
import { filtersToQuery } from '@directus/shared/utils';
|
||||
import { useCollectionsStore } from '@/stores/';
|
||||
|
||||
type LayoutQuery = {
|
||||
|
||||
@@ -49,7 +49,7 @@ import FieldFilter from './field-filter.vue';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { debounce } from 'lodash';
|
||||
import FieldListItem from './field-list-item.vue';
|
||||
import { useCollection } from '@/composables/use-collection';
|
||||
import { useCollection } from '@directus/shared/composables';
|
||||
import { getFilterOperatorsForType } from '@directus/shared/utils';
|
||||
import { useFieldTree } from '@/composables/use-field-tree';
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, computed } from 'vue';
|
||||
import { getLayouts } from '@/layouts';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed, watch, ref } from 'vue';
|
||||
import { Revision } from './types';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import localizedFormat from '@/utils/localized-format';
|
||||
import { userName } from '@/utils/user-name';
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<script lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { defineComponent, PropType, computed, ref } from 'vue';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { useSync } from '@directus/shared/composables';
|
||||
import { Revision } from './types';
|
||||
import RevisionsDrawerPicker from './revisions-drawer-picker.vue';
|
||||
import RevisionsDrawerPreview from './revisions-drawer-preview.vue';
|
||||
|
||||
22
package-lock.json
generated
22
package-lock.json
generated
@@ -4061,7 +4061,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.7.tgz",
|
||||
"integrity": "sha512-q1W2j81xbHyfKrNcca/CeJyf0Bcx4u9UDu05l7AaiJbqOseTme2o2I3wp1hDDCtmC7k7HgX0sAygyHNJH9swuQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/devtools-if": "9.1.7",
|
||||
"@intlify/message-compiler": "9.1.7",
|
||||
@@ -4078,7 +4077,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.7.tgz",
|
||||
"integrity": "sha512-/DcN5FUySSkQhDqx5y1RvxfuCXO3Ot/dUEIOs472qbM7Hyb2qif+eXCnwHBzlI4+wEfQVT6L0PiM1a7Er/ro9g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/shared": "9.1.7"
|
||||
},
|
||||
@@ -4090,7 +4088,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.7.tgz",
|
||||
"integrity": "sha512-JZNkAhr3O7tnbdbRBcpYfqr/Ai26WTzX0K/lV8Y1KVdOIj/dGiamaffdWUdFiDXUnbJRNbPiOaKxy7Pwip3KxQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
"@intlify/shared": "9.1.7",
|
||||
@@ -4104,7 +4101,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.7.tgz",
|
||||
"integrity": "sha512-WTK+OaXJYjyquLGhuCyDvU2WHkG+kXzXeHagmVFHn+s118Jf2143zzkLLUrapP5CtZ/csuyjmYg7b3xQRQAmvw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
@@ -4113,7 +4109,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.7.tgz",
|
||||
"integrity": "sha512-QURPSlzhOVnRwS2XMGpCDsDkP42kfVBh94aAORxh/gVGzdgJip2vagrIFij/J69aEqdB476WJkMhVjP8VSHmiA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/message-compiler": "9.1.7",
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
@@ -4127,7 +4122,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.7.tgz",
|
||||
"integrity": "sha512-zt0zlUdalumvT9AjQNxPXA36UgOndUyvBMplh8uRZU0fhWHAwhnJTcf0NaG9Qvr8I1n3HPSs96+kLb/YdwTavQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
@@ -4136,7 +4130,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.7.tgz",
|
||||
"integrity": "sha512-DI5Wc0aOiohtBUGUkKAcryCWbbuaO4/PK4Pa/LaNCsFNxbtgR5qkIDmhBv9xVPYGTUhySXxaDDAMvOpBjhPJjw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
"@intlify/runtime": "9.1.7",
|
||||
@@ -46606,7 +46599,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.7.tgz",
|
||||
"integrity": "sha512-ujuuDanoHqtEd4GejWrbG/fXE9nrP51ElsEGxp0WBHfv+/ki0/wyUqkO+4fLikki2obGtXdviTPH0VNpas5K6g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@intlify/core-base": "9.1.7",
|
||||
"@intlify/shared": "9.1.7",
|
||||
@@ -50571,6 +50563,7 @@
|
||||
"lodash": "4.17.21",
|
||||
"pino": "*",
|
||||
"vue": "3",
|
||||
"vue-i18n": "9",
|
||||
"vue-router": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -53137,6 +53130,7 @@
|
||||
"rimraf": "3.0.2",
|
||||
"typescript": "4.4.3",
|
||||
"vue": "3",
|
||||
"vue-i18n": "9",
|
||||
"vue-router": "4"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -53870,7 +53864,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.1.7.tgz",
|
||||
"integrity": "sha512-q1W2j81xbHyfKrNcca/CeJyf0Bcx4u9UDu05l7AaiJbqOseTme2o2I3wp1hDDCtmC7k7HgX0sAygyHNJH9swuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/devtools-if": "9.1.7",
|
||||
"@intlify/message-compiler": "9.1.7",
|
||||
@@ -53884,7 +53877,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/devtools-if/-/devtools-if-9.1.7.tgz",
|
||||
"integrity": "sha512-/DcN5FUySSkQhDqx5y1RvxfuCXO3Ot/dUEIOs472qbM7Hyb2qif+eXCnwHBzlI4+wEfQVT6L0PiM1a7Er/ro9g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/shared": "9.1.7"
|
||||
}
|
||||
@@ -53893,7 +53885,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.1.7.tgz",
|
||||
"integrity": "sha512-JZNkAhr3O7tnbdbRBcpYfqr/Ai26WTzX0K/lV8Y1KVdOIj/dGiamaffdWUdFiDXUnbJRNbPiOaKxy7Pwip3KxQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
"@intlify/shared": "9.1.7",
|
||||
@@ -53903,14 +53894,12 @@
|
||||
"@intlify/message-resolver": {
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.1.7.tgz",
|
||||
"integrity": "sha512-WTK+OaXJYjyquLGhuCyDvU2WHkG+kXzXeHagmVFHn+s118Jf2143zzkLLUrapP5CtZ/csuyjmYg7b3xQRQAmvw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-WTK+OaXJYjyquLGhuCyDvU2WHkG+kXzXeHagmVFHn+s118Jf2143zzkLLUrapP5CtZ/csuyjmYg7b3xQRQAmvw=="
|
||||
},
|
||||
"@intlify/runtime": {
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.1.7.tgz",
|
||||
"integrity": "sha512-QURPSlzhOVnRwS2XMGpCDsDkP42kfVBh94aAORxh/gVGzdgJip2vagrIFij/J69aEqdB476WJkMhVjP8VSHmiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/message-compiler": "9.1.7",
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
@@ -53920,14 +53909,12 @@
|
||||
"@intlify/shared": {
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-9.1.7.tgz",
|
||||
"integrity": "sha512-zt0zlUdalumvT9AjQNxPXA36UgOndUyvBMplh8uRZU0fhWHAwhnJTcf0NaG9Qvr8I1n3HPSs96+kLb/YdwTavQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-zt0zlUdalumvT9AjQNxPXA36UgOndUyvBMplh8uRZU0fhWHAwhnJTcf0NaG9Qvr8I1n3HPSs96+kLb/YdwTavQ=="
|
||||
},
|
||||
"@intlify/vue-devtools": {
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@intlify/vue-devtools/-/vue-devtools-9.1.7.tgz",
|
||||
"integrity": "sha512-DI5Wc0aOiohtBUGUkKAcryCWbbuaO4/PK4Pa/LaNCsFNxbtgR5qkIDmhBv9xVPYGTUhySXxaDDAMvOpBjhPJjw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/message-resolver": "9.1.7",
|
||||
"@intlify/runtime": "9.1.7",
|
||||
@@ -87972,7 +87959,6 @@
|
||||
"version": "9.1.7",
|
||||
"resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.1.7.tgz",
|
||||
"integrity": "sha512-ujuuDanoHqtEd4GejWrbG/fXE9nrP51ElsEGxp0WBHfv+/ki0/wyUqkO+4fLikki2obGtXdviTPH0VNpas5K6g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@intlify/core-base": "9.1.7",
|
||||
"@intlify/shared": "9.1.7",
|
||||
|
||||
@@ -5,5 +5,7 @@ export {
|
||||
defineModule,
|
||||
defineHook,
|
||||
defineEndpoint,
|
||||
getFieldsFromTemplate,
|
||||
getRelationType,
|
||||
} from '@directus/shared/utils';
|
||||
export { useStores, useApi } from '@directus/shared/composables';
|
||||
export { useStores, useApi, useCollection, useSync, useFilterFields, useItems } from '@directus/shared/composables';
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"lodash": "4.17.21",
|
||||
"pino": "*",
|
||||
"vue": "3",
|
||||
"vue-i18n": "9",
|
||||
"vue-router": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
export * from './use-collection';
|
||||
export * from './use-filter-fields';
|
||||
export * from './use-items';
|
||||
export * from './use-sync';
|
||||
export * from './use-system';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCollectionsStore, useFieldsStore } from '@/stores/';
|
||||
import { Collection } from '@/types';
|
||||
import { Field } from '@directus/shared/types';
|
||||
import { useStores } from './use-system';
|
||||
import { Collection, Field } from '../types';
|
||||
import { computed, ref, Ref, ComputedRef } from 'vue';
|
||||
|
||||
type UsableCollection = {
|
||||
@@ -15,18 +14,21 @@ type UsableCollection = {
|
||||
};
|
||||
|
||||
export function useCollection(collectionKey: string | Ref<string | null>): UsableCollection {
|
||||
const { useCollectionsStore, useFieldsStore } = useStores();
|
||||
const collectionsStore = useCollectionsStore();
|
||||
const fieldsStore = useFieldsStore();
|
||||
|
||||
const collection: Ref<string | null> = typeof collectionKey === 'string' ? ref(collectionKey) : collectionKey;
|
||||
|
||||
const info = computed(() => {
|
||||
return collectionsStore.collections.find(({ collection: key }) => key === collection.value) || null;
|
||||
return (
|
||||
(collectionsStore.collections as Collection[]).find(({ collection: key }) => key === collection.value) || null
|
||||
);
|
||||
});
|
||||
|
||||
const fields = computed(() => {
|
||||
if (!collection.value) return [];
|
||||
return fieldsStore.getFieldsForCollection(collection.value);
|
||||
return fieldsStore.getFieldsForCollection(collection.value) as Field[];
|
||||
});
|
||||
|
||||
const defaults = computed(() => {
|
||||
21
packages/shared/src/composables/use-filter-fields.ts
Normal file
21
packages/shared/src/composables/use-filter-fields.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Field } from '../types';
|
||||
import { Ref, computed } from 'vue';
|
||||
|
||||
export function useFilterFields<T extends string>(fields: Ref<Field[]>, filters: Record<T, (field: Field) => boolean>) {
|
||||
const fieldGroups = computed(() => {
|
||||
const acc = {} as Record<Extract<T, string>, Field[]>;
|
||||
for (const name in filters) {
|
||||
acc[name] = [];
|
||||
}
|
||||
|
||||
return fields.value.reduce((acc, field) => {
|
||||
for (const name in filters) {
|
||||
if (filters[name](field) === false) continue;
|
||||
acc[name].push(field);
|
||||
}
|
||||
return acc;
|
||||
}, acc);
|
||||
});
|
||||
|
||||
return { fieldGroups };
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import api from '@/api';
|
||||
import useCollection from '@/composables/use-collection';
|
||||
import { Filter, Item } from '@directus/shared/types';
|
||||
import filtersToQuery from '@/utils/filters-to-query';
|
||||
import moveInArray from '@/utils/move-in-array';
|
||||
import { useApi } from './use-system';
|
||||
import { useCollection } from './use-collection';
|
||||
import { Filter, Item } from '../types';
|
||||
import { moveInArray, filtersToQuery } from '../utils';
|
||||
import { isEqual, orderBy, throttle } from 'lodash';
|
||||
import { computed, ComputedRef, nextTick, ref, Ref, watch } from 'vue';
|
||||
|
||||
@@ -32,6 +31,7 @@ type UsableItems = {
|
||||
};
|
||||
|
||||
export function useItems(collection: Ref<string | null>, query: Query, fetchOnInit = true): UsableItems {
|
||||
const api = useApi();
|
||||
const { primaryKeyField, sortField } = useCollection(collection);
|
||||
|
||||
let loadingTimeout: number | null = null;
|
||||
@@ -144,7 +144,7 @@ export function useItems(collection: Ref<string | null>, query: Query, fetchOnIn
|
||||
|
||||
error.value = null;
|
||||
|
||||
loadingTimeout = setTimeout(() => {
|
||||
loadingTimeout = window.setTimeout(() => {
|
||||
loading.value = true;
|
||||
}, 250);
|
||||
|
||||
@@ -162,8 +162,8 @@ export function useItems(collection: Ref<string | null>, query: Query, fetchOnIn
|
||||
// Make sure all fields that are used to filter are fetched
|
||||
if (fields.value.includes('*') === false) {
|
||||
filters.value.forEach((filter) => {
|
||||
if (fieldsToFetch.includes(filter.field) === false) {
|
||||
fieldsToFetch.push(filter.field);
|
||||
if (fieldsToFetch.includes(filter.field as string) === false) {
|
||||
fieldsToFetch.push(filter.field as string);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { computed, Ref } from 'vue';
|
||||
|
||||
export default function useSync<
|
||||
T,
|
||||
K extends keyof T & string,
|
||||
E extends (event: `update:${K}`, ...args: any[]) => void
|
||||
>(props: T, key: K, emit: E): Ref<T[K]> {
|
||||
export function useSync<T, K extends keyof T & string, E extends (event: `update:${K}`, ...args: any[]) => void>(
|
||||
props: T,
|
||||
key: K,
|
||||
emit: E
|
||||
): Ref<T[K]> {
|
||||
return computed<T[K]>({
|
||||
get() {
|
||||
return props[key];
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './accountability';
|
||||
export * from './collection';
|
||||
export * from './displays';
|
||||
export * from './endpoints';
|
||||
export * from './extensions';
|
||||
@@ -13,5 +14,6 @@ export * from './misc';
|
||||
export * from './modules';
|
||||
export * from './permissions';
|
||||
export * from './presets';
|
||||
export * from './relations';
|
||||
export * from './settings';
|
||||
export * from './users';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Filter } from '@directus/shared/types';
|
||||
import { Filter } from '../types';
|
||||
import { clone } from 'lodash';
|
||||
|
||||
export default function filtersToQuery(filters: readonly Filter[]): { filter: Record<string, any> } {
|
||||
export function filtersToQuery(filters: readonly Filter[]): { filter: Record<string, any> } {
|
||||
const filterList: Record<string, any>[] = [];
|
||||
|
||||
for (const filter of filters) {
|
||||
@@ -30,7 +30,7 @@ export default function filtersToQuery(filters: readonly Filter[]): { filter: Re
|
||||
|
||||
let filterQuery: Record<string, any> = {};
|
||||
|
||||
if (filterList.length === 1) {
|
||||
if (filterList.length === 1 && filterList[0] !== undefined) {
|
||||
filterQuery = filterList[0];
|
||||
} else if (filterList.length > 1) {
|
||||
filterQuery = { _and: filterList };
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Relation } from '@/types';
|
||||
import { Relation } from '../types';
|
||||
|
||||
export function getRelationType(getRelationOptions: {
|
||||
relation: Relation;
|
||||
@@ -1,9 +1,13 @@
|
||||
export * from './adjust-date';
|
||||
export * from './deep-map';
|
||||
export * from './define-extension';
|
||||
export * from './filters-to-query';
|
||||
export * from './generate-joi';
|
||||
export * from './get-fields-from-template';
|
||||
export * from './get-filter-operators-for-type';
|
||||
export * from './get-relation-type';
|
||||
export * from './is-extension';
|
||||
export * from './move-in-array';
|
||||
export * from './parse-filter';
|
||||
export * from './pluralize';
|
||||
export * from './to-array';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user