Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 378 | Rev 380 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 378 Rev 379
Línea 22... Línea 22...
22
            //init form data
22
            //init form data
23
            const formData = new FormData();
23
            const formData = new FormData();
24
            formData.append("content", JSON.stringify(test));
24
            formData.append("content", JSON.stringify(test));
25
            await axios.post(action, formData).then((response) => {
25
            await axios.post(action, formData).then((response) => {
26
                if (response.data.success) {
26
                if (response.data.success) {
27
                    console.info('Formulario almacenado');
-
 
28
                    setTest(null);
27
                    setTest(null);
29
                }
28
                }
30
            });
29
            });
31
        }
30
        }
32
    }
31
    }
Línea 43... Línea 42...
43
                    if (question.slug_question == slug_question) {
42
                    if (question.slug_question == slug_question) {
44
                        //valid if the question has more than one answer
43
                        //valid if the question has more than one answer
45
                        question.type == 'multiple' ?
44
                        question.type == 'multiple' ?
46
                            !question.answer ?
45
                            !question.answer ?
47
                                question.answer = [answer] :
46
                                question.answer = [answer] :
-
 
47
                                question.answer.includes(answer) ?
-
 
48
                                    question.answer = removeOptionMultiple(question.answer, answer) :
48
                                question.answer.push(answer)
49
                                    question.answer.push(answer)
49
                            : question.answer = answer;
50
                            : question.answer = answer;
Línea 50... Línea 51...
50
 
51
 
51
                    }
52
                    }
52
                })
53
                })
53
            }
54
            }
54
        });
55
        });
55
        validateForm();
56
        validateForm();
56
        setTest(test);
57
        setTest(test);
Línea 57... Línea 58...
57
    }
58
    }
58
 
59
 
59
    function removeItemFromArr ( arr, item ) {
-
 
60
        var i = arr.indexOf( item );
-
 
61
     
60
    const removeOptionMultiple = (arr, item) => {
62
        if ( i !== -1 ) {
-
 
63
            arr.splice( i, 1 );
61
        var i = arr.indexOf(item);
64
        }
62
        return arr.splice(i, 1);
65
    }
63
    }
66
    /**
64
    /**
67
     * Check if there are questions to answer
65
     * Check if there are questions to answer
Línea 149... Línea 147...
149
 
147
 
150
 
148
 
151
                            <button
149
                            <button
152
                                type="buttton"
150
                                type="buttton"
153
                                className="btn btn-primary"
151
                                className="btn btn-primary"
154
                                disabled ={!valid}
152
                                disabled={!valid}
155
                                onClick={() => handleSubmit()}>
153
                                onClick={() => handleSubmit()}>
156
                                {backendVars.LBL_SAVE}
154
                                {backendVars.LBL_SAVE}
157
                            </button>
155
                            </button>