fix sections
Main daploy / deploy (push) Successful in 45s

This commit is contained in:
2024-11-20 09:48:18 +02:00
parent 99ff4beba3
commit fc66b779ae
2 changed files with 36 additions and 16 deletions
+5 -5
View File
@@ -7,16 +7,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { watch, useTemplateRef } from 'vue' import { watch, useTemplateRef } from 'vue'
const props = defineProps<{ isActive: boolean }>() const props = defineProps<{ isActive: boolean; isNextActiveSection: boolean }>()
const sectionRef = useTemplateRef('section') const sectionRef = useTemplateRef('section')
// плавная прокрутка при активации секции // плавная прокрутка при активации секции
watch( watch(
() => props.isActive, () => props.isNextActiveSection,
(isActive) => { (isNextActiveSection) => {
if (isActive) { if (isNextActiveSection) {
sectionRef.value?.querySelector('input')?.focus() sectionRef.value?.querySelector('input[type="text"]')?.focus()
sectionRef.value?.scrollIntoView({ behavior: 'smooth' }) sectionRef.value?.scrollIntoView({ behavior: 'smooth' })
} }
}, },
+31 -11
View File
@@ -3,30 +3,44 @@
<section class="content"> <section class="content">
<div class="max-w-prose mx-auto py-8"> <div class="max-w-prose mx-auto py-8">
<!-- Секция выбора размещения --> <!-- Секция выбора размещения -->
<CreateSection :isActive="activeSteps.includes('placement')"> <CreateSection
:isActive="activeSteps.includes('placement')"
:isNextActiveSection="nextActiveSection === 'placement'"
>
<CreatePlacementSection v-model="placement" /> <CreatePlacementSection v-model="placement" />
</CreateSection> </CreateSection>
<!-- Секция выбора доступных действий --> <!-- Секция выбора доступных действий -->
<CreateSection :isActive="activeSteps.includes('actions')"> <CreateSection
:isActive="activeSteps.includes('actions')"
:isNextActiveSection="nextActiveSection === 'actions'"
>
<CreateActionsSection v-model="selectedActions" /> <CreateActionsSection v-model="selectedActions" />
</CreateSection> </CreateSection>
<!-- Секция выбора способа доставки --> <!-- Секция выбора способа доставки -->
<CreateSection v-if="activeSteps.includes('delivery')" :isActive="true"> <CreateSection
v-if="activeSteps.includes('delivery')"
:isActive="true"
:isNextActiveSection="nextActiveSection === 'delivery'"
>
<CreateMessageDeliveryMethodSection v-model="messageDeliveryMethod" /> <CreateMessageDeliveryMethodSection v-model="messageDeliveryMethod" />
</CreateSection> </CreateSection>
<!-- Секция сообщений для отправки --> <!-- Секция сообщений для отправки -->
<CreateSection <CreateSection
v-if="activeSteps.includes('messages')" v-if="selectedActions.includes('sendMessage')"
:isActive="messageDeliveryMethod !== 'telegram'" :isActive="activeSteps.includes('messages')"
:isNextActiveSection="nextActiveSection === 'messages'"
> >
<CreatePredefinedMessagesSection :placement="placement" v-model="messages" /> <CreatePredefinedMessagesSection :placement="placement" v-model="messages" />
</CreateSection> </CreateSection>
<!-- Секция итогового резюме --> <!-- Секция итогового резюме -->
<CreateSection :isActive="activeSteps.includes('summary')"> <CreateSection
:isActive="activeSteps.includes('summary')"
:isNextActiveSection="nextActiveSection === 'summary'"
>
<CreateSummarySection <CreateSummarySection
v-model:name="name" v-model:name="name"
buttonLabel="Создать QR‑код" buttonLabel="Создать QR‑код"
@@ -43,7 +57,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue' import { computed, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { createQrCodeDocument } from '@/api/qrCode' import { createQrCodeDocument } from '@/api/qrCode'
import type { QRCodeDocument } from '@/types/DBDocumentTypes' import type { QRCodeDocument } from '@/types/DBDocumentTypes'
@@ -95,18 +109,24 @@ const activeSteps = computed(() => {
summary: summary:
!!placement.value && !!placement.value &&
selectedActions.value.length > 0 && selectedActions.value.length > 0 &&
(messageDeliveryMethod.value === 'webPushSubscription' || (selectedActions.value.includes('sendMessage')
selectedActions.value.includes('viewContactInfo')), ? messageDeliveryMethod.value === 'webPushSubscription'
: !!selectedActions.value.length),
} }
const active = [] const active = []
for (const step of steps) { for (const step of steps) {
if (active.length === 0 || isStepValid[step]) { if (active.length === 0 || isStepValid[step]) {
active.push(step) active.push(step)
} else {
break
} }
} }
return active return active
}) })
const nextActiveSection = ref<string>('placement')
watch(activeSteps, (newActiveSteps, oldActiveSteps) => {
nextActiveSection.value =
(oldActiveSteps && newActiveSteps[oldActiveSteps.length]) ?? newActiveSteps.at(-1)
})
</script> </script>