Browse Source

feat(gui-v2): copy active view props

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
de27f51f2c
  1. 28
      packages/nc-gui-v2/components/dlg/ViewCreate.vue
  2. 7
      packages/nc-gui-v2/components/smartsheet/Sidebar.vue

28
packages/nc-gui-v2/components/dlg/ViewCreate.vue

@ -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>

7
packages/nc-gui-v2/components/smartsheet/Sidebar.vue

@ -19,7 +19,7 @@ const _isUIAllowed = (view: string) => {}
// todo decide based on route param
loadViews().then(() => {
activeView.value = views.value?.[0]
if (activeView) activeView.value = views.value?.[0]
})
const toggleDrawer = ref(false)
@ -33,12 +33,11 @@ const openCreateViewDlg = (type: ViewTypes) => {
viewCreateType.value = type
}
const onViewCreate = (view)=>{
const onViewCreate = (view) => {
views.value?.push(view)
activeView.value = view
viewCreateDlg.value = false
}
</script>
<template>
@ -270,7 +269,7 @@ const onViewCreate = (view)=>{
</div>
</div>
<DlgViewCreate v-model="viewCreateDlg" :type="viewCreateType" @created="onViewCreate"/>
<DlgViewCreate v-model="viewCreateDlg" :type="viewCreateType" @created="onViewCreate" />
</div>
</template>

Loading…
Cancel
Save