- added setting for documents category selection for fileselect;
- added confirmation popup for fileselect and fileinput;
This commit is contained in:
@@ -722,6 +722,7 @@ const BandoApplication = () => {
|
||||
}
|
||||
const step = head(o.settings.filter(o => o.name === 'step'));
|
||||
const mime = head(o.settings.filter(o => o.name === 'mime'));
|
||||
const documentCategories = head(o.settings.filter(o => o.name === 'documentCategories'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
let mimeValue = '';
|
||||
|
||||
@@ -773,6 +774,7 @@ const BandoApplication = () => {
|
||||
defaultValue={values[o.id] ? values[o.id] : ''}
|
||||
maxFractionDigits={step ? step.value : 0}
|
||||
accept={mimeValue}
|
||||
documentCategories={documentCategories ? documentCategories.value : []}
|
||||
config={validations}
|
||||
options={options ? options.value : []}
|
||||
setDataFn={setValue}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { __ } from '@wordpress/i18n';
|
||||
import { head, is, isEmpty, isNil, uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeGet } from '../../../../../../store';
|
||||
import { storeGet, useStore } from '../../../../../../store';
|
||||
|
||||
// tools
|
||||
import renderHtmlContent from '../../../../../../helpers/renderHtmlContent';
|
||||
@@ -23,6 +23,7 @@ import { mimeTypes } from '../../../../../../configData';
|
||||
|
||||
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
const [existingVars, setExistingVars] = useState([]);
|
||||
const documentCategories = useStore().main.documentCategories();
|
||||
|
||||
const settingLabels = {
|
||||
label: __('Label', 'gepafin'),
|
||||
@@ -32,6 +33,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
isDelegation: __('Delega', 'gepafin'),
|
||||
options: __('Opzioni', 'gepafin'),
|
||||
mime: __('Tipo di file', 'gepafin'),
|
||||
documentCategories: __('Categorie dei documenti', 'gepafin'),
|
||||
text: __('Testo formattato', 'gepafin'),
|
||||
table_columns: '',
|
||||
criteria_table_columns: '',
|
||||
@@ -79,6 +81,13 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
optionLabel="name"
|
||||
display="chip"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
} else if (setting.name === 'documentCategories') {
|
||||
return <MultiSelect
|
||||
value={is(Array, setting.value) ? setting.value : []}
|
||||
onChange={(e) => updateDataFn(setting.name, e.value)}
|
||||
options={documentCategories}
|
||||
display="chip"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
} else if (setting.name === 'text') {
|
||||
return <Editor
|
||||
value={setting.value}
|
||||
|
||||
@@ -25,6 +25,7 @@ import BandoService from '../../service/bando-service';
|
||||
|
||||
// TODO temp data
|
||||
import { elementItems } from '../../tempData';
|
||||
import DocumentCategoryService from '../../service/document-category-service';
|
||||
|
||||
const BandoFormsEdit = () => {
|
||||
const { id, formId } = useParams();
|
||||
@@ -257,6 +258,15 @@ const BandoFormsEdit = () => {
|
||||
set404FromErrorResponse(data);
|
||||
}
|
||||
|
||||
const getCategories = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.documentCategories(resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
}
|
||||
}
|
||||
|
||||
const errGetCategories = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const bandoId = getBandoId();
|
||||
const parsedFormId = parseInt(formId)
|
||||
@@ -283,6 +293,10 @@ const BandoFormsEdit = () => {
|
||||
}
|
||||
}, [id, formId]);
|
||||
|
||||
useEffect(() => {
|
||||
DocumentCategoryService.getCategories(getCategories, errGetCategories)
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Dialog } from 'primereact/dialog';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { useStore } from '../../store';
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import { FileUpload } from 'primereact/fileupload';
|
||||
import formatDateString from '../../helpers/formatDateString';
|
||||
@@ -24,7 +24,7 @@ const DocumentsBeneficiary = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const [isVisibleAddNewDialog, setIsVisibleAddNewDialog] = useState(false);
|
||||
const [categories, setCategories] = useState(false);
|
||||
const documentCategories= useStore().main.documentCategories();
|
||||
const [newFileData, setNewFileData] = useState({});
|
||||
const [fileAttached, setFileAttached] = useState([]);
|
||||
const [reloadHash, setReloadHash] = useState(0);
|
||||
@@ -120,7 +120,7 @@ const DocumentsBeneficiary = () => {
|
||||
|
||||
const getCategories = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setCategories(resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
storeSet.main.documentCategories(resp.data.map(o => ({value: o.id, label: o.description})));
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ const DocumentsBeneficiary = () => {
|
||||
value={newFileData.documentCategoryId}
|
||||
invalid={isEmpty(newFileData.documentCategoryId) || isNil(newFileData.documentCategoryId) || newFileData.documentCategoryId === 0}
|
||||
onChange={(e) => onUpdateFieldValue(e.value, 'documentCategoryId')}
|
||||
options={categories}
|
||||
options={documentCategories}
|
||||
optionLabel="label"
|
||||
optionValue="value"/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user