Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
176 lines
4.5 KiB
JavaScript
176 lines
4.5 KiB
JavaScript
export default function wizardSchemaComponent({
|
|
isSkippable,
|
|
isStepPersistedInQueryString,
|
|
key,
|
|
livewireId,
|
|
schemaKey,
|
|
startStep,
|
|
stepQueryStringKey,
|
|
}) {
|
|
return {
|
|
boundResetHandler: null,
|
|
step: null,
|
|
|
|
init() {
|
|
this.step = this.getSteps().at(startStep - 1)
|
|
|
|
this.$watch('step', () => {
|
|
this.updateQueryString()
|
|
this.autofocusFields()
|
|
})
|
|
|
|
this.autofocusFields(true)
|
|
|
|
this.boundResetHandler = (event) => {
|
|
if (
|
|
event.detail.livewireId !== livewireId ||
|
|
event.detail.schemaKey !== schemaKey ||
|
|
isStepPersistedInQueryString
|
|
) {
|
|
return
|
|
}
|
|
|
|
this.$nextTick(() => {
|
|
this.step = this.getSteps().at(startStep - 1) ?? this.step
|
|
})
|
|
}
|
|
|
|
window.addEventListener(
|
|
'reset-schema-component-state',
|
|
this.boundResetHandler,
|
|
)
|
|
},
|
|
|
|
async requestNextStep() {
|
|
await this.$wire.callSchemaComponentMethod(key, 'nextStep', {
|
|
currentStepIndex: this.getStepIndex(this.step),
|
|
})
|
|
},
|
|
|
|
goToNextStep() {
|
|
let nextStepIndex = this.getStepIndex(this.step) + 1
|
|
|
|
if (nextStepIndex >= this.getSteps().length) {
|
|
return
|
|
}
|
|
|
|
this.step = this.getSteps()[nextStepIndex]
|
|
|
|
this.scroll()
|
|
},
|
|
|
|
goToPreviousStep() {
|
|
let previousStepIndex = this.getStepIndex(this.step) - 1
|
|
|
|
if (previousStepIndex < 0) {
|
|
return
|
|
}
|
|
|
|
this.step = this.getSteps()[previousStepIndex]
|
|
|
|
this.scroll()
|
|
},
|
|
|
|
goToStep(stepKey) {
|
|
const stepIndex = this.getStepIndex(stepKey)
|
|
|
|
if (stepIndex <= -1) {
|
|
return
|
|
}
|
|
|
|
if (!isSkippable && stepIndex > this.getStepIndex(this.step)) {
|
|
return
|
|
}
|
|
|
|
this.step = stepKey
|
|
|
|
this.scroll()
|
|
},
|
|
|
|
scroll() {
|
|
this.$nextTick(() => {
|
|
this.$refs.header?.children[
|
|
this.getStepIndex(this.step)
|
|
].scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
})
|
|
},
|
|
|
|
autofocusFields(respectCurrentFocus = false) {
|
|
this.$nextTick(() => {
|
|
if (
|
|
respectCurrentFocus &&
|
|
document.activeElement &&
|
|
document.activeElement !== document.body &&
|
|
this.$el.compareDocumentPosition(document.activeElement) &
|
|
Node.DOCUMENT_POSITION_PRECEDING
|
|
) {
|
|
return
|
|
}
|
|
|
|
const fields =
|
|
this.$refs[`step-${this.step}`]?.querySelectorAll(
|
|
'[autofocus]',
|
|
) ?? []
|
|
|
|
for (const field of fields) {
|
|
field.focus()
|
|
|
|
if (document.activeElement === field) {
|
|
break
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
getStepIndex(step) {
|
|
let index = this.getSteps().findIndex(
|
|
(indexedStep) => indexedStep === step,
|
|
)
|
|
|
|
if (index === -1) {
|
|
return 0
|
|
}
|
|
|
|
return index
|
|
},
|
|
|
|
getSteps() {
|
|
return JSON.parse(this.$refs.stepsData.value)
|
|
},
|
|
|
|
isFirstStep() {
|
|
return this.getStepIndex(this.step) <= 0
|
|
},
|
|
|
|
isLastStep() {
|
|
return this.getStepIndex(this.step) + 1 >= this.getSteps().length
|
|
},
|
|
|
|
isStepAccessible(stepKey) {
|
|
return (
|
|
isSkippable ||
|
|
this.getStepIndex(this.step) > this.getStepIndex(stepKey)
|
|
)
|
|
},
|
|
|
|
updateQueryString() {
|
|
if (!isStepPersistedInQueryString) {
|
|
return
|
|
}
|
|
|
|
const url = new URL(window.location.href)
|
|
url.searchParams.set(stepQueryStringKey, this.step)
|
|
|
|
history.replaceState(null, document.title, url.toString())
|
|
},
|
|
|
|
destroy() {
|
|
if (this.boundResetHandler) {
|
|
window.removeEventListener(
|
|
'reset-schema-component-state',
|
|
this.boundResetHandler,
|
|
)
|
|
}
|
|
},
|
|
}
|
|
}
|