- added duplicate form from another call functionality;
- fixed styles; - added copy icon for user emails; - added hotkey to open loginadmin page quickly; - added modal for archiving document; - added modal for create appointment;
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty } from 'ramda';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { classNames } from 'primereact/utils';
|
||||
|
||||
const ArchiveDocument = ({ ndg = '', fileId = 0 }) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVisibleDialog, setIsVisibleDialog] = useState(false);
|
||||
const [modalData, setModalData] = useState({});
|
||||
const [categories, setCategories] = useState([]);
|
||||
|
||||
const openArchivationModal = () => {
|
||||
setIsVisibleDialog(true);
|
||||
setModalData({
|
||||
description: '',
|
||||
categoryId: 0,
|
||||
fileId
|
||||
});
|
||||
}
|
||||
|
||||
const headerDialog = () => {
|
||||
return <span>{__('Archive document', 'gepafin')}</span>;
|
||||
}
|
||||
|
||||
const hideDialog = () => {
|
||||
setIsVisibleDialog(false);
|
||||
setModalData({});
|
||||
}
|
||||
|
||||
const setValue = (name, value) => {
|
||||
const newData = wrap(modalData).set(name, value).value();
|
||||
setModalData(newData);
|
||||
}
|
||||
|
||||
const footerDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
label={__('Invia', 'gepafin')} onClick={submitData}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
const submitData = () => {
|
||||
console.log('submitData', modalData)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setCategories([
|
||||
{value: 1, label: 'Type 1'},
|
||||
{value: 2, label: 'Type 2'},
|
||||
])
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isEmpty(ndg)
|
||||
? <Button icon="pi pi-file-export"
|
||||
rounded
|
||||
onClick={openArchivationModal}
|
||||
outlined
|
||||
severity="info"
|
||||
aria-label={__('Mostra', 'gepafin')}/>
|
||||
: null}
|
||||
<Dialog
|
||||
visible={isVisibleDialog}
|
||||
modal
|
||||
header={headerDialog}
|
||||
footer={footerDialog}
|
||||
style={{ maxWidth: '600px', width: '100%' }}
|
||||
onHide={hideDialog}>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': !modalData.categoryId || modalData.categoryId === 0 })}>
|
||||
{__('Classificazione', 'gepafin')}*
|
||||
</label>
|
||||
<Dropdown
|
||||
value={modalData.categoryId}
|
||||
invalid={!modalData.categoryId || modalData.categoryId === 0}
|
||||
onChange={(e) => setValue('categoryId', e.value)}
|
||||
options={categories}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(modalData.description) })}>
|
||||
{__('Descrizione', 'gepafin')}
|
||||
</label>
|
||||
<InputTextarea
|
||||
value={modalData.description}
|
||||
invalid={isEmpty(modalData.description)}
|
||||
onChange={(e) => setValue('description', e.target.value)}
|
||||
rows={3}
|
||||
cols={30}/>
|
||||
</div>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ArchiveDocument;
|
||||
@@ -28,6 +28,10 @@ import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import HelpIcon from '../../icons/HelpIcon';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import ArchiveDocument from './components/ArchiveDocument';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
|
||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
|
||||
@@ -46,6 +50,13 @@ const DomandaEditPreInstructor = () => {
|
||||
const [isVisibleCompleteDialog, setIsVisibleCompleteDialog] = useState(false);
|
||||
const [operationType, setOperationType] = useState('');
|
||||
const [motivation, setMotivation] = useState('');
|
||||
const [isVisibleAppointmentDialog, setIsVisibleAppointmentDialog] = useState(false);
|
||||
const [appointmentData, setAppointmentData] = useState({
|
||||
title: '',
|
||||
text: '',
|
||||
duration: 0,
|
||||
amount: 0
|
||||
});
|
||||
|
||||
const goToEvaluationsPage = () => {
|
||||
navigate('/domande');
|
||||
@@ -322,10 +333,53 @@ const DomandaEditPreInstructor = () => {
|
||||
setIsVisibleCompleteDialog(true);
|
||||
}
|
||||
|
||||
const doCreateAppointment = () => {
|
||||
const doCheckNDG = () => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
const doCreateAppointment = () => {
|
||||
setAppointmentData({
|
||||
title: '',
|
||||
text: '',
|
||||
duration: 0,
|
||||
amount: 0
|
||||
});
|
||||
setIsVisibleAppointmentDialog(true);
|
||||
}
|
||||
|
||||
const setValue = (name, value) => {
|
||||
const newData = wrap(appointmentData).set(name, value).value();
|
||||
setAppointmentData(newData);
|
||||
}
|
||||
|
||||
const headerAppointmentDialog = () => {
|
||||
return <span>{__('Crea appuntamento', 'gepafin')}</span>;
|
||||
}
|
||||
|
||||
const hideAppointmentDialog = () => {
|
||||
setIsVisibleAppointmentDialog(false);
|
||||
setAppointmentData({});
|
||||
}
|
||||
|
||||
const footerAppointmentDialog = () => {
|
||||
return <div>
|
||||
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideAppointmentDialog} outlined/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={loading}
|
||||
label={__('Invia', 'gepafin')} onClick={doCreateAppointmentRequest}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
const doCreateAppointmentRequest = () => {
|
||||
if (
|
||||
!isEmpty(appointmentData.title) && !isEmpty(appointmentData.text) && !isEmpty(appointmentData.amount)
|
||||
&& !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0
|
||||
) {
|
||||
console.log(appointmentData);
|
||||
}
|
||||
}
|
||||
|
||||
const doMakeAdmisible = () => {
|
||||
// TODO
|
||||
}
|
||||
@@ -565,6 +619,7 @@ const DomandaEditPreInstructor = () => {
|
||||
}}>
|
||||
<span>{k.name}</span>
|
||||
<div className="appPageSection__iconActions">
|
||||
<ArchiveDocument ndg={data.ndg} fileId={k.id}/>
|
||||
<Button icon="pi pi-eye" rounded
|
||||
onClick={() => window.open(k.filePath, '_blank').focus()}
|
||||
outlined severity="info"
|
||||
@@ -615,6 +670,13 @@ const DomandaEditPreInstructor = () => {
|
||||
onClick={doSaveDraft}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
@@ -675,6 +737,55 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<Dialog
|
||||
visible={isVisibleAppointmentDialog}
|
||||
modal
|
||||
header={headerAppointmentDialog}
|
||||
footer={footerAppointmentDialog}
|
||||
style={{ maxWidth: '600px', width: '100%' }}
|
||||
onHide={hideAppointmentDialog}>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.amount) || appointmentData.amount === 0})}>
|
||||
{__('Importo', 'gepafin')}
|
||||
</label>
|
||||
<InputNumber
|
||||
value={appointmentData.amount}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.amount) || appointmentData.amount === 0}
|
||||
onChange={(e) => setValue('amount', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.duration) || appointmentData.duration === 0 })}>
|
||||
{__('Durata', 'gepafin')}
|
||||
</label>
|
||||
<InputNumber
|
||||
value={appointmentData.duration}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.duration) || appointmentData.duration === 0}
|
||||
onChange={(e) => setValue('duration', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.title) })}>
|
||||
{__('Titolo', 'gepafin')}
|
||||
</label>
|
||||
<InputText
|
||||
value={appointmentData.title}
|
||||
invalid={isEmpty(appointmentData.title)}
|
||||
onChange={(e) => setValue('title', e.target.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.text) })}>
|
||||
{__('Messaggio', 'gepafin')}
|
||||
</label>
|
||||
<InputTextarea
|
||||
value={appointmentData.text}
|
||||
invalid={isEmpty(appointmentData.text)}
|
||||
onChange={(e) => setValue('text', e.target.value)}
|
||||
rows={3}
|
||||
cols={30}/>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
</div>
|
||||
: <>
|
||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
||||
|
||||
Reference in New Issue
Block a user