diff --git a/src/interfaces/files/files.vue b/src/interfaces/files/files.vue new file mode 100644 index 0000000000..ac6981f937 --- /dev/null +++ b/src/interfaces/files/files.vue @@ -0,0 +1,290 @@ + + + {{ $t('relationship_not_setup') }} + + + + + + + + + + + + + + {{ $t('upload_file') }} + + {{ $t('add_existing') }} + + + + + + + + + + {{ $t('upload_file') }} + + + {{ $t('done') }} + + + + + + + + + diff --git a/src/interfaces/files/index.ts b/src/interfaces/files/index.ts new file mode 100644 index 0000000000..baf927858b --- /dev/null +++ b/src/interfaces/files/index.ts @@ -0,0 +1,10 @@ +import { defineInterface } from '../define'; +import InterfaceFiles from './files.vue'; + +export default defineInterface(({ i18n }) => ({ + id: 'files', + name: i18n.t('files'), + icon: 'note_add', + component: InterfaceFiles, + options: [], +})); diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index a5f2861ced..bbd1acc382 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -27,6 +27,7 @@ import InterfaceFile from './file'; import InterfaceCollections from './collections'; import InterfaceTranslations from './translations'; import InterfaceManyToMany from './many-to-many'; +import InterfaceFiles from './files'; export const interfaces = [ InterfaceTextInput, @@ -58,6 +59,7 @@ export const interfaces = [ InterfaceCollections, InterfaceTranslations, InterfaceManyToMany, + InterfaceFiles, ]; export default interfaces; diff --git a/src/interfaces/many-to-many/is-new.ts b/src/interfaces/many-to-many/is-new.ts new file mode 100644 index 0000000000..18c90005a8 --- /dev/null +++ b/src/interfaces/many-to-many/is-new.ts @@ -0,0 +1,25 @@ +import { Ref } from '@vue/composition-api'; +import { Relation } from '@/stores/relations/types'; +import { Field } from '@/stores/fields/types'; + +type IsNewContext = { + relationCurrentToJunction: Ref; + junctionCollectionPrimaryKeyField: Ref; + relatedCollectionPrimaryKeyField: Ref; +}; + +export default function isNew( + item: any, + { relationCurrentToJunction, junctionCollectionPrimaryKeyField, relatedCollectionPrimaryKeyField }: IsNewContext +) { + if (!relationCurrentToJunction.value) return; + if (!relationCurrentToJunction.value.junction_field) return; + + const junctionPrimaryKey = junctionCollectionPrimaryKeyField.value.field; + const junctionField = relationCurrentToJunction.value.junction_field; + const relatedPrimaryKey = relatedCollectionPrimaryKeyField.value.field; + const hasPrimaryKey = !!item[junctionPrimaryKey]; + const hasRelatedPrimaryKey = !!item[junctionField]?.[relatedPrimaryKey]; + + return hasPrimaryKey === false && hasRelatedPrimaryKey === false; +} diff --git a/src/interfaces/many-to-many/many-to-many.vue b/src/interfaces/many-to-many/many-to-many.vue index d5ed198acd..305b88a8ee 100644 --- a/src/interfaces/many-to-many/many-to-many.vue +++ b/src/interfaces/many-to-many/many-to-many.vue @@ -2,7 +2,7 @@ {{ $t('relationship_not_setup') }} - +