|
|
|
@ -1,17 +1,19 @@
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import { inject } from '@vue/runtime-core' |
|
|
|
|
import type { TableType, ViewTypes } from 'nocodb-sdk' |
|
|
|
|
import type { TableType } from 'nocodb-sdk' |
|
|
|
|
import { ViewTypes } from 'nocodb-sdk' |
|
|
|
|
import type { Ref } from '#imports' |
|
|
|
|
import { MetaInj, ViewListInj } from '~/components' |
|
|
|
|
import { ActiveViewInj, MetaInj, ViewListInj } from '~/components' |
|
|
|
|
import useViewCreate from '~/composables/useViewCreate' |
|
|
|
|
|
|
|
|
|
const { modelValue, type, selectedViewId } = defineProps<{ type: ViewTypes; modelValue: boolean; selectedViewId?:string }>() |
|
|
|
|
const { modelValue, type } = defineProps<{ type: ViewTypes; modelValue: boolean }>() |
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue', 'created']) |
|
|
|
|
|
|
|
|
|
const valid =ref(false) |
|
|
|
|
const valid = ref(false) |
|
|
|
|
|
|
|
|
|
const viewList = inject(ViewListInj) |
|
|
|
|
const activeView = inject(ActiveViewInj) |
|
|
|
|
|
|
|
|
|
const dialogShow = computed({ |
|
|
|
|
get() { |
|
|
|
@ -22,7 +24,19 @@ const dialogShow = computed({
|
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const { view, createView, generateUniqueTitle, loading } = useViewCreate(inject(MetaInj) as Ref<TableType>, (view) => emit('created', view)) |
|
|
|
|
const { view, createView, generateUniqueTitle, loading } = useViewCreate(inject(MetaInj) as Ref<TableType>, (view) => |
|
|
|
|
emit('created', view), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const typeAlias = computed( |
|
|
|
|
() => |
|
|
|
|
({ |
|
|
|
|
[ViewTypes.GRID]: 'grid', |
|
|
|
|
[ViewTypes.GALLERY]: 'gallery', |
|
|
|
|
[ViewTypes.FORM]: 'form', |
|
|
|
|
[ViewTypes.KANBAN]: 'kanban', |
|
|
|
|
}[type]), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
/* name: 'CreateViewDialog', |
|
|
|
|
props: [ |
|
|
|
@ -84,7 +98,7 @@ const { view, createView, generateUniqueTitle, loading } = useViewCreate(inject(
|
|
|
|
|
<v-card-title class="grey darken-2 subheading" style="height: 30px" /> |
|
|
|
|
<v-card-text class="pt-4 pl-4"> |
|
|
|
|
<p class="headline"> |
|
|
|
|
{{ $t('general.create') }} <span class="text-capitalize">{{ type }}</span> {{ $t('objects.view') }} |
|
|
|
|
{{ $t('general.create') }} <span class="text-capitalize">{{ typeAlias }}</span> {{ $t('objects.view') }} |
|
|
|
|
</p> |
|
|
|
|
<v-form ref="form" v-model="valid" @submit.prevent="createView"> |
|
|
|
|
<!-- label="View Name" --> |
|
|
|
@ -105,7 +119,7 @@ const { view, createView, generateUniqueTitle, loading } = useViewCreate(inject(
|
|
|
|
|
<v-btn class="" small @click="emit('update:modelValue', false)"> |
|
|
|
|
{{ $t('general.cancel') }} |
|
|
|
|
</v-btn> |
|
|
|
|
<v-btn small :loading="loading" class="primary" :disabled="!valid" @click="createView(type, selectedViewId)"> |
|
|
|
|
<v-btn small :loading="loading" class="primary" :disabled="!valid" @click="createView(type, activeView.id)"> |
|
|
|
|
{{ $t('general.submit') }} |
|
|
|
|
</v-btn> |
|
|
|
|
</v-card-actions> |
|
|
|
|