- updated page of evaluation editing for instructor;
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { head, isNil, pathOr } from 'ramda';
|
import { head, is, isNil, pathOr } from 'ramda';
|
||||||
import getNumberFormatted from '../../../../../../../helpers/getNumberFormatted';
|
import getNumberFormatted from '../../../../../../../helpers/getNumberFormatted';
|
||||||
|
|
||||||
const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) => {
|
const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) => {
|
||||||
@@ -9,7 +9,7 @@ const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) =
|
|||||||
cellValue = pathOr(0, ['total'], tableValue);
|
cellValue = pathOr(0, ['total'], tableValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <td>{getNumberFormatted(cellValue)}</td>;
|
return <td>{is(Number, cellValue) ? getNumberFormatted(cellValue) : cellValue}</td>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LastRowCell;
|
export default LastRowCell;
|
||||||
@@ -121,7 +121,7 @@ const DomandaEditPreInstructor = () => {
|
|||||||
navigate('/domande');
|
navigate('/domande');
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateFlagsForSoccorso = (data) => {
|
const updateFlagsForSoccorso = useCallback((data) => {
|
||||||
let nonRatedFilesLength = 0;
|
let nonRatedFilesLength = 0;
|
||||||
|
|
||||||
if (data.files) {
|
if (data.files) {
|
||||||
@@ -140,14 +140,28 @@ const DomandaEditPreInstructor = () => {
|
|||||||
|
|
||||||
setAllFilesRated(nonRatedFilesLength === 0);
|
setAllFilesRated(nonRatedFilesLength === 0);
|
||||||
|
|
||||||
if (data.checklist) {
|
if (data.evaluationVersion === 'V1') {
|
||||||
const checkedChecklistItems = data.checklist
|
if (data.checklist) {
|
||||||
.map(el => el.valid)
|
const checkedChecklistItems = data.checklist
|
||||||
.filter(v => v);
|
.map(el => el.valid)
|
||||||
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
.filter(v => v);
|
||||||
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
||||||
|
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
||||||
|
}
|
||||||
|
} else if (data.evaluationVersion === 'V2') {
|
||||||
|
const minChecks = data.numberOfCheck;
|
||||||
|
const formFieldsChecklist = formData
|
||||||
|
.filter(o => head(o.settings.filter(s => s.name === 'isChecklistItem' && s.value)))
|
||||||
|
.map(o => o.id);
|
||||||
|
|
||||||
|
if (formFieldsChecklist.length >= minChecks) {
|
||||||
|
const valuesTotal = formFieldsChecklist.map(v => formValues[v]);
|
||||||
|
const valuesFirst = valuesTotal.toSpliced(minChecks);
|
||||||
|
setAtLeastOneChecked(valuesTotal.filter(v => v === true).length === valuesTotal.length);
|
||||||
|
setAllChecksChecked(valuesFirst.filter(v => v === true).length === valuesFirst.length)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, [formValues]);
|
||||||
|
|
||||||
const doNewSoccorso = () => {
|
const doNewSoccorso = () => {
|
||||||
if (connectedSoccorsoId !== 0) {
|
if (connectedSoccorsoId !== 0) {
|
||||||
@@ -191,25 +205,28 @@ const DomandaEditPreInstructor = () => {
|
|||||||
setData(getFormattedData(resp.data));
|
setData(getFormattedData(resp.data));
|
||||||
setMotivation(resp.data.motivation);
|
setMotivation(resp.data.motivation);
|
||||||
updateFlagsForSoccorso(resp.data);
|
updateFlagsForSoccorso(resp.data);
|
||||||
setFormData(resp.data.applicationEvaluationFormResponse.content);
|
|
||||||
setFormId(resp.data.applicationEvaluationFormResponse.id);
|
|
||||||
let formDataInitial = {};
|
|
||||||
|
|
||||||
if (resp.data.applicationEvaluationFormResponse.formFields) {
|
if (resp.data.evaluationVersion === 'V2') {
|
||||||
const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
|
setFormData(resp.data.applicationEvaluationFormResponse.content);
|
||||||
fieldId: o.fieldId,
|
setFormId(resp.data.applicationEvaluationFormResponse.id);
|
||||||
fieldValue: o.fieldValue
|
let formDataInitial = {};
|
||||||
}));
|
|
||||||
formDataInitial = submitData.reduce((acc, cur) => {
|
if (resp.data.applicationEvaluationFormResponse.formFields) {
|
||||||
if (cur.fieldValue) {
|
const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
|
||||||
acc[cur.fieldId] = cur.fieldValue;
|
fieldId: o.fieldId,
|
||||||
}
|
fieldValue: o.fieldValue
|
||||||
return acc;
|
}));
|
||||||
}, formDataInitial);
|
formDataInitial = submitData.reduce((acc, cur) => {
|
||||||
|
if (cur.fieldValue) {
|
||||||
|
acc[cur.fieldId] = cur.fieldValue;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, formDataInitial);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
setFormInitialData(formDataInitial);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset();
|
|
||||||
setFormInitialData(formDataInitial);
|
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
@@ -848,6 +865,8 @@ const DomandaEditPreInstructor = () => {
|
|||||||
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
||||||
reset(updatedFormValues);
|
reset(updatedFormValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFlagsForSoccorso(data);
|
||||||
}, [formValues]);
|
}, [formValues]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user