From 8a62213badd930d239ce321359b0b2cd071790e3 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 12 Mar 2025 12:45:08 +0100 Subject: [PATCH] - added setting for documents category selection for fileselect; - added confirmation popup for fileselect and fileinput; --- .../FormField/components/FileSelect/index.js | 32 +++++++++++++++---- .../FormField/components/Fileupload/index.js | 17 +++++++++- .../FormField/components/Wysiwyg/index.js | 1 - src/layouts/DefaultLayout/index.js | 2 +- src/pages/BandoApplication/index.js | 2 ++ .../components/ElementSetting/index.js | 11 ++++++- src/pages/BandoFormsEdit/index.js | 14 ++++++++ src/pages/DocumentsBeneficiary/index.js | 8 ++--- src/store/initial.js | 1 + src/tempData.js | 4 +++ 10 files changed, 77 insertions(+), 15 deletions(-) diff --git a/src/components/FormField/components/FileSelect/index.js b/src/components/FormField/components/FileSelect/index.js index 55fa612..089b625 100644 --- a/src/components/FormField/components/FileSelect/index.js +++ b/src/components/FormField/components/FileSelect/index.js @@ -3,12 +3,15 @@ import { classNames } from 'primereact/utils'; import { __ } from '@wordpress/i18n'; import { isEmpty, pathOr, pluck } from 'ramda'; +// service +import FileUploadService from '../../../../service/file-upload-service'; +import CompanyDocumentsService from '../../../../service/company-documents-service'; + // components import { ListBox } from 'primereact/listbox'; import { Button } from 'primereact/button'; -import CompanyDocumentsService from '../../../../service/company-documents-service'; import { Link } from 'react-router-dom'; -import FileUploadService from '../../../../service/file-upload-service'; +import { ConfirmPopup, confirmPopup } from 'primereact/confirmpopup'; const FileSelect = ({ fieldName, @@ -23,6 +26,7 @@ const FileSelect = ({ options = [], sourceId = 0, source = 'DOCUMENT', + documentCategories = [], saveFormCallback }) => { //const [stateFieldData, setStateFieldData] = useState([]); @@ -87,9 +91,18 @@ const FileSelect = ({ console.log('err', err); } - /*useEffect(() => { - console.log('selectedUnconfirmed', selectedUnconfirmed) - }, [selectedUnconfirmed]);*/ + const confirmDelete = (event, id) => { + confirmPopup({ + target: event.currentTarget, + message: __('Sei sicuro di cancellare il file?', 'gepafin'), + acceptLabel: __('Si', 'gepafin'), + icon: 'pi pi-info-circle', + defaultFocus: 'reject', + acceptClassName: 'p-button-danger', + accept: () => removeAttached(id), + reject: () => {} + }); + }; useEffect(() => { stateFieldData.current = defaultValue; @@ -98,7 +111,11 @@ const FileSelect = ({ useEffect(() => { if (!isEmpty(options)) { - const optionsDefault = options.reduce((acc, cur) => { + const optionsDefault = options + .filter(o => isEmpty(documentCategories) + ? o + : documentCategories.includes(o.category.id)) + .reduce((acc, cur) => { const catName = pathOr('', ['category', 'categoryName'], cur); const catLabel = pathOr('', ['category', 'description'], cur); @@ -163,7 +180,7 @@ const FileSelect = ({