- added setting for documents category selection for fileselect;
- added confirmation popup for fileselect and fileinput;
This commit is contained in:
@@ -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 = ({
|
||||
<Button icon="pi pi-times" rounded
|
||||
type="button"
|
||||
size="small"
|
||||
onClick={() => removeAttached(o.id)}
|
||||
onClick={(e) => confirmDelete(e, o.id)}
|
||||
outlined severity="danger"
|
||||
aria-label={__('Cancella', 'gepafin')}/>
|
||||
</div>
|
||||
@@ -188,6 +205,7 @@ const FileSelect = ({
|
||||
</div>
|
||||
: null}
|
||||
{infoText ? <small>{infoText}</small> : null}
|
||||
<ConfirmPopup />
|
||||
</>)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import { Button } from 'primereact/button';
|
||||
|
||||
import { defaultMaxFileSize, mimeTypes } from '../../../../configData';
|
||||
import getFormatedFileSizeText from '../../../../helpers/getFormatedFileSizeText';
|
||||
import { ConfirmPopup, confirmPopup } from 'primereact/confirmpopup';
|
||||
|
||||
const Fileupload = ({
|
||||
fieldName,
|
||||
@@ -72,6 +73,19 @@ const Fileupload = ({
|
||||
console.log('err', err);
|
||||
}
|
||||
|
||||
const confirmDelete = (event, file) => {
|
||||
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: () => onTemplateRemove(file),
|
||||
reject: () => {}
|
||||
});
|
||||
};
|
||||
|
||||
const itemTemplate = (file) => {
|
||||
let fileName = file.fileName ? file.fileName : file.name;
|
||||
return (
|
||||
@@ -91,7 +105,7 @@ const Fileupload = ({
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
aria-label={__('Anulla', 'gepafin')}
|
||||
onClick={() => onTemplateRemove(file)}/>
|
||||
onClick={(e) => confirmDelete(e, file)}/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -213,6 +227,7 @@ const Fileupload = ({
|
||||
onBeforeSelect={onBeforeSelect}
|
||||
uploadHandler={customBase64Uploader}/>
|
||||
{infoText ? <small>{infoText}</small> : null}
|
||||
<ConfirmPopup />
|
||||
</>
|
||||
: null
|
||||
)
|
||||
|
||||
@@ -78,7 +78,6 @@ const Wysiwyg = ({
|
||||
clipboard: {
|
||||
matchers: [
|
||||
[ Node.ELEMENT_NODE, function(node, delta) {
|
||||
console.log('here')
|
||||
const ops = delta.ops.map((op) => ({insert: op.insert}));
|
||||
return new Delta(ops)
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user