- added fileselect form field;
- added Documents page;
This commit is contained in:
@@ -7,6 +7,7 @@ import { isEmpty, pluck } from 'ramda';
|
||||
import { ListBox } from 'primereact/listbox';
|
||||
import { Button } from 'primereact/button';
|
||||
import CompanyDocumentsService from '../../../../service/company-documents-service';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
const FileSelect = ({
|
||||
fieldName,
|
||||
@@ -35,6 +36,7 @@ const FileSelect = ({
|
||||
setSelectedUnconfirmed([]);
|
||||
|
||||
setLoading(true);
|
||||
// eslint-disable-next-line array-callback-return
|
||||
selectedToBeAdded.map(o => {
|
||||
CompanyDocumentsService.attachCompanyDocumentToAppl(o.id, callback, errCallback, [
|
||||
['applicationId', sourceId],
|
||||
@@ -43,6 +45,10 @@ const FileSelect = ({
|
||||
});
|
||||
}, [selectedUnconfirmed]);
|
||||
|
||||
const removeAttached = (id) => {
|
||||
console.log('stateFieldData', stateFieldData, id)
|
||||
}
|
||||
|
||||
const callback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
stateFieldData.current = [...stateFieldData.current, resp.data];
|
||||
@@ -84,7 +90,6 @@ const FileSelect = ({
|
||||
}, [options]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('defaultValue', defaultValue);
|
||||
stateFieldData.current = defaultValue;
|
||||
}, [defaultValue]);
|
||||
|
||||
@@ -96,31 +101,51 @@ const FileSelect = ({
|
||||
</label>
|
||||
<div className="fileselectInner">
|
||||
<div className="fileselectInner__selectionBox">
|
||||
<ListBox multiple
|
||||
value={selectedUnconfirmed}
|
||||
onChange={(e) => setSelectedUnconfirmed(e.value)}
|
||||
options={optionsTransformed}
|
||||
optionLabel="name"
|
||||
optionGroupLabel="label"
|
||||
optionGroupChildren="items"
|
||||
className="w-full md:w-14rem"
|
||||
listStyle={{ maxHeight: '130px' }}/>
|
||||
<Button
|
||||
severity="success"
|
||||
disabled={loading}
|
||||
onClick={attachSelectedFiles}
|
||||
label={__('Conferma i file scelti', 'gepafin')}
|
||||
icon="pi pi-arrow-right" size="small" iconPos="right"/>
|
||||
</div>
|
||||
<div className="fileselectInner__selectedFiles">
|
||||
<p>{__('Selezionati')}</p>
|
||||
<ul>
|
||||
{[...stateFieldData.current].map(o => <li key={o.id}>
|
||||
{o.name}
|
||||
</li>)}
|
||||
</ul>
|
||||
<ListBox multiple
|
||||
value={selectedUnconfirmed}
|
||||
onChange={(e) => setSelectedUnconfirmed(e.value)}
|
||||
options={optionsTransformed}
|
||||
optionLabel="name"
|
||||
optionGroupLabel="label"
|
||||
optionGroupChildren="items"
|
||||
className="w-full md:w-14rem"
|
||||
listStyle={{ maxHeight: '130px' }}/>
|
||||
{!isEmpty(optionsTransformed)
|
||||
? <Button
|
||||
severity="success"
|
||||
disabled={loading}
|
||||
onClick={attachSelectedFiles}
|
||||
label={__('Conferma i file scelti', 'gepafin')}
|
||||
icon="pi pi-arrow-right" size="small" iconPos="right"/> : null}
|
||||
</div>
|
||||
{!isEmpty(optionsTransformed)
|
||||
? <div className="fileselectInner__selectedFiles">
|
||||
<p>{__('I file selezionati')}</p>
|
||||
<ul>
|
||||
{[...stateFieldData.current].map(o => <li key={o.id}>
|
||||
{o.name}
|
||||
<div className="appPageSection__iconActions">
|
||||
<Button icon="pi pi-times" rounded
|
||||
type="button"
|
||||
size="small"
|
||||
onClick={() => removeAttached(o.id)}
|
||||
outlined severity="danger"
|
||||
aria-label={__('Cancella', 'gepafin')}/>
|
||||
</div>
|
||||
</li>)}
|
||||
</ul>
|
||||
</div> : null}
|
||||
</div>
|
||||
{isEmpty(optionsTransformed)
|
||||
? <div className="appPageSection__message warning">
|
||||
<span>
|
||||
{__('I file caricati sulla pagina Documenti saranno disponibili qui. ', 'gepafin')}
|
||||
<Link to={`/documenti`}>
|
||||
{__('Vai alla pagina Documenti', 'gepafin')}
|
||||
</Link>
|
||||
</span>
|
||||
</div>
|
||||
: null}
|
||||
{infoText ? <small>{infoText}</small> : null}
|
||||
</>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user