1834423612 / Pit-scouting

Pit-Scouting for FRC Team 695

Home Page:https://pit-scouting-two.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Front End Form verify values

1834423612 opened this issue · comments

commented

Fix: Form verify those values(Required or not) => Submit

【Vue-dev】(Front-End)

watch: {
robotWeight(newValue,oldValue){
if (!newValue.test('^\d+(\s\d+\/\d+)?(\.\d+)?$|^\d+\/\d+$')){
//change back to old value
//make seperate validation
//prevent storage from storing the newValue
}
},
robotDimensionLength(newValue,oldValue){},
robotDimensionWidth(newValue,oldValue){},
robotDimensionHeight(newValue,oldValue){},
heightWhenFullyExtended(newValue,oldValue){},
practiceHoursPerWeek(newValue,oldValue){},
form: {
handler(newForm) {
this.formModified = true; // Form has been modified
if (this.saveTimeout) {
clearTimeout(this.saveTimeout);
}
this.saveTimeout = setTimeout(() => {
this.savingStatus = 'saving';
let arr = window.localStorage.getItem('TabsArray')
let TabsArray = JSON.parse(arr)
TabsArray.map(item => {
if (item.name == this.tabIndex) {
item.formValue = newForm
}
})
window.localStorage.setItem('TabsArray', JSON.stringify(TabsArray))
//Object.keys(this.valid).forEach((item,index)=>{
// this.valid.item.entered=
//})
//
//newForm.forEach((question) => {
// if (question.type === "checkbox") {
// localStorage.setItem(
// question.question,
// JSON.stringify(question.value)
// );
// } else { localStorage.setItem(question.question, question.value); }
// localStorage.setItem(
// question.question + "-otherValue",
// question.otherValue
// );
// });
setTimeout(() => {
this.savingStatus = 'success';
this.formModified = false; // Reset the form status
}, 1400); // Set the saving status TEXT to success after 1.4 seconds
}, 300); // Save the form data after 0.3 seconds
},
deep: true,
},

commented

Now solution:
Create a newValue and compare new&old