From 3cb8e9e606a3a168f0c752f2f5286c25d5ea65c5 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:56:30 +0200 Subject: [PATCH] refactor(gui-v2): change view create to ant design cmps --- .../nc-gui-v2/components/dlg/ViewCreate.vue | 116 ++++-------------- .../components/smartsheet/Sidebar.vue | 15 ++- 2 files changed, 36 insertions(+), 95 deletions(-) diff --git a/packages/nc-gui-v2/components/dlg/ViewCreate.vue b/packages/nc-gui-v2/components/dlg/ViewCreate.vue index d23dfb6c29..7b717c75bc 100644 --- a/packages/nc-gui-v2/components/dlg/ViewCreate.vue +++ b/packages/nc-gui-v2/components/dlg/ViewCreate.vue @@ -2,7 +2,7 @@ import { inject } from '@vue/runtime-core' import type { TableType } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk' -import type { Ref } from '#imports' +import type { Ref } from 'vue' import { ActiveViewInj, MetaInj, ViewListInj } from '~/context' import useViewCreate from '~/composables/useViewCreate' @@ -13,8 +13,13 @@ const emit = defineEmits(['update:modelValue', 'created']) const valid = ref(false) const viewList = inject(ViewListInj) + const activeView = inject(ActiveViewInj) +const inputEl = ref() + +const form = ref() + const dialogShow = computed({ get() { return modelValue @@ -38,8 +43,6 @@ const typeAlias = computed( }[type]), ) -const inputEl = ref() -const form = ref() watch( () => modelValue, (v) => { @@ -55,93 +58,28 @@ watch( }, ) -/* name: 'CreateViewDialog', - props: [ - 'value', - 'nodes', - 'table', - 'alias', - 'show_as', - 'viewsCount', - 'primaryValueColumn', - 'meta', - 'copyView', - 'viewsList', - 'selectedViewId', - ], - data: () => ({ - valid: false, - view_name: '', - loading: false, - queryParams: {}, - }), - computed: { - localState: { - get() { - return this.value; - }, - set(v) { - this.$emit('input', v); - }, - }, - typeAlias() { - return { - [ViewTypes.GRID]: 'grid', - [ViewTypes.GALLERY]: 'gallery', - [ViewTypes.FORM]: 'form', - [ViewTypes.KANBAN]: 'kanban', - }[this.show_as]; - }, - }, - mounted() { - try { - if (this.copyView && this.copyView.query_params) { - this.queryParams = { ...JSON.parse(this.copyView.query_params) }; - } - } catch (e) {} - this.view_name = `${this.alias || this.table}${this.viewsCount}`; - - this.$nextTick(() => { - const input = this.$refs.name.$el.querySelector('input'); - input.setSelectionRange(0, this.view_name.length); - input.focus(); - }); - }, */ +const onSubmit = () => { + const isValid = form.value.validate() + if (isValid) { + createView(view.type!) + emit('update:modelValue', false) + } +} - - diff --git a/packages/nc-gui-v2/components/smartsheet/Sidebar.vue b/packages/nc-gui-v2/components/smartsheet/Sidebar.vue index aef8234608..9a27d50b19 100644 --- a/packages/nc-gui-v2/components/smartsheet/Sidebar.vue +++ b/packages/nc-gui-v2/components/smartsheet/Sidebar.vue @@ -24,9 +24,11 @@ watch( { immediate: true }, ) -const toggleDrawer = $ref(false) +const toggleDrawer = ref(false) // todo: identify based on meta -const isView = $ref(false) +const isView = ref(false) + +const enableDummyFeat = ref(false) let viewCreateType = $ref() @@ -80,23 +82,24 @@ function onViewCreate(view: GridType | FormType | KanbanType | GalleryType) { {{ $t('msg.info.addView.grid') }} +