Browse Source

refactor(gui-v2): move expanded form header part to a component

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3025/head
Pranav C 2 years ago
parent
commit
8cc5c3bec4
  1. 19
      packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue
  2. 16
      packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue
  3. 2
      packages/nc-gui-v2/composables/useExpandedFormStore.ts

19
packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue

@ -0,0 +1,19 @@
<script lang="ts" setup>
import { computed } from '#imports'
import { useExpandedFormStoreOrThrow } from '~/composables'
import MdiDoorOpen from '~icons/mdi/door-open'
import MdiDoorClosed from '~icons/mdi/door-closed'
const { commentsDrawer } = useExpandedFormStoreOrThrow()
const drawerToggleIcon = computed(() => (commentsDrawer.value ? MdiDoorOpen : MdiDoorClosed))
</script>
<template>
<div class="flex p-2">
<div class="flex-grow" />
<component :is="drawerToggleIcon" class="" @click="commentsDrawer = !commentsDrawer" />
</div>
</template>
<style scoped></style>

16
packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue

@ -2,13 +2,12 @@
import { isVirtualCol } from 'nocodb-sdk' import { isVirtualCol } from 'nocodb-sdk'
import { useVModel } from '@vueuse/core' import { useVModel } from '@vueuse/core'
import { Ref, computed, provide, toRef } from 'vue' import { Ref, computed, provide, toRef } from 'vue'
import Comments from '~/components/smartsheet/expanded-form/Comments.vue' import Comments from './Comments.vue'
import Header from './Header.vue'
import { useSmartsheetStoreOrThrow } from '~/composables' import { useSmartsheetStoreOrThrow } from '~/composables'
import type { Row } from '~/composables' import type { Row } from '~/composables'
import { useProvideExpandedFormStore } from '~/composables/useExpandedFormStore' import { useProvideExpandedFormStore } from '~/composables/useExpandedFormStore'
import { FieldsInj, IsFormInj, MetaInj } from '~/context' import { FieldsInj, IsFormInj, MetaInj } from '~/context'
import MdiDoorOpen from '~icons/mdi/door-open'
import MdiDoorClosed from '~icons/mdi/door-closed'
interface Props { interface Props {
modelValue: string | null modelValue: string | null
@ -27,21 +26,14 @@ provide(IsFormInj, true)
// accept as a prop // accept as a prop
// const row: Row = { row: {}, rowMeta: {}, oldRow: {} } // const row: Row = { row: {}, rowMeta: {}, oldRow: {} }
const { loadComments } = useProvideExpandedFormStore(meta, row) const { loadComments, commentsDrawer } = useProvideExpandedFormStore(meta, row)
const commentsDrawer = ref(false)
const isExpanded = useVModel(props, 'modelValue', emits) const isExpanded = useVModel(props, 'modelValue', emits)
const drawerToggleIcon = computed(() => (commentsDrawer.value ? MdiDoorOpen : MdiDoorClosed))
</script> </script>
<template> <template>
<a-modal v-model:visible="isExpanded" :footer="null" width="min(90vw,1000px)" :body-style="{ padding: 0 }" :closable="false"> <a-modal v-model:visible="isExpanded" :footer="null" width="min(90vw,1000px)" :body-style="{ padding: 0 }" :closable="false">
<div class="flex p-2"> <Header />
<div class="flex-grow" />
<component :is="drawerToggleIcon" class="" @click="commentsDrawer = !commentsDrawer" />
</div>
<a-card class="!bg-gray-100"> <a-card class="!bg-gray-100">
<div class="flex"> <div class="flex">
<div class="flex-grow"> <div class="flex-grow">

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

@ -17,6 +17,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
const commentsOnly = ref(false) const commentsOnly = ref(false)
const commentsAndLogs = ref([]) const commentsAndLogs = ref([])
const comment = ref('') const comment = ref('')
const commentsDrawer = ref(false)
// todo // todo
const activeView = inject(ActiveViewInj) const activeView = inject(ActiveViewInj)
@ -72,6 +73,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
saveComment, saveComment,
comment, comment,
isYou, isYou,
commentsDrawer,
} }
}, },
'expanded-form-store', 'expanded-form-store',

Loading…
Cancel
Save