add ausbildung

This commit is contained in:
Philipp Lang 2023-05-07 17:54:59 +02:00
parent 06072bb01d
commit 934bcc4f82
1 changed files with 128 additions and 74 deletions

View File

@ -1,4 +1,4 @@
import scrollToElement from './scrollToElement.js'; import scrollToElement from "./scrollToElement.js";
var toastedOptions = { var toastedOptions = {
position: "bottom-right", position: "bottom-right",
@ -12,10 +12,58 @@ export default function (toasted) {
var toasted = new toasted(toastedOptions); var toasted = new toasted(toastedOptions);
return { return {
data: {
event_id: null,
gender: "",
firstname: "",
lastname: "",
birthday: "",
group: null,
phone: "",
email: "",
agegroup_leader: null,
food_preferences: [],
foto: false,
misc: "",
},
loading: false,
finished: false, finished: false,
submitRequest: null, submitRequest: null,
errorFields: [], errorFields: [],
active: 0, active: 0,
slides: ["Persönliches", "Veranstaltung", "Sonstiges"],
genders: [
{ id: "Männlich", name: "Männlich" },
{ id: "Weiblich", name: "Weiblich" },
{ id: "Divers", name: "Divers" },
],
groups: [
{ id: "Gallier", name: "Gallier (Wuppertal)" },
{ id: "Gandalf", name: "Gandalf (SG-Mangenberg)" },
{ id: "Gravenrode", name: "Gravenrode (SG-Gräfrath)" },
{ id: "Lennep", name: "Lennep (RS-Lennep)" },
{ id: "Silva", name: "Silva (SG-Wald)" },
{ id: "Sugambrer", name: "Sugambrer (SG-Höhscheid)" },
{ id: "Tenkterer", name: "Tenkterer (SG-Löhdorf)" },
{ id: "von Berg", name: "von Berg (SG-Ohligs)" },
],
agegroupLeaders: [
{ id: "Biber", name: "Biber" },
{ id: "Wölfling", name: "Wölfling" },
{ id: "Jungpfadfinder", name: "Jungpfadfinder" },
{ id: "Pfadfinder", name: "Pfadfinder" },
{ id: "Rover", name: "Rover" },
],
boolean: [
{ id: "Ja", name: "Ja" },
{ id: "Nein", name: "Nein" },
],
foodPreferences: [
{ id: "Fleisch", name: "Ich esse Fleisch" },
{ id: "Vegan", name: "Ich ernähre mich vegan" },
{ id: "Glutenfrei", name: "Ich vertrage kein Gluten" },
{ id: "Laktosefrei", name: "Ich vertrage keine Laktose" },
],
slideTo(e, index) { slideTo(e, index) {
if (e !== null) { if (e !== null) {
e.preventDefault(); e.preventDefault();
@ -25,33 +73,37 @@ export default function (toasted) {
} }
this.scrollForm(this.$refs.form); this.scrollForm(this.$refs.form);
this.active = index; this.active = index;
this.$refs.slider.scrollLeft = this.$refs.slider.scrollWidth / this.slides.length * index; this.$refs.slider.scrollLeft =
this.$refs.mobileSlider.scrollLeft = this.$refs.mobileSlider.scrollWidth / this.slides.length * index; (this.$refs.slider.scrollWidth / this.slides.length) * index;
this.$refs.mobileSlider.scrollLeft =
(this.$refs.mobileSlider.scrollWidth / this.slides.length) * index;
}, },
scrollForm(el) { scrollForm(el) {
var margin = window.getComputedStyle(el).marginTop.replace('px', ''); var margin = window.getComputedStyle(el).marginTop.replace("px", "");
scrollToElement(el, 300, (margin ? margin : 0) * -1); scrollToElement(el, 300, (margin ? margin : 0) * -1);
}, },
submit() { submit() {
var _self = this; var _self = this;
_self.loading = true;
var promise = fetch(window.location.href, { var promise = fetch(window.location.href, {
method: 'POST', method: "POST",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
'X-WINTER-REQUEST-HANDLER': this.submitRequest, "X-WINTER-REQUEST-HANDLER": this.submitRequest,
'X-WINTER-REQUEST-PARTIALS': [], "X-WINTER-REQUEST-PARTIALS": [],
'X-Requested-With': 'XMLHttpRequest', "X-Requested-With": "XMLHttpRequest",
}, },
body: JSON.stringify(this.data), body: JSON.stringify(this.data),
}); });
promise.then(function (response) { promise.then(function (response) {
_self.loading = false;
if (response.status === 422) { if (response.status === 422) {
response.json().then((errors) => { response.json().then((errors) => {
_self.scrollToFirstError(errors); _self.scrollToFirstError(errors);
Object.keys(errors).forEach((field) => { Object.keys(errors).forEach((field) => {
toasted.error(errors[field].join('<br>')); toasted.error(errors[field].join("<br>"));
}); });
}); });
} }
@ -73,19 +125,21 @@ export default function (toasted) {
return; return;
} }
var slideElement = field.closest('.slider-element'); var slideElement = field.closest(".slider-element");
this.slideTo(null, Array.from(slideElement.parentNode.children).indexOf(slideElement)); this.slideTo(
null,
Array.from(slideElement.parentNode.children).indexOf(slideElement)
);
}, },
prevButton: { prevButton: {
[':class']() { [":class"]() {
return this.active == 0 ? 'opacity-40' : ''; return this.active == 0 ? "opacity-40" : "";
} },
}, },
nextButton: { nextButton: {
[':class']() { [":class"]() {
return this.active == this.core.slides.length - 1 ? 'opacity-40' : ''; return this.active == this.slides.length - 1 ? "opacity-40" : "";
} },
}, },
}; };
} }