Skip to content

Commit

Permalink
Handle validation set true on remark
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSetyadi committed Apr 10, 2022
1 parent 3687e5d commit 252c451
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const FormInput: FormComponentBase = props => {
}
let refPosition = reference.details.findIndex(obj => obj.dataKey === flagRemark());
setReference('details',refPosition,'hasRemark',true);
setReference('details',refPosition,'validationState',0);
setReference('details',refPosition,'validationMessage',[]);
setNote('details','notes', updatedNote);
// console.log('remark', remark)

Expand Down
20 changes: 11 additions & 9 deletions src/GlobalFunction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -668,15 +668,17 @@ export const runValidation = (dataKey:string, updatedRef:any, activeComponentPos

updatedRef.validationMessage = [];
updatedRef.validationState = 0;
let biggest = 0;
for(let i in updatedRef.validations){
let result = eval(updatedRef.validations[i].test);
if(result){
updatedRef.validationMessage.push(updatedRef.validations[i].message);
biggest = (biggest < updatedRef.validations[i].type) ? updatedRef.validations[i].type : biggest;
if(!updatedRef.hasRemark){
let biggest = 0;
for(let i in updatedRef.validations){
let result = eval(updatedRef.validations[i].test);
if(result){
updatedRef.validationMessage.push(updatedRef.validations[i].message);
biggest = (biggest < updatedRef.validations[i].type) ? updatedRef.validations[i].type : biggest;
}
}
updatedRef.validationState = biggest;
}
updatedRef.validationState = biggest;

saveAnswer(dataKey, 'validate', updatedRef, activeComponentPosition, null);
}
Expand Down Expand Up @@ -840,7 +842,7 @@ export const saveAnswer = (dataKey: string, attributeParam: any, answer: any, ac

if(hasComponentUsing.length > 0) {//berarti dataKey ini digunakan sebagai sumber Nested minimal di 1 component
// console.log('dataKey', dataKey, answer);
console.time('buat roster');
console.time('Nested creation time ');
hasComponentUsing.forEach(element => {

if(typeof answer === 'number' || typeof answer === 'string'){
Expand Down Expand Up @@ -893,7 +895,7 @@ export const saveAnswer = (dataKey: string, attributeParam: any, answer: any, ac
}
}
});
console.timeEnd('buat roster');
console.timeEnd('Nested creation time ');
}
}
} else if(attributeParam === 'validate'){
Expand Down

0 comments on commit 252c451

Please sign in to comment.