mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
veiwer on event should return
This commit is contained in:
parent
ea70a53f3c
commit
5fccede5a2
2 changed files with 11 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ import { resolveWidgetFieldValue } from '@/_helpers/utils';
|
|||
import { toast } from 'react-hot-toast';
|
||||
import * as XLSX from 'xlsx/xlsx.mjs';
|
||||
import { useCurrentState } from '@/_stores/currentStateStore';
|
||||
import { useAppInfo } from '@/_stores/appDataStore';
|
||||
|
||||
export const FilePicker = ({
|
||||
id,
|
||||
|
|
@ -54,6 +55,10 @@ export const FilePicker = ({
|
|||
const parsedWidgetVisibility =
|
||||
typeof widgetVisibility !== 'boolean' ? resolveWidgetFieldValue(widgetVisibility, currentState) : widgetVisibility;
|
||||
|
||||
const { events: allAppEvents } = useAppInfo();
|
||||
|
||||
const filePickerEvents = allAppEvents.filter((event) => event.target === 'component' && event.sourceId === id);
|
||||
|
||||
const bgThemeColor = darkMode ? '#232E3C' : '#fff';
|
||||
|
||||
const baseStyle = {
|
||||
|
|
@ -235,7 +240,7 @@ export const FilePicker = ({
|
|||
onComponentOptionChanged(component, 'file', [], id);
|
||||
}
|
||||
|
||||
if (acceptedFiles.length !== 0) {
|
||||
if (acceptedFiles.length !== 0 && onEvent) {
|
||||
const fileData = parsedEnableMultiple ? [...selectedFiles] : [];
|
||||
if (parseContent) {
|
||||
onComponentOptionChanged(component, 'isParsing', true, id);
|
||||
|
|
@ -250,7 +255,8 @@ export const FilePicker = ({
|
|||
});
|
||||
setSelectedFiles(fileData);
|
||||
onComponentOptionChanged(component, 'file', fileData, id);
|
||||
onEvent('onFileSelected', { component })
|
||||
|
||||
onEvent('onFileSelected', filePickerEvents, { component })
|
||||
.then(() => {
|
||||
setAccepted(true);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
|
@ -263,7 +269,7 @@ export const FilePicker = ({
|
|||
}, 600);
|
||||
});
|
||||
})
|
||||
.then(() => onEvent('onFileLoaded', { component }));
|
||||
.then(() => onEvent('onFileLoaded', filePickerEvents, { component }));
|
||||
}
|
||||
|
||||
if (fileRejections.length > 0) {
|
||||
|
|
@ -286,7 +292,7 @@ export const FilePicker = ({
|
|||
copy.splice(index, 1);
|
||||
return copy;
|
||||
});
|
||||
onEvent('onFileDeselected', { component });
|
||||
onEvent('onFileDeselected', filePickerEvents);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ class ViewerComponent extends React.Component {
|
|||
};
|
||||
|
||||
handleEvent = (eventName, events, options) => {
|
||||
onEvent(this.getViewerRef(), eventName, events, options, 'view');
|
||||
return onEvent(this.getViewerRef(), eventName, events, options, 'view');
|
||||
};
|
||||
|
||||
computeCanvasMaxWidth = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue