Browse Source

chore(nc-gui): cleanup

pull/3669/head
braks 2 years ago committed by Raju Udava
parent
commit
90372f280a
  1. 8
      packages/nc-gui/components/general/PoweredBy.vue
  2. 22
      packages/nc-gui/components/smartsheet/Form.vue
  3. 4
      packages/nc-gui/pages/[projectType]/form/[viewId]/index.vue
  4. 8
      packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue
  5. 55
      packages/nc-gui/pages/[projectType]/form/[viewId]/index/survey.vue
  6. 2
      packages/nc-gui/pages/index/index.vue

8
packages/nc-gui/components/general/PoweredBy.vue

@ -5,13 +5,13 @@ import { openLink } from '#imports'
<template> <template>
<button <button
type="button" type="button"
class="cursor-pointer group text-xs text-slate-500 hover:text-primary dark:hover:text-white dark:text-slate-300 mx-auto my-4 flex justify-center gap-2 items-center" class="cursor-pointer group text-xs text-slate-500 hover:text-primary dark:hover:text-white dark:text-slate-300 mx-auto my-4 flex justify-center gap-1 items-center"
@click="openLink('https://github.com/nocodb/nocodb')" @click="openLink('https://github.com/nocodb/nocodb')"
> >
<span class="bg-primary bg-opacity-100 rounded"> <span class="rounded">
<img width="32" height="32" alt="NocoDB" src="~/assets/img/icons/512x512-trans.png" /> <GeneralNocoIcon class="!relative !top-0" width="32" height="32" />
</span> </span>
<span class="color-transition transform group-hover:(scale-103)">Powered by NocoDB</span> <span>Powered by NocoDB</span>
</button> </button>
</template> </template>

22
packages/nc-gui/components/smartsheet/Form.vue

@ -392,9 +392,11 @@ watch(view, (nextView) => {
<div class="text-center">{{ formViewData.success_msg || 'Successfully submitted form data' }}</div> <div class="text-center">{{ formViewData.success_msg || 'Successfully submitted form data' }}</div>
</template> </template>
</a-alert> </a-alert>
<div v-if="formViewData.show_blank_form" class="text-gray-400 mt-4"> <div v-if="formViewData.show_blank_form" class="text-gray-400 mt-4">
New form will be loaded after {{ secondsRemain }} seconds New form will be loaded after {{ secondsRemain }} seconds
</div> </div>
<div v-if="formViewData.submit_another_form" class="text-center mt-4"> <div v-if="formViewData.submit_another_form" class="text-center mt-4">
<a-button type="primary" size="large" @click="submitted = false"> Submit Another Form</a-button> <a-button type="primary" size="large" @click="submitted = false"> Submit Another Form</a-button>
</div> </div>
@ -403,7 +405,7 @@ watch(view, (nextView) => {
</a-row> </a-row>
<a-row v-else class="h-full flex"> <a-row v-else class="h-full flex">
<a-col v-if="isEditable" :span="8" class="shadow p-2 md:p-4 h-full overflow-auto scrollbar-thin-primary nc-form-left-drawer"> <a-col v-if="isEditable" :span="8" class="shadow p-2 md:p-4 h-full overflow-auto scrollbar-thin-dull nc-form-left-drawer">
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
<div class="flex-1 text-lg"> <div class="flex-1 text-lg">
{{ $t('objects.fields') }} {{ $t('objects.fields') }}
@ -444,7 +446,7 @@ watch(view, (nextView) => {
<template #item="{ element, index }"> <template #item="{ element, index }">
<a-card <a-card
size="small" size="small"
class="cursor-pointer item hover:(bg-primary ring-1 ring-accent ring-opacity-100) bg-opacity-10 !rounded !shadow-lg" class="!border-0 color-transition cursor-pointer item hover:(bg-primary ring-1 ring-accent ring-opacity-100) bg-opacity-10 !rounded !shadow-lg"
@mousedown="moved = false" @mousedown="moved = false"
@mousemove="moved = false" @mousemove="moved = false"
@mouseup="handleMouseUp(element, index)" @mouseup="handleMouseUp(element, index)"
@ -489,7 +491,7 @@ watch(view, (nextView) => {
</button> </button>
<template #overlay> <template #overlay>
<LazySmartsheetColumnEditOrAddProvider <SmartsheetColumnEditOrAddProvider
v-if="showColumnDropdown" v-if="showColumnDropdown"
@submit="submitCallback" @submit="submitCallback"
@cancel="showColumnDropdown = false" @cancel="showColumnDropdown = false"
@ -502,7 +504,7 @@ watch(view, (nextView) => {
</Draggable> </Draggable>
</a-col> </a-col>
<a-col v-if="formViewData" :span="isEditable ? 16 : 24" class="h-full overflow-auto scrollbar-thin-primary"> <a-col v-if="formViewData" :span="isEditable ? 16 : 24" class="h-full overflow-auto scrollbar-thin-dull">
<div class="h-[200px] bg-primary bg-opacity-75"> <div class="h-[200px] bg-primary bg-opacity-75">
<!-- for future implementation of cover image --> <!-- for future implementation of cover image -->
</div> </div>
@ -517,13 +519,13 @@ watch(view, (nextView) => {
}" }"
> >
<a-form ref="formRef" :model="formState" class="nc-form" no-style> <a-form ref="formRef" :model="formState" class="nc-form" no-style>
<a-card class="!rounded !shadow !m-2 md:!m-4 xl:!m-8" :body-style="{ paddingLeft: '0px', paddingRight: '0px' }"> <a-card class="!rounded !shadow !m-2 md:(!m-4) xl:(!m-8)" :body-style="{ paddingLeft: '0px', paddingRight: '0px' }">
<!-- Header --> <!-- Header -->
<div v-if="isEditable" class="px-4"> <div v-if="isEditable" class="px-4 lg:px-12">
<a-form-item v-if="isEditable"> <a-form-item v-if="isEditable">
<a-input <a-input
v-model:value="formViewData.heading" v-model:value="formViewData.heading"
class="w-full !font-bold !text-4xl !border-0 !border-b-1 !border-dashed" class="w-full !font-bold !text-4xl !border-0 !border-b-1 !border-dashed !rounded-none !border-gray-400"
:style="{ borderRightWidth: '0px !important' }" :style="{ borderRightWidth: '0px !important' }"
size="large" size="large"
hide-details hide-details
@ -537,11 +539,11 @@ watch(view, (nextView) => {
<div v-else class="px-4 ml-3 w-full text-bold text-4xl">{{ formViewData.heading }}</div> <div v-else class="px-4 ml-3 w-full text-bold text-4xl">{{ formViewData.heading }}</div>
<!-- Sub Header --> <!-- Sub Header -->
<div v-if="isEditable" class="px-4"> <div v-if="isEditable" class="px-4 lg:px-12">
<a-form-item> <a-form-item>
<a-input <a-input
v-model:value="formViewData.subheading" v-model:value="formViewData.subheading"
class="w-full !border-0 !border-b-1 !border-dashed" class="w-full !border-0 !border-b-1 !border-dashed !rounded-none !border-gray-400"
:style="{ borderRightWidth: '0px !important' }" :style="{ borderRightWidth: '0px !important' }"
size="large" size="large"
hide-details hide-details
@ -569,7 +571,7 @@ watch(view, (nextView) => {
> >
<template #item="{ element, index }"> <template #item="{ element, index }">
<div <div
class="nc-editable item cursor-pointer hover:(bg-primary bg-opacity-10 ring-1 ring-accent ring-opacity-100) px-4 lg:px-12 py-4 relative" class="color-transition nc-editable item cursor-pointer hover:(bg-primary bg-opacity-10 ring-1 ring-accent ring-opacity-100) px-4 lg:px-12 py-4 relative"
:class="[ :class="[
`nc-form-drag-${element.title.replaceAll(' ', '')}`, `nc-form-drag-${element.title.replaceAll(' ', '')}`,
{ {

4
packages/nc-gui/pages/[projectType]/form/[viewId]/index.vue

@ -31,7 +31,7 @@ const onClick = () => {
<template> <template>
<div <div
class="overflow-y-auto overflow-x-hidden flex flex-wrap color-transition nc-form-view relative md:bg-primary bg-opacity-10 dark:(bg-slate-900) h-full min-h-[600px]" class="overflow-y-auto overflow-x-hidden flex flex-wrap color-transition nc-form-view relative md:bg-primary bg-opacity-10 dark:(bg-slate-900) h-full min-h-[600px] nc-form-signin"
> >
<NuxtPage /> <NuxtPage />
@ -40,7 +40,7 @@ const onClick = () => {
</div> </div>
<div <div
class="flex items-center justify-center cursor-pointer absolute top-15 right-15 rounded-full p-2 bg-white dark:(bg-slate-600) shadow hover:(ring-1 ring-accent ring-opacity-100)" class="color-transition flex items-center justify-center cursor-pointer absolute top-15 right-15 rounded-full p-2 bg-white dark:(bg-slate-600) shadow hover:(ring-1 ring-accent ring-opacity-100)"
@click="onClick" @click="onClick"
> >
<Transition name="slide-left" duration="250" mode="out-in"> <Transition name="slide-left" duration="250" mode="out-in">

8
packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue

@ -65,14 +65,14 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
<div class="flex flex-col gap-6"> <div class="flex flex-col gap-6">
<div v-for="(field, index) in formColumns" :key="index" class="flex flex-col gap-2"> <div v-for="(field, index) in formColumns" :key="index" class="flex flex-col gap-2">
<div class="flex nc-form-column-label"> <div class="flex nc-form-column-label">
<SmartsheetHeaderVirtualCell <LazySmartsheetHeaderVirtualCell
v-if="isVirtualCol(field)" v-if="isVirtualCol(field)"
:column="{ ...field, title: field.label || field.title }" :column="{ ...field, title: field.label || field.title }"
:required="isRequired(field, field.required)" :required="isRequired(field, field.required)"
:hide-menu="true" :hide-menu="true"
/> />
<SmartsheetHeaderCell <LazySmartsheetHeaderCell
v-else v-else
:column="{ ...field, title: field.label || field.title }" :column="{ ...field, title: field.label || field.title }"
:required="isRequired(field, field.required)" :required="isRequired(field, field.required)"
@ -81,14 +81,14 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
</div> </div>
<div> <div>
<SmartsheetVirtualCell <LazySmartsheetVirtualCell
v-if="isVirtualCol(field)" v-if="isVirtualCol(field)"
class="mt-0 nc-input" class="mt-0 nc-input"
:class="`nc-form-input-${field.title.replaceAll(' ', '')}`" :class="`nc-form-input-${field.title.replaceAll(' ', '')}`"
:column="field" :column="field"
/> />
<SmartsheetCell <LazySmartsheetCell
v-else v-else
v-model="formState[field.title]" v-model="formState[field.title]"
class="nc-input" class="nc-input"

55
packages/nc-gui/pages/[projectType]/form/[viewId]/index/survey.vue

@ -1,4 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' import { RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import { SwipeDirection } from '@vueuse/core' import { SwipeDirection } from '@vueuse/core'
import { import {
@ -7,16 +8,22 @@ import {
onKeyStroke, onKeyStroke,
provide, provide,
ref, ref,
useEventListener,
usePointerSwipe, usePointerSwipe,
useSharedFormStoreOrThrow, useSharedFormStoreOrThrow,
useStepper, useStepper,
} from '#imports' } from '#imports'
enum TransitionDirection {
Left = 'left',
Right = 'right',
}
const { v$, formState, formColumns, submitForm, submitted, secondsRemain, sharedFormView } = useSharedFormStoreOrThrow() const { v$, formState, formColumns, submitForm, submitted, secondsRemain, sharedFormView } = useSharedFormStoreOrThrow()
const isTransitioning = ref(false) const isTransitioning = ref(false)
const transitionName = ref<'left' | 'right'>('left') const transitionName = ref<TransitionDirection>(TransitionDirection.Left)
const el = ref<HTMLDivElement>() const el = ref<HTMLDivElement>()
@ -36,36 +43,44 @@ provide(DropZoneRef, el)
const steps = computed(() => { const steps = computed(() => {
if (!formColumns.value) return [] if (!formColumns.value) return []
return formColumns.value.reduce((acc, column) => {
acc.push((column as any).label || column.title) return formColumns.value.reduce<string[]>((acc, column) => {
const title = column.label || column.title
if (!title) return acc
acc.push(title)
return acc return acc
}, [] as string[]) }, [])
}) })
const { index, goToPrevious, goToNext, isFirst, isLast } = useStepper(steps) const { index, goToPrevious, goToNext, isFirst, isLast } = useStepper(steps)
const field = computed(() => formColumns.value?.[index.value]) const field = computed(() => formColumns.value?.[index.value])
function isRequired(_columnObj: Record<string, any>, required = false) { function isRequired(column: ColumnType, required = false) {
let columnObj = _columnObj let columnObj = column
if ( if (
columnObj.uidt === UITypes.LinkToAnotherRecord && columnObj.uidt === UITypes.LinkToAnotherRecord &&
columnObj.colOptions && columnObj.colOptions &&
columnObj.colOptions.type === RelationTypes.BELONGS_TO (columnObj.colOptions as { type: RelationTypes }).type === RelationTypes.BELONGS_TO
) { ) {
columnObj = formColumns.value?.find((c) => c.id === columnObj.colOptions.fk_child_column_id) as Record<string, any> columnObj = formColumns.value?.find(
(c) => c.id === (columnObj.colOptions as LinkToAnotherRecordType).fk_child_column_id,
) as ColumnType
} }
return !!(required || (columnObj && columnObj.rqd && !columnObj.cdf)) return required || (columnObj && columnObj.rqd && !columnObj.cdf)
} }
function transition(direction: 'left' | 'right') { function transition(direction: TransitionDirection) {
isTransitioning.value = true isTransitioning.value = true
transitionName.value = direction transitionName.value = direction
setTimeout(() => { setTimeout(() => {
transitionName.value = transitionName.value === 'left' ? 'right' : 'left' transitionName.value =
transitionName.value === TransitionDirection.Left ? TransitionDirection.Right : TransitionDirection.Left
}, 500) }, 500)
setTimeout(() => { setTimeout(() => {
@ -85,7 +100,7 @@ async function goNext() {
if (!isValid) return if (!isValid) return
} }
transition('left') transition(TransitionDirection.Left)
goToNext() goToNext()
} }
@ -93,7 +108,7 @@ async function goNext() {
async function goPrevious() { async function goPrevious() {
if (isFirst.value) return if (isFirst.value) return
transition('right') transition(TransitionDirection.Right)
goToPrevious() goToPrevious()
} }
@ -138,14 +153,14 @@ onKeyStroke(['ArrowRight', 'ArrowUp', 'Enter', 'Space'], goNext)
> >
<div v-if="field && !submitted" class="flex flex-col gap-2"> <div v-if="field && !submitted" class="flex flex-col gap-2">
<div class="flex nc-form-column-label"> <div class="flex nc-form-column-label">
<SmartsheetHeaderVirtualCell <LazySmartsheetHeaderVirtualCell
v-if="isVirtualCol(field)" v-if="isVirtualCol(field)"
:column="{ ...field, title: field.label || field.title }" :column="{ ...field, title: field.label || field.title }"
:required="isRequired(field, field.required)" :required="isRequired(field, field.required)"
:hide-menu="true" :hide-menu="true"
/> />
<SmartsheetHeaderCell <LazySmartsheetHeaderCell
v-else v-else
:column="{ ...field, title: field.label || field.title }" :column="{ ...field, title: field.label || field.title }"
:required="isRequired(field, field.required)" :required="isRequired(field, field.required)"
@ -154,14 +169,14 @@ onKeyStroke(['ArrowRight', 'ArrowUp', 'Enter', 'Space'], goNext)
</div> </div>
<div> <div>
<SmartsheetVirtualCell <LazySmartsheetVirtualCell
v-if="isVirtualCol(field)" v-if="isVirtualCol(field)"
class="mt-0 nc-input" class="mt-0 nc-input"
:class="`nc-form-input-${field.title.replaceAll(' ', '')}`" :class="`nc-form-input-${field.title.replaceAll(' ', '')}`"
:column="field" :column="field"
/> />
<SmartsheetCell <LazySmartsheetCell
v-else v-else
v-model="formState[field.title]" v-model="formState[field.title]"
class="nc-input" class="nc-input"
@ -200,13 +215,13 @@ onKeyStroke(['ArrowRight', 'ArrowUp', 'Enter', 'Space'], goNext)
<a-tooltip <a-tooltip
v-if="!isLast" v-if="!isLast"
placement="left" placement="bottom"
:title="v$.localState[field.title]?.$error ? v$.localState[field.title].$errors[0].$message : 'Go to next'" :title="v$.localState[field.title]?.$error ? v$.localState[field.title].$errors[0].$message : 'Go to next'"
:mouse-enter-delay="v$.localState[field.title]?.$error ? 0 : 1" :mouse-enter-delay="0.2"
:mouse-leave-delay="0" :mouse-leave-delay="0"
> >
<button class="group color-transition transform absolute right-1 top-1/2 md:static hover:scale-110" @click="goNext"> <button class="group color-transition transform absolute right-1 top-1/2 md:static hover:scale-110" @click="goNext">
<TransitionGroup name="layout"> <TransitionGroup name="slide-left" mode="out-in">
<MdiCloseCircleOutline v-if="v$.localState[field.title]?.$error" class="text-red-500 text-2xl md:text-md" /> <MdiCloseCircleOutline v-if="v$.localState[field.title]?.$error" class="text-red-500 text-2xl md:text-md" />
<MdiChevronRight v-else class="group-hover:text-accent text-2xl md:text-md" /> <MdiChevronRight v-else class="group-hover:text-accent text-2xl md:text-md" />
</TransitionGroup> </TransitionGroup>

2
packages/nc-gui/pages/index/index.vue

@ -24,7 +24,7 @@ useSidebar('nc-left-sidebar', { hasSidebar: false })
<div class="flex-1 flex gap-6 flex-col justify-center items-center md:(flex-row justify-between items-start)"> <div class="flex-1 flex gap-6 flex-col justify-center items-center md:(flex-row justify-between items-start)">
<template v-if="route.name === 'index-index'"> <template v-if="route.name === 'index-index'">
<TransitionGroup name="page" mode="out-in"> <TransitionGroup name="page" mode="out-in">
<div> <div key="social-card">
<LazyGeneralSocialCard /> <LazyGeneralSocialCard />
</div> </div>

Loading…
Cancel
Save