Browse Source

Merge pull request #3078 from nocodb/fix/gui-v2-form-follow-ups

fix(gui-v2): form view follow-up issues
pull/3093/head
navi 2 years ago committed by GitHub
parent
commit
b9023bd989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui-v2/components/dlg/ViewCreate.vue
  2. 14
      packages/nc-gui-v2/components/smartsheet/Form.vue
  3. 4
      packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue
  4. 2
      packages/nc-gui-v2/components/smartsheet/sidebar/RenameableMenuItem.vue
  5. 20
      packages/nc-gui-v2/components/smartsheet/sidebar/index.vue
  6. 2
      packages/nc-gui-v2/composables/useViewData.ts

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

@ -14,6 +14,7 @@ interface Props {
modelValue: boolean modelValue: boolean
type: ViewTypes type: ViewTypes
title?: string title?: string
selectedViewId?: string
} }
interface Emits { interface Emits {
@ -86,6 +87,10 @@ watch(
function init() { function init() {
form.title = generateUniqueTitle(capitalize(ViewTypes[props.type].toLowerCase()), viewList?.value || [], 'title') form.title = generateUniqueTitle(capitalize(ViewTypes[props.type].toLowerCase()), viewList?.value || [], 'title')
if (props.selectedViewId) {
form.copy_from_id = props.selectedViewId
}
nextTick(() => { nextTick(() => {
const el = inputEl?.$el as HTMLInputElement const el = inputEl?.$el as HTMLInputElement

14
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -467,6 +467,9 @@ onMounted(async () => {
<div class="nc-editable item cursor-pointer hover:bg-primary/10 pa-3" @click="activeRow = element.title"> <div class="nc-editable item cursor-pointer hover:bg-primary/10 pa-3" @click="activeRow = element.title">
<div class="flex"> <div class="flex">
<div class="flex flex-1"> <div class="flex flex-1">
<div class="flex flex-row">
<mdi-drag-vertical class="flex flex-1" />
</div>
<SmartsheetHeaderVirtualCell <SmartsheetHeaderVirtualCell
v-if="isVirtualCol(element)" v-if="isVirtualCol(element)"
:column="{ ...element, title: element.label || element.title }" :column="{ ...element, title: element.label || element.title }"
@ -523,14 +526,9 @@ onMounted(async () => {
@change="updateColMeta(element)" @change="updateColMeta(element)"
/> />
</a-form-item> </a-form-item>
<div> <div class="items-center flex">
<a-switch <span class="text-sm text-gray-500 mr-2">{{ $t('general.required') }}</span>
v-model:checked="element.required" <a-switch v-model:checked="element.required" class="my-2" @change="updateColMeta(element)" />
class="my-2"
:checked-children="$t('general.required')"
un-checked-children="Not Required"
@change="updateColMeta(element)"
/>
</div> </div>
</div> </div>
<span class="text-gray-500">{{ element.description }}</span> <span class="text-gray-500">{{ element.description }}</span>

4
packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue

@ -11,7 +11,7 @@ import { extractSdkResponseErrorMsg } from '~/utils'
import { ActiveViewInj, ViewListInj } from '~/context' import { ActiveViewInj, ViewListInj } from '~/context'
interface Emits { interface Emits {
(event: 'openModal', data: { type: ViewTypes; title?: string }): void (event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string }): void
(event: 'deleted'): void (event: 'deleted'): void
(event: 'sorted'): void (event: 'sorted'): void
} }
@ -179,6 +179,8 @@ function onDeleted() {
emits('deleted') emits('deleted')
toDelete = undefined toDelete = undefined
deleteModalVisible = false deleteModalVisible = false
// return to the default view
activeView.value = views.value[0]
} }
</script> </script>

2
packages/nc-gui-v2/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -85,7 +85,7 @@ function focusInput(el: HTMLInputElement) {
/** Duplicate a view */ /** Duplicate a view */
// todo: This is not really a duplication, maybe we need to implement a true duplication? // todo: This is not really a duplication, maybe we need to implement a true duplication?
function onDuplicate() { function onDuplicate() {
emits('openModal', { type: vModel.value.type, title: vModel.value.title }) emits('openModal', { type: vModel.value.type, title: vModel.value.title, copyViewId: vModel.value.id })
$e('c:view:copy', { view: vModel.value.type }) $e('c:view:copy', { view: vModel.value.type })
} }

20
packages/nc-gui-v2/components/smartsheet/sidebar/index.vue

@ -3,7 +3,7 @@ import type { FormType, GalleryType, GridType, KanbanType, ViewTypes } from 'noc
import MenuTop from './MenuTop.vue' import MenuTop from './MenuTop.vue'
import MenuBottom from './MenuBottom.vue' import MenuBottom from './MenuBottom.vue'
import Toolbar from './toolbar/index.vue' import Toolbar from './toolbar/index.vue'
import { computed, inject, provide, ref, useRoute, useViews, watch } from '#imports' import { computed, inject, provide, ref, useRoute, useRouter, useViews, watch } from '#imports'
import { ActiveViewInj, MetaInj, RightSidebarInj, ViewListInj } from '~/context' import { ActiveViewInj, MetaInj, RightSidebarInj, ViewListInj } from '~/context'
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())
@ -12,6 +12,8 @@ const activeView = inject(ActiveViewInj, ref())
const { views, loadViews } = useViews(meta) const { views, loadViews } = useViews(meta)
const router = useRouter()
const route = useRoute() const route = useRoute()
provide(ViewListInj, views) provide(ViewListInj, views)
@ -27,6 +29,9 @@ let viewCreateType = $ref<ViewTypes>()
/** View title to create from modal (when duplicating) */ /** View title to create from modal (when duplicating) */
let viewCreateTitle = $ref('') let viewCreateTitle = $ref('')
/** selected view id for copying view meta */
let selectedViewId = $ref('')
/** is view creation modal open */ /** is view creation modal open */
let modalOpen = $ref(false) let modalOpen = $ref(false)
@ -49,16 +54,18 @@ watch(
) )
/** Open view creation modal */ /** Open view creation modal */
function openModal({ type, title = '' }: { type: ViewTypes; title: string }) { function openModal({ type, title = '', copyViewId }: { type: ViewTypes; title: string; copyViewId: string }) {
modalOpen = true modalOpen = true
viewCreateType = type viewCreateType = type
viewCreateTitle = title viewCreateTitle = title
selectedViewId = copyViewId
} }
/** Handle view creation */ /** Handle view creation */
function onCreate(view: GridType | FormType | KanbanType | GalleryType) { function onCreate(view: GridType | FormType | KanbanType | GalleryType) {
views.value.push(view) views.value.push(view)
activeView.value = view activeView.value = view
router.push({ params: { viewTitle: view.title || '' } })
modalOpen = false modalOpen = false
} }
</script> </script>
@ -126,7 +133,14 @@ function onCreate(view: GridType | FormType | KanbanType | GalleryType) {
<MenuBottom @open-modal="openModal" /> <MenuBottom @open-modal="openModal" />
</div> </div>
<dlg-view-create v-if="views" v-model="modalOpen" :title="viewCreateTitle" :type="viewCreateType" @created="onCreate" /> <dlg-view-create
v-if="views"
v-model="modalOpen"
:title="viewCreateTitle"
:type="viewCreateType"
:selected-view-id="selectedViewId"
@created="onCreate"
/>
</a-layout-sider> </a-layout-sider>
</template> </template>

2
packages/nc-gui-v2/composables/useViewData.ts

@ -209,7 +209,7 @@ export function useViewData(
const deleteRowById = async (id: string) => { const deleteRowById = async (id: string) => {
if (!id) { if (!id) {
throw new Error('Delete not allowed for table which doesn\'t have primary Key') throw new Error("Delete not allowed for table which doesn't have primary Key")
} }
const res: any = await $api.dbViewRow.delete( const res: any = await $api.dbViewRow.delete(

Loading…
Cancel
Save