π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix(nc-gui): some review changes
Ramesh Mane3dcf49c68a6b
diff --git a/packages/nc-gui/components/auth/onboarding/Layout/ImagePreviewSection.vue b/packages/nc-gui/components/auth/onboarding/Layout/ImagePreviewSection.vueindex 020038200f..5480d7d7f7 100644--- a/packages/nc-gui/components/auth/onboarding/Layout/ImagePreviewSection.vue+++ b/packages/nc-gui/components/auth/onboarding/Layout/ImagePreviewSection.vue@@ -114,10 +114,14 @@ const viewImage = computed(() => {const nextQuestionViewImage = computed(() => {return nextQuestionRightSectionInfo.value ? getViewImage(nextQuestionRightSectionInfo.value.imageName) : undefined})++defineExpose({+ bgColorClass,+})</script><template>- <div class="flex flex-col items-center justify-center h-full relative" :class="[bgColorClass]">+ <div class="flex flex-col items-center justify-center h-full relative overflow-hidden" :class="[bgColorClass]"><div class="nc-view-image-box" :style="{ backgroundImage: `url(${viewImage})` }"></div><div class="nc-view-image-box nc-moscot-image-box"><div class="h-full w-full relative">diff --git a/packages/nc-gui/components/auth/onboarding/Layout/index.vue b/packages/nc-gui/components/auth/onboarding/Layout/index.vueindex 8626f23679..5458ac8c10 100644--- a/packages/nc-gui/components/auth/onboarding/Layout/index.vue+++ b/packages/nc-gui/components/auth/onboarding/Layout/index.vue@@ -3,6 +3,8 @@ const { stepper, onCompleteOnboardingFlow, isFilledQuestionAnswer, isFilledVisibconst { index: stepIndex, steps, isLast, isFirst, goToNext, goToPrevious } = stepper+const imagePreviewSectionRef = ref()+const isFilledSecondScreenOptions = computed(() => {return questionsMap.value[2] ? isFilledQuestionAnswer(questionsMap.value[2]) : false})@@ -13,11 +15,30 @@ const progress = computed(() => {text: `${stepIndex.value + 1} / ${steps.value.length}`,}})++useEventListener('keydown', (event) => {+ if (!isFilledVisibleOptions.value) return++ if (event.key === 'Enter') {+ if (isLast.value) {+ onCompleteOnboardingFlow(false)+ } else {+ goToNext()+ }+ }+})</script><template><div class="w-full flex items-stretch h-full">- <div class="w-full lg:(w-1/2) transition-width duration-250 h-full flex flex-col gap-[120px] nc-scrollbar-thin relative">+ <div class="hidden lg:block w-1/2">+ <slot name="imagePreviewSection">+ <AuthOnboardingLayoutImagePreviewSection ref="imagePreviewSectionRef" />+ </slot>+ </div>+ <div+ class="w-full lg:(w-1/2) transition-width duration-250 h-full flex flex-col gap-[120px] nc-scrollbar-thin relative border-l-1 border-nc-border-gray-medium"+ ><headerclass="px-4 pt-6 lg:(pt-12 px-8) flex items-center justify-between w-full max-w-[672px] lg:max-w-[704px] mx-auto sticky top-0 lg:-top-4 bg-white">@@ -30,7 +51,7 @@ const progress = computed(() => {status="normal"stroke-color="#3366FF"trail-color="#F0F3FF"- :format="() => progress.text"+ :show-info="false"/></div></header>@@ -62,30 +83,23 @@ const progress = computed(() => {</NcButton><template v-if="stepIndex !== 0 || isFilledSecondScreenOptions"><NcButton- v-if="!isLast"type="primary"size="small"- :disabled="isLast || !isFilledVisibleOptions"- @click="goToNext()"+ :disabled="!isFilledVisibleOptions"+ @click="isLast ? onCompleteOnboardingFlow(false) : goToNext()"><div class="flex items-center gap-2">- {{ $t('labels.next') }}+ {{ isLast ? $t('general.finish') : $t('labels.next') }}<div class="h-full rounded px-1 py-0.5"><GeneralIcon icon="ncEnter" class="w-4 h-4" /></div></div></NcButton>- <div v-else></div></template></div></footer></slot></div>- <div class="hidden lg:block w-1/2 border-l">- <slot name="imagePreviewSection">- <AuthOnboardingLayoutImagePreviewSection />- </slot>- </div></div></template>diff --git a/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue b/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vueindex ad9bacffb4..b7faa378ed 100644--- a/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue+++ b/packages/nc-gui/components/auth/onboarding/Question/Option/Icon.vue@@ -35,7 +35,7 @@ const bgColorClass = computed(() => {:class="[bgColorClass,{- 'rounded-lg': bgColorClass,+ 'rounded-l-lg': bgColorClass,},]":style="{@@ -60,8 +60,8 @@ const bgColorClass = computed(() => {:key="i"class="flex-none w-3 h-3":class="{- 'bg-green-600': i <= index,- 'bg-nc-bg-gray-dark': i !== index,+ 'bg-green-600': i <= index + 1,+ 'bg-nc-bg-gray-dark': i > index + 1,'rounded-l-full': i === 1,'rounded-r-full': i === totalOptions,}"diff --git a/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue b/packages/nc-gui/components/auth/onboarding/Question/Option/index.vueindex 90f5928510..38c9eb118f 100644--- a/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue+++ b/packages/nc-gui/components/auth/onboarding/Question/Option/index.vue@@ -35,7 +35,7 @@ const { option } = toRefs(props)<style lang="scss" scoped>.nc-onboarding-option {- @apply flex items-center gap-2.5 px-3 py-2 border-1 border-nc-border-gray-medium rounded-lg cursor-pointer select-none transition-all duration-250;+ @apply bg-white flex items-center gap-2.5 px-3 py-2 overflow-hidden border-1 border-nc-border-gray-medium rounded-lg cursor-pointer select-none transition-all duration-250;box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.08);@@ -43,6 +43,10 @@ const { option } = toRefs(props)@apply bg-nc-bg-gray-extralight;}+ &.nc-has-icon-bg-color {+ @apply !py-0 !pl-0;+ }+&.nc-selected {@apply border-nc-border-brand bg-nc-bg-brand !shadow-selected;}diff --git a/packages/nc-gui/components/auth/onboarding/Question/index.vue b/packages/nc-gui/components/auth/onboarding/Question/index.vueindex 85369c0f8b..4b7a621ddc 100644--- a/packages/nc-gui/components/auth/onboarding/Question/index.vue+++ b/packages/nc-gui/components/auth/onboarding/Question/index.vue@@ -22,6 +22,10 @@ const anyOptionHasIcon = computed(() => {return options.value.some((option) => option.iconType || (!option.iconType && option.icon))})+const anyOptionHasBgColor = computed(() => {+ return options.value.some((option) => option.iconColor)+})+const isOptionSelected = (option: OnboardingOptionType) => {if (question.value.inputType === 'singleSelect') {return formState.value[question.value.id] === option.value@@ -47,6 +51,7 @@ const isOptionSelected = (option: OnboardingOptionType) => {:class="{'!justify-center': !anyOptionHasIcon,'nc-selected': isOptionSelected(option),+ 'nc-has-icon-bg-color': anyOptionHasBgColor,}"/></template>diff --git a/packages/nc-gui/components/auth/onboarding/index.vue b/packages/nc-gui/components/auth/onboarding/index.vueindex 1f3a3bf297..46713513b2 100644--- a/packages/nc-gui/components/auth/onboarding/index.vue+++ b/packages/nc-gui/components/auth/onboarding/index.vue@@ -1,7 +1,7 @@<script lang="ts" setup>import type { VNodeRef } from '@vue/runtime-core'-const { showOnboardingFlow, onInitOnboardingFlow, onCompleteOnboardingFlow, visibleQuestions, stepper } = useOnboardingFlow()+const { showOnboardingFlow, onInitOnboardingFlow, visibleQuestion, stepper } = useOnboardingFlow()const autoScrollQuestionRefs = ref<HTMLDivElement>()@@ -13,12 +13,10 @@ const onSelectRef: VNodeRef = (el) => {let timer: anywatch(- [() => visibleQuestions.value.length, () => stepper.index.value],- ([newValue, newStepperIndex], [oldValue, oldStepperIndex], cleanup) => {- if (newValue !== 2 || oldValue !== 1 || newStepperIndex !== oldStepperIndex) return-+ () => visibleQuestion.value.id,+ (_newValue, _oldValue, cleanup) => {timer = setTimeout(() => {- autoScrollQuestionRefs.value?.scrollIntoView({ behavior: 'smooth' })+ autoScrollQuestionRefs.value?.scrollIntoView({ behavior: 'smooth', block: 'start' })}, 300)cleanup(() => {@@ -31,23 +29,21 @@ onMounted(() => {onInitOnboardingFlow()})-useEventListener('beforeunload', (event) => {- if (!showOnboardingFlow.value) return+// useEventListener('beforeunload', (event) => {+// if (!showOnboardingFlow.value) return- // Recommended- event.preventDefault()+// // Recommended+// event.preventDefault()- // Included for legacy support, e.g. Chrome/Edge < 119- event.returnValue = ''-})+// // Included for legacy support, e.g. Chrome/Edge < 119+// event.returnValue = ''+// })</script><template><AuthOnboardingLayout><template #content>- <template v-for="(question, index) of visibleQuestions" :key="question.id">- <AuthOnboardingQuestion :question="question" :question-index="index" :ref="onSelectRef" />- </template>+ <AuthOnboardingQuestion :question="visibleQuestion" :question-index="stepper.index.value" :ref="onSelectRef" /></template></AuthOnboardingLayout></template>diff --git a/packages/nc-gui/composables/useOnboardingFlow.ts b/packages/nc-gui/composables/useOnboardingFlow.tsindex 54ec06f4ed..ee631fd1b5 100644--- a/packages/nc-gui/composables/useOnboardingFlow.ts+++ b/packages/nc-gui/composables/useOnboardingFlow.ts@@ -40,6 +40,12 @@ export interface OnboardingQuestionType {height: numberfullWidth?: boolean}+ config?: {+ /**+ * Default value is 2+ */+ optionsInEachRow?: number+ }}export const useOnboardingFlow = createSharedComposable(() => {@@ -58,7 +64,7 @@ export const useOnboardingFlow = createSharedComposable(() => {/*** If true, the onboarding flow will be shown in home page - `/`*/- const showOnboardingFlowLocalState = ref(false)+ const showOnboardingFlowLocalState = ref(true)const showOnboardingFlow = computed(() => {return isEnabledOnboardingFlow.value && showOnboardingFlowLocalState.value && route.value.name === 'index'@@ -81,11 +87,6 @@ export const useOnboardingFlow = createSharedComposable(() => {icon: 'ncBriefcase',iconColor: 'orange',},- {- value: 'Personal',- icon: 'ncUser',- iconColor: 'green',- },{value: 'School',icon: 'ncGraduationCap',@@ -96,6 +97,11 @@ export const useOnboardingFlow = createSharedComposable(() => {icon: 'ncHeart',iconColor: 'pink',},+ {+ value: 'Personal',+ icon: 'ncUser',+ iconColor: 'green',+ },],rightSection: {themeColor: 'orange',@@ -106,6 +112,9 @@ export const useOnboardingFlow = createSharedComposable(() => {width: 40,height: 40,},+ config: {+ optionsInEachRow: 1,+ },},{id: 2,@@ -168,9 +177,9 @@ export const useOnboardingFlow = createSharedComposable(() => {},{id: 3,- question: 'How many people are in your team?',+ question: 'How many people work at your company?',inputType: 'singleSelect',- options: ['Only me', '2-5', '6-10', '11-15', '16-25', '26-50', '51-100', '101+'].map((value) => ({ value })),+ options: ['0-10', '11-50', '51-250', '251-1000', '1000+'].reverse().map((value) => ({ value })),rightSection: {themeColor: 'orange',moscot: 'moscotCollaboration',@@ -179,15 +188,16 @@ export const useOnboardingFlow = createSharedComposable(() => {},{id: 4,- question: 'How many people work at your company?',+ question: 'How many people are in your team?',inputType: 'singleSelect',- options: ['1-19', '20-49', '50-99', '100-250', '251-500', '500-1500', '1500+'].map((value) => ({ value })),+ options: ['20+', '11-20', '1-10', 'Only me'].map((value) => ({ value })),rightSection: {themeColor: 'orange',moscot: 'moscotCollaboration',imageName: 'gallery',},},+{id: 5,question: 'How experienced are you with app building?',@@ -282,6 +292,8 @@ export const useOnboardingFlow = createSharedComposable(() => {fullWidth: true,},},+ /*+ // Commenting for now{id: 7,question: 'How do you want to build your database?',@@ -323,6 +335,7 @@ export const useOnboardingFlow = createSharedComposable(() => {height: 32,},},+ */]})@@ -335,19 +348,20 @@ export const useOnboardingFlow = createSharedComposable(() => {})const steps = computed(() => {- return ncArrayFrom(Math.ceil(questions.value.length / 2)).map((_, index) => index + 1)+ return questions.value.map((q) => q.id)})const stepper = useStepper(steps)const lastVisibleQuestionIndex = computed(() => {- const index = (stepper.index.value + 1) * 2 - 1+ // const index = (stepper.index.value + 1) * 2 - 1+ const index = stepper.index.valueconst question = questions.value[index]!- if (!question || ncIsUndefined(formState.value[question.id])) {- return index - 1- }+ // if (!question || ncIsUndefined(formState.value[question.id])) {+ // return index - 1+ // }return index})@@ -371,6 +385,10 @@ export const useOnboardingFlow = createSharedComposable(() => {return currentVisibleQuestions})+ const visibleQuestion = computed(() => {+ return questions.value[stepper.index.value]!+ })+const isFilledQuestionAnswer = (question: OnboardingQuestionType) => {return (!ncIsUndefined(formState.value[question.id]) &&@@ -381,11 +399,7 @@ export const useOnboardingFlow = createSharedComposable(() => {}const isFilledVisibleOptions = computed(() => {- if (stepper.isLast.value) return true-- return visibleQuestions.value.every((question) => {- return isFilledQuestionAnswer(question)- })+ return isFilledQuestionAnswer(visibleQuestion.value)})const onInitOnboardingFlow = async () => {@@ -423,45 +437,40 @@ export const useOnboardingFlow = createSharedComposable(() => {}}- const nextQuestionIndex = questions.value.findIndex((q) => q.id === question.id) + 1+ const nextQuestionIndex = currentStepQuestionIndex + 1const nextQuestion = questions.value[nextQuestionIndex]if (!nextQuestion) {- if (stepper.isLast.value) {- onCompleteOnboardingFlow(false, () => {- if (option.value === 'Start from Scratch') {- showOnboardingFlowLocalState.value = false- }- })- }-return}- if (currentStepQuestionIndex % 2 !== 0) {- /**- * Don't auto navigate to next question if:- * 1. It is the last question- * 2. User has not selected any option- * 3. Next question is already filled (maybe they have click back button)- */- if (stepper.isLast.value || !autoNavigateToNextQuestion || !nextQuestion || isFilledQuestionAnswer(nextQuestion)) return-- if (question.inputType === 'singleSelect') {- ncDelay(500).then(() => {- stepper.goToNext()- })- } else if (question.inputType === 'multiSelect') {+ /**+ * Don't auto navigate to next question if:+ * 1. It is the last question+ * 2. User has not selected any option+ * 3. Next question is already filled (maybe they have click back button)+ */+ if (stepper.isLast.value || !autoNavigateToNextQuestion || !nextQuestion || isFilledQuestionAnswer(nextQuestion)) return++ if (ncIsUndefined(formState.value[nextQuestion.id]) || question.id === 1) {+ formState.value[nextQuestion.id] = nextQuestion.inputType === 'singleSelect' ? '' : []+ }++ if (question.inputType === 'singleSelect') {+ ncDelay(500).then(() => {+ stepper.goToNext()+ })+ }+ /*+ else if (question.inputType === 'multiSelect') {if ((formState.value[question.id]?.length ?? 0) >= (question.minSelection ?? 1)) {ncDelay(500).then(() => {stepper.goToNext()})}}- } else if (ncIsUndefined(formState.value[nextQuestion.id]) || question.id === 1) {- formState.value[nextQuestion.id] = nextQuestion.inputType === 'singleSelect' ? '' : []- }+ */}/**@@ -497,14 +506,10 @@ export const useOnboardingFlow = createSharedComposable(() => {$e('a:auth:onboarding-flow', data)}- const onCompleteOnboardingFlow = async (skipped: boolean = false, callback?: () => void) => {+ const onCompleteOnboardingFlow = async (skipped: boolean = false) => {postCompleteOnboardingFlow(skipped)- if (skipped) {- showOnboardingFlowLocalState.value = false- }-- callback?.()+ showOnboardingFlowLocalState.value = false}return {@@ -518,6 +523,7 @@ export const useOnboardingFlow = createSharedComposable(() => {onCompleteOnboardingFlow,lastVisibleQuestionIndex,visibleQuestions,+ visibleQuestion,isFilledVisibleOptions,onSelectOption,isFilledQuestionAnswer,