new Vue({
el: '#app',
data: function () {
return {
firstChildSetting: {},
secondChildSetting: {},
firstChild: 'none',
secondChild: 'none',
currentSetting: {},
client: 'none',
formType: 'none',
errorMessage: '',
lastRequestResult: null,
}
},
methods: {
firstChildOnChange: function () {
this.formSettingRequest(this.firstChild, 1);
},
secondChildOnChange: function () {
this.formSettingRequest(this.secondChild, 2);
},
formTypeOnChange: function () {
this.formSettingRequest(this.formType);
},
formSettingRequest: function (formType, childrenCount = 0) {
fetch('http://site.name/api/v1/getFormConfig?type=' + encodeURIComponent(formType))
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error('Network response was not ok');
}
})
.then((response) => {
if (childrenCount === 2) {
this.firstChildSetting = response.data;
} else if (childrenCount === 1) {
this.secondChildSetting = response.data;
} else {
this.currentSetting = response.data;
}
})
.catch((error) => {
console.log(error);
});
},
clientOnChange: function () {
}
}
});