- updated version;
This commit is contained in:
@@ -17,3 +17,19 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nodeIntermediateForm {
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: white;
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
max-width: 180px;
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,8 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: "Montserrat", sans-serif;
|
font-family: "Montserrat", sans-serif;
|
||||||
|
|
||||||
p, span:not(.p-button-label, .p-button-icon, .p-badge), input, label:not(.p-error), textarea, a, li, h1, h2, h3, h4, h5, h6, div, th, td {
|
p, span:not(.p-button-label, .p-button-icon, .p-badge, .p-message-detail), input, label:not(.p-error),
|
||||||
|
textarea, a, li, h1, h2, h3, h4, h5, h6, div, th, td {
|
||||||
color: var(--global-textColor);
|
color: var(--global-textColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.p-paginator-page {
|
.p-paginator-page {
|
||||||
color: var(--menuitem-active-color);
|
/*color: var(--menuitem-active-color);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-datepicker-buttonbar .p-button {
|
.p-datepicker-buttonbar .p-button {
|
||||||
@@ -78,6 +78,10 @@
|
|||||||
color: var(--primary-text);
|
color: var(--primary-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p-toast-detail {
|
||||||
|
color: white;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.mb-2 {
|
.mb-2 {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const NodeIntermediateForm = ({ data: { id, label = '' } }) => {
|
|||||||
}, [flowEdges, flowData]);
|
}, [flowEdges, flowData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="nodeInitialForm">
|
<div className="nodeIntermediateForm">
|
||||||
<Handle
|
<Handle
|
||||||
type="target"
|
type="target"
|
||||||
position={Position.Top}
|
position={Position.Top}
|
||||||
|
|||||||
@@ -32,33 +32,38 @@ const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (initialForm && finalForm && forms.length) {
|
if (
|
||||||
|
(forms.length === 2 && initialForm) ||
|
||||||
|
(forms.length > 2 && initialForm && finalForm)
|
||||||
|
) {
|
||||||
const total = (forms.length - 2) * (200 - 90);
|
const total = (forms.length - 2) * (200 - 90);
|
||||||
let coordinates = range(total * -1, total, 200);
|
let coordinates = range(total * -1, total, 200);
|
||||||
|
|
||||||
const initialNodes = forms.map(o => {
|
const initialNodes = forms.map(o => {
|
||||||
|
const formId = String(o.id);
|
||||||
let obj;
|
let obj;
|
||||||
|
|
||||||
if (o.id === initialForm) {
|
if (formId === String(initialForm)) {
|
||||||
obj = {
|
obj = {
|
||||||
id: String(o.id),
|
id: formId,
|
||||||
type: 'initialForm',
|
type: 'initialForm',
|
||||||
data: { label: o.label, id: o.id },
|
data: { label: o.label, id: formId },
|
||||||
position: { x: 0, y: 0 },
|
position: { x: 0, y: 0 },
|
||||||
}
|
}
|
||||||
} else if (o.id === finalForm) {
|
} else if (formId === String(finalForm)) {
|
||||||
obj = {
|
obj = {
|
||||||
id: String(o.id),
|
id: formId,
|
||||||
type: 'output',
|
type: 'output',
|
||||||
data: { label: o.label, id: o.id },
|
data: { label: o.label, id: formId },
|
||||||
position: { x: 0, y: 300 },
|
position: { x: 0, y: 300 },
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const x = coordinates.splice(0, 1);
|
const x = coordinates.splice(0, 1);
|
||||||
|
console.log('x', x)
|
||||||
obj = {
|
obj = {
|
||||||
id: String(o.id),
|
id: formId,
|
||||||
type: 'intermediateForm',
|
type: 'intermediateForm',
|
||||||
data: { label: o.label, id: o.id },
|
data: { label: o.label, id: formId },
|
||||||
position: { x, y: 150 },
|
position: { x, y: 150 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,13 +71,18 @@ const FlowBuilder = ({ initialForm = 0, finalForm = 0 }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let edges = [];
|
let edges = [];
|
||||||
|
// eslint-disable-next-line
|
||||||
forms.map(o => {
|
forms.map(o => {
|
||||||
if (o.id !== initialForm && o.id !== finalForm) {
|
const formId = String(o.id);
|
||||||
edges.push({ id: `${initialForm}->${o.id}`, source: String(initialForm), target: String(o.id), type: 'smoothstep' });
|
|
||||||
edges.push({ id: `${o.id}->${finalForm}`, source: String(o.id), target: String(finalForm), type: 'smoothstep' });
|
if (formId !== String(initialForm) && formId !== String(finalForm)) {
|
||||||
|
edges.push({ id: `${initialForm}->${formId}`, source: String(initialForm), target: formId, type: 'smoothstep' });
|
||||||
|
}
|
||||||
|
if (formId !== String(finalForm) && formId !== String(initialForm) && String(finalForm) !== '0') {
|
||||||
|
edges.push({ id: `${formId}->${finalForm}`, source: formId, target: String(finalForm), type: 'smoothstep' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('edges', edges, initialNodes);
|
||||||
setNodes(initialNodes);
|
setNodes(initialNodes);
|
||||||
setEdges(edges);
|
setEdges(edges);
|
||||||
storeSet.main.flowEdges(edges);
|
storeSet.main.flowEdges(edges);
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ const FileuploadAsync = ({
|
|||||||
}, [accept]);
|
}, [accept]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
inputRef.current.setUploadedFiles(stateFieldData);
|
inputRef.current.setUploadedFiles(stateFieldData);
|
||||||
|
}
|
||||||
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
||||||
}, [stateFieldData])
|
}, [stateFieldData])
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
||||||
import { classNames } from 'primereact/utils';
|
import { classNames } from 'primereact/utils';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { head, isEmpty, isNil } from 'ramda';
|
import { head, isEmpty, isNil, pluck } from 'ramda';
|
||||||
|
import { diff } from 'deep-object-diff';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { Menu } from 'primereact/menu';
|
import { Menu } from 'primereact/menu';
|
||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { diff } from 'deep-object-diff';
|
|
||||||
|
|
||||||
const FormFieldRepeater = ({
|
const FormFieldRepeater = ({
|
||||||
data,
|
data,
|
||||||
@@ -39,7 +39,7 @@ const FormFieldRepeater = ({
|
|||||||
setStateFieldData([...stateFieldData, { id: null, value: '', lookUpDataId: null }]);
|
setStateFieldData([...stateFieldData, { id: null, value: '', lookUpDataId: null }]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
const removeItem = (index) => {
|
const removeItem = (index) => {
|
||||||
const newData = stateFieldData.toSpliced(index, 1);
|
const newData = stateFieldData.toSpliced(index, 1);
|
||||||
@@ -96,6 +96,11 @@ const FormFieldRepeater = ({
|
|||||||
if (!isEmpty(diffData)) {
|
if (!isEmpty(diffData)) {
|
||||||
const storeFieldData = data ?? [];
|
const storeFieldData = data ?? [];
|
||||||
setStateFieldData(storeFieldData);
|
setStateFieldData(storeFieldData);
|
||||||
|
setStateOptionsData(prevState => {
|
||||||
|
const ids = pluck('id', storeFieldData)
|
||||||
|
const objectsToAdd = storeFieldData.filter(o => ids.includes(o.id));
|
||||||
|
return [...prevState, ...objectsToAdd];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
@@ -105,7 +110,7 @@ const FormFieldRepeater = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
||||||
}, [stateFieldData])
|
}, [stateFieldData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(['appForm__field', 'formfieldrepeater'])}>
|
<div className={classNames(['appForm__field', 'formfieldrepeater'])}>
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ const FormFieldRepeaterFaq = ({
|
|||||||
|
|
||||||
const editItem = (e, index) => {
|
const editItem = (e, index) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setQuestion(stateFieldData[index].title);
|
setTitle(stateFieldData[index].title);
|
||||||
setAnswer(stateFieldData[index].value);
|
setQuestion(stateFieldData[index].value);
|
||||||
|
setAnswer(stateFieldData[index].response);
|
||||||
setEditDataIndex(index);
|
setEditDataIndex(index);
|
||||||
setIsVisibleEditDialog(true);
|
setIsVisibleEditDialog(true);
|
||||||
}
|
}
|
||||||
@@ -71,6 +72,7 @@ const FormFieldRepeaterFaq = ({
|
|||||||
setIsVisibleEditDialog(false);
|
setIsVisibleEditDialog(false);
|
||||||
setQuestion('');
|
setQuestion('');
|
||||||
setAnswer('');
|
setAnswer('');
|
||||||
|
setTitle('');
|
||||||
setEditDataIndex(null);
|
setEditDataIndex(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +101,7 @@ const FormFieldRepeaterFaq = ({
|
|||||||
setIsVisibleEditDialog(false);
|
setIsVisibleEditDialog(false);
|
||||||
setQuestion('');
|
setQuestion('');
|
||||||
setAnswer('');
|
setAnswer('');
|
||||||
|
setTitle('');
|
||||||
setEditDataIndex(null);
|
setEditDataIndex(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +175,6 @@ const FormFieldRepeaterFaq = ({
|
|||||||
offLabel=""
|
offLabel=""
|
||||||
checked={o.isVisible}
|
checked={o.isVisible}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
console.log('e', e);
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setChecked(e, i);
|
setChecked(e, i);
|
||||||
@@ -181,9 +183,11 @@ const FormFieldRepeaterFaq = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className="appForm__faqTabItem">
|
<div className="appForm__faqTabItem">
|
||||||
<Button icon="pi pi-pencil" severity="success"
|
<Button icon="pi pi-pencil" severity="success"
|
||||||
|
type="button"
|
||||||
aria-label={__('Modifica', 'gepafin')}
|
aria-label={__('Modifica', 'gepafin')}
|
||||||
onClick={(e) => editItem(e, i)}/>
|
onClick={(e) => editItem(e, i)}/>
|
||||||
<Button icon="pi pi-times" severity="danger"
|
<Button icon="pi pi-times" severity="danger"
|
||||||
|
type="button"
|
||||||
aria-label={__('Cancella', 'gepafin')}
|
aria-label={__('Cancella', 'gepafin')}
|
||||||
onClick={() => removeItem(i)}/>
|
onClick={() => removeItem(i)}/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ const UnsavedChangesDetector = ({ getValuesFn }) => {
|
|||||||
const formData = getValuesFn();
|
const formData = getValuesFn();
|
||||||
const initial = storeGet.main.formInitialData();
|
const initial = storeGet.main.formInitialData();
|
||||||
const isEqual = equal(initial, formData);
|
const isEqual = equal(initial, formData);
|
||||||
console.log(initial, formData);
|
|
||||||
|
|
||||||
if (!isEqual) {
|
if (!isEqual) {
|
||||||
event.returnValue = __('You have unsaved changes. If you proceed, they will be lost.', 'gepafin');
|
event.returnValue = __('You have unsaved changes. If you proceed, they will be lost.', 'gepafin');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { forwardRef, useImperativeHandle, useEffect, useState, useMemo } from 'react';
|
import React, { forwardRef, useImperativeHandle, useEffect, useState, useMemo, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
@@ -11,6 +11,9 @@ import FormFieldRepeater from '../../../../components/FormFieldRepeater';
|
|||||||
import FormFieldRepeaterFaq from '../../../../components/FormFieldRepeaterFaq';
|
import FormFieldRepeaterFaq from '../../../../components/FormFieldRepeaterFaq';
|
||||||
import BandoEditFormActions from '../BandoEditFormActions';
|
import BandoEditFormActions from '../BandoEditFormActions';
|
||||||
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
import LookupdataService from '../../../../service/lookupdata-service';
|
import LookupdataService from '../../../../service/lookupdata-service';
|
||||||
|
|
||||||
@@ -39,6 +42,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
}, [formInitialData]), mode: 'onChange'
|
}, [formInitialData]), mode: 'onChange'
|
||||||
});
|
});
|
||||||
const values = getValues();
|
const values = getValues();
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
if (!isNil(formData.dates) && formData.dates.length) {
|
if (!isNil(formData.dates) && formData.dates.length) {
|
||||||
@@ -54,6 +58,11 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
|
|
||||||
const createCallback = (data) => {
|
const createCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'success',
|
||||||
|
summary: '',
|
||||||
|
detail: __('Il bando è stato aggiornato corretamente!', 'gepafin')
|
||||||
|
});
|
||||||
const values = getValues();
|
const values = getValues();
|
||||||
if (!values.id && data.data.id) {
|
if (!values.id && data.data.id) {
|
||||||
navigate(`/tenders/${data.data.id}`);
|
navigate(`/tenders/${data.data.id}`);
|
||||||
@@ -84,7 +93,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
delete o.type;
|
delete o.type;
|
||||||
return {
|
return {
|
||||||
...o,
|
...o,
|
||||||
lookUpDataId: o.id
|
lookUpDataId: o.id,
|
||||||
|
id: null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setAimedToOptions(aimedTo);
|
setAimedToOptions(aimedTo);
|
||||||
@@ -94,7 +104,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
delete o.type;
|
delete o.type;
|
||||||
return {
|
return {
|
||||||
...o,
|
...o,
|
||||||
lookUpDataId: o.id
|
lookUpDataId: o.id,
|
||||||
|
id: null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setFaqOptions(faqItems);
|
setFaqOptions(faqItems);
|
||||||
@@ -290,6 +301,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
<span>{__('Azioni', 'gepafin')}</span>
|
<span>{__('Azioni', 'gepafin')}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Toast ref={toast} />
|
||||||
<BandoEditFormActions
|
<BandoEditFormActions
|
||||||
id={values.id}
|
id={values.id}
|
||||||
openPreview={openPreview}
|
openPreview={openPreview}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
@@ -11,8 +11,13 @@ import FormFieldRepeater from '../../../../components/FormFieldRepeater';
|
|||||||
import FormFieldRepeaterCriteria from '../../../../components/FormFieldRepeaterCriteria';
|
import FormFieldRepeaterCriteria from '../../../../components/FormFieldRepeaterCriteria';
|
||||||
import BandoEditFormActions from '../BandoEditFormActions';
|
import BandoEditFormActions from '../BandoEditFormActions';
|
||||||
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
import LookupdataService from '../../../../service/lookupdata-service';
|
import LookupdataService from '../../../../service/lookupdata-service';
|
||||||
|
|
||||||
|
// store
|
||||||
import { storeSet } from '../../../../store';
|
import { storeSet } from '../../../../store';
|
||||||
|
|
||||||
const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors }, ref) {
|
const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors }, ref) {
|
||||||
@@ -37,6 +42,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
});
|
});
|
||||||
const values = getValues();
|
const values = getValues();
|
||||||
const step2Props = ['threshold', 'criteria', 'checkList', 'docs', 'images'];
|
const step2Props = ['threshold', 'criteria', 'checkList', 'docs', 'images'];
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
if (!isNil(formData.dates) && formData.dates.length) {
|
if (!isNil(formData.dates) && formData.dates.length) {
|
||||||
@@ -55,6 +61,11 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
|
|
||||||
const createCallback = (data) => {
|
const createCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'success',
|
||||||
|
summary: '',
|
||||||
|
detail: __('Il bando è stato aggiornato corretamente!', 'gepafin')
|
||||||
|
});
|
||||||
setFormInitialData(data.data);
|
setFormInitialData(data.data);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@@ -73,7 +84,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
return {
|
return {
|
||||||
...o,
|
...o,
|
||||||
score: 0,
|
score: 0,
|
||||||
lookUpDataId: o.id
|
lookUpDataId: o.id,
|
||||||
|
id: null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setCriteriaOptions(criteria);
|
setCriteriaOptions(criteria);
|
||||||
@@ -83,7 +95,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
delete o.type;
|
delete o.type;
|
||||||
return {
|
return {
|
||||||
...o,
|
...o,
|
||||||
lookUpDataId: o.id
|
lookUpDataId: o.id,
|
||||||
|
id: null
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setChecklistOptions(checklist);
|
setChecklistOptions(checklist);
|
||||||
@@ -215,6 +228,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
|||||||
<span>{__('Azioni', 'gepafin')}</span>
|
<span>{__('Azioni', 'gepafin')}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Toast ref={toast} />
|
||||||
<BandoEditFormActions
|
<BandoEditFormActions
|
||||||
openPreview={openPreview}
|
openPreview={openPreview}
|
||||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import { isEmpty } from 'ramda';
|
import { isEmpty } from 'ramda';
|
||||||
@@ -16,15 +16,18 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
|||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import FlowBuilder from '../../components/FlowBuilder';
|
import FlowBuilder from '../../components/FlowBuilder';
|
||||||
|
import { Messages } from 'primereact/messages';
|
||||||
|
|
||||||
const BandoFlowEdit = () => {
|
const BandoFlowEdit = () => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const forms = useStore().main.flowForms();
|
||||||
const flowData = useStore().main.flowData();
|
const flowData = useStore().main.flowData();
|
||||||
const flowEdges = useStore().main.flowEdges();
|
const flowEdges = useStore().main.flowEdges();
|
||||||
const [formOptions, setFormOptions] = useState([]);
|
const [formOptions, setFormOptions] = useState([]);
|
||||||
const [initialForm, setInitialForm] = useState(0);
|
const [initialForm, setInitialForm] = useState(0);
|
||||||
const [finalForm, setFinalForm] = useState(0);
|
const [finalForm, setFinalForm] = useState(0);
|
||||||
|
const flowMsgs = useRef(null);
|
||||||
|
|
||||||
const getBandoId = () => {
|
const getBandoId = () => {
|
||||||
const parsed = parseInt(id)
|
const parsed = parseInt(id)
|
||||||
@@ -51,7 +54,7 @@ const BandoFlowEdit = () => {
|
|||||||
|
|
||||||
const getFormsCallback = (data) => {
|
const getFormsCallback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
const formOptions = data.data.map(o => ({label: o.label, value: o.id}))
|
const formOptions = data.data.map(o => ({ label: o.label, value: o.id }))
|
||||||
storeSet.main.flowForms(data.data);
|
storeSet.main.flowForms(data.data);
|
||||||
setFormOptions(formOptions);
|
setFormOptions(formOptions);
|
||||||
}
|
}
|
||||||
@@ -69,6 +72,20 @@ const BandoFlowEdit = () => {
|
|||||||
FormsService.getFormsForCall(bandoId, getFormsCallback, errGetFormsCallback);
|
FormsService.getFormsForCall(bandoId, getFormsCallback, errGetFormsCallback);
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (flowMsgs.current && forms.length < 2) {
|
||||||
|
flowMsgs.current.clear();
|
||||||
|
flowMsgs.current.show([
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
sticky: true, severity: 'info', summary: '',
|
||||||
|
detail: __('Devi creare almeno 2 form.', 'gepafin'),
|
||||||
|
closable: false
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}, [forms]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
storeSet.main.flowForms([]);
|
storeSet.main.flowForms([]);
|
||||||
@@ -100,10 +117,11 @@ const BandoFlowEdit = () => {
|
|||||||
options={formOptions}
|
options={formOptions}
|
||||||
optionLabel="label"
|
optionLabel="label"
|
||||||
optionValue="value"
|
optionValue="value"
|
||||||
placeholder={__('Scegli il form', 'gepafin')} />
|
placeholder={__('Scegli il form', 'gepafin')}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appForm__field">
|
{forms.length > 2
|
||||||
|
? <div className="appForm__field">
|
||||||
<label htmlFor="finalForm">{__('Scegli form finale', 'gepafin')}</label>
|
<label htmlFor="finalForm">{__('Scegli form finale', 'gepafin')}</label>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
id="finalForm"
|
id="finalForm"
|
||||||
@@ -113,15 +131,17 @@ const BandoFlowEdit = () => {
|
|||||||
options={formOptions}
|
options={formOptions}
|
||||||
optionLabel="label"
|
optionLabel="label"
|
||||||
optionValue="value"
|
optionValue="value"
|
||||||
placeholder={__('Scegli il form', 'gepafin')} />
|
placeholder={__('Scegli il form', 'gepafin')}/>
|
||||||
</div>
|
</div> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<FlowBuilder initialForm={initialForm} finalForm={finalForm}/>
|
{forms.length >= 2
|
||||||
|
? <FlowBuilder initialForm={initialForm} finalForm={finalForm}/>
|
||||||
|
: <Messages ref={flowMsgs}/>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ const BandoFormsEdit = () => {
|
|||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
const bandoId = getBandoId();
|
const bandoId = getBandoId();
|
||||||
|
|
||||||
if (shouldRedirect) {
|
if (shouldRedirect) {
|
||||||
navigate(`/tenders/${bandoId}/forms/${data.data.id}/preview`);
|
navigate(`/tenders/${bandoId}/forms/${data.data.id}/preview`);
|
||||||
return;
|
return;
|
||||||
@@ -198,7 +197,7 @@ const BandoFormsEdit = () => {
|
|||||||
outlined
|
outlined
|
||||||
label={__('Indietro', 'gepafin')} icon="pi pi-arrow-left" iconPos="left"/>
|
label={__('Indietro', 'gepafin')} icon="pi pi-arrow-left" iconPos="left"/>
|
||||||
<Button
|
<Button
|
||||||
onClick={doSave}
|
onClick={() => doSave()}
|
||||||
label={__('Salva progressi', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
label={__('Salva progressi', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
||||||
<Button
|
<Button
|
||||||
outlined
|
outlined
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ import { uniq } from 'ramda';
|
|||||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
|
||||||
|
// store
|
||||||
|
import { storeSet } from '../../../../store';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import BandoService from '../../../../service/bando-service';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||||
import { DataTable } from 'primereact/datatable';
|
import { DataTable } from 'primereact/datatable';
|
||||||
@@ -30,7 +36,7 @@ const LatestBandiTable = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// TODO
|
// TODO
|
||||||
const items = [
|
/*const items = [
|
||||||
{
|
{
|
||||||
name: 'Bando Innovazione 2024',
|
name: 'Bando Innovazione 2024',
|
||||||
start_date: '2024-08-08T00:00:00+00:00',
|
start_date: '2024-08-08T00:00:00+00:00',
|
||||||
@@ -59,9 +65,26 @@ const LatestBandiTable = () => {
|
|||||||
setItems(getFormattedBandiData(items));
|
setItems(getFormattedBandiData(items));
|
||||||
setStatuses(uniq(items.map(o => o.status)))
|
setStatuses(uniq(items.map(o => o.status)))
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
initFilters();
|
initFilters();*/
|
||||||
|
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
BandoService.getBandi(getCallback, errGetCallbacks);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const getCallback = (data) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
setItems(getFormattedBandiData(data.data));
|
||||||
|
setStatuses(uniq(data.data.map(o => o.status)))
|
||||||
|
initFilters();
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errGetCallbacks = (data) => {
|
||||||
|
console.log('errGetCallbacks', data)
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
const getFormattedBandiData = (data) => {
|
const getFormattedBandiData = (data) => {
|
||||||
return [...(data || [])].map((d) => {
|
return [...(data || [])].map((d) => {
|
||||||
d.start_date = new Date(d.start_date);
|
d.start_date = new Date(d.start_date);
|
||||||
|
|||||||
Reference in New Issue
Block a user