- saving progress;
This commit is contained in:
@@ -11,31 +11,31 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
||||
{files.map((o, i) => <li key={o.id} className="appPageSection__listItem">
|
||||
<div className="appPageSection__listItemRow">
|
||||
<span>{o.label}</span>
|
||||
<div className="appPageSection__iconActions">
|
||||
{o.fileDetail && o.fileDetail.length === 1
|
||||
? <Button icon="pi pi-eye" rounded
|
||||
onClick={() => {
|
||||
window.open(o.fileDetail[0].filePath, '_blank').focus()
|
||||
}}
|
||||
outlined severity="info"
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableFieldFn(name)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateFn(
|
||||
true,
|
||||
[name, i, 'valid']
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableFieldFn(name)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateFn(
|
||||
false,
|
||||
[name, i, 'valid']
|
||||
)}
|
||||
aria-label={__('Giu', 'gepafin')}/>
|
||||
</div>
|
||||
{o.fileDetail && o.fileDetail.length === 1
|
||||
? <div className="appPageSection__iconActions">
|
||||
<Button icon="pi pi-eye" rounded
|
||||
onClick={() => {
|
||||
window.open(o.fileDetail[0].filePath, '_blank').focus()
|
||||
}}
|
||||
outlined severity="info"
|
||||
aria-label={__('Mostra', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableFieldFn(name)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateFn(
|
||||
true,
|
||||
[name, i, 'valid']
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableFieldFn(name)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateFn(
|
||||
false,
|
||||
[name, i, 'valid']
|
||||
)}
|
||||
aria-label={__('Giu', 'gepafin')}/>
|
||||
</div> : null}
|
||||
</div>
|
||||
{o.fileDetail && o.fileDetail.length > 1
|
||||
? <ul style={{
|
||||
@@ -53,7 +53,8 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
||||
}}>
|
||||
<span>{k.name}</span>
|
||||
<div className="appPageSection__iconActions">
|
||||
<ArchiveDocument ndg={ndg} applicationId={applicationId} fileId={k.id} docAttachmentId={k.documentAttachmentId}/>
|
||||
<ArchiveDocument ndg={ndg} applicationId={applicationId} fileId={k.id}
|
||||
docAttachmentId={k.documentAttachmentId}/>
|
||||
<Button icon="pi pi-eye" rounded
|
||||
onClick={() => {
|
||||
window.open(k.filePath, '_blank').focus()
|
||||
|
||||
@@ -13,9 +13,12 @@ import { Button } from 'primereact/button';
|
||||
const RepeaterFields = ({
|
||||
sourceId,
|
||||
sourceName,
|
||||
updateFn = () => {},
|
||||
defaultValue = []
|
||||
}) => {
|
||||
updateFn = () => {
|
||||
},
|
||||
defaultValue = [],
|
||||
updateCallbackFn = () => {
|
||||
}
|
||||
}) => {
|
||||
const [items, setItems] = useState([]);
|
||||
const [chosen, setChosen] = useState('');
|
||||
const [formInitialData, setFormInitialData] = useState({});
|
||||
@@ -27,7 +30,8 @@ const RepeaterFields = ({
|
||||
register,
|
||||
trigger,
|
||||
reset,
|
||||
watch
|
||||
watch,
|
||||
getValues
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return formInitialData;
|
||||
@@ -51,8 +55,7 @@ const RepeaterFields = ({
|
||||
const newItem = {
|
||||
fieldId: uid,
|
||||
nameValue: '',
|
||||
fileValue: [],
|
||||
valid: true
|
||||
fileValue: []
|
||||
}
|
||||
setItems([...items, newItem]);
|
||||
setChosen(uid);
|
||||
@@ -93,7 +96,7 @@ const RepeaterFields = ({
|
||||
...o,
|
||||
fileValue: watchFile
|
||||
} : o;
|
||||
})
|
||||
});
|
||||
setItems([...updatedItems]);
|
||||
}, [watchFile]);
|
||||
|
||||
@@ -105,7 +108,6 @@ const RepeaterFields = ({
|
||||
setItems(defaultValue);
|
||||
}, [])
|
||||
|
||||
console.log('items', items, chosen);
|
||||
return (
|
||||
<div className="fieldsRepeater">
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
@@ -157,7 +159,7 @@ const RepeaterFields = ({
|
||||
className="fieldsRepeater__addNew"
|
||||
outlined
|
||||
type="button"
|
||||
/*disabled={!isEmpty(chosen.fileId) && (isEmpty(chosen.name) || isEmpty(chosen.file))}*/
|
||||
disabled={!isEmpty(chosen.fileId) && (isEmpty(watchName) || isEmpty(watchFile))}
|
||||
onClick={addNew}
|
||||
label={__('Aggiungi nuovo file', 'gepafin')}
|
||||
/>
|
||||
|
||||
@@ -88,7 +88,7 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
const doNewSoccorso = () => {
|
||||
if (connectedSoccorsoId !== 0) {
|
||||
doSaveDraft(`/domande/${id}/soccorso/${connectedSoccorsoId}`)
|
||||
navigate(`/domande/${id}/soccorso/${connectedSoccorsoId}`);
|
||||
} else {
|
||||
doSaveDraft(`/domande/${id}/aggiungi-soccorso/`)
|
||||
}
|
||||
@@ -605,16 +605,34 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/*<div className="appPageSection">
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti di soccorso', 'gepafin')}</h2>
|
||||
<ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={shouldDisableField}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
</div>*/}
|
||||
{data.amendmentDetails
|
||||
.filter(o => o.amendmentDocuments && !isEmpty(o.amendmentDocuments)
|
||||
|| o.formFieldDocuments && !isEmpty(o.formFieldDocuments))
|
||||
.map(o => {
|
||||
const aDocs = pathOr([],['amendmentDocuments'], o)
|
||||
.map(o => ({
|
||||
id: o.fieldId,
|
||||
label: o.nameValue,
|
||||
fileDetail: o.fileValue,
|
||||
valid: o.valid
|
||||
}));
|
||||
const fDocs = pathOr([],['formFieldDocuments'], o);
|
||||
|
||||
return {
|
||||
id: o.id,
|
||||
files: [...aDocs, ...fDocs]
|
||||
}
|
||||
})
|
||||
.map(o => <ListOfFiles
|
||||
files={o.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={shouldDisableField}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>)}
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
||||
|
||||
Reference in New Issue
Block a user