@@ -2,23 +2,26 @@ import classNames from "classnames";
22import { ReactElement } from "react" ;
33
44import { useSignaturePad } from "src/utils/useSignaturePad" ;
5- import Utils from "../utils/Utils" ;
6- import { SignatureProps } from "../utils/customTypes" ;
75import { Alert } from "@mendix/widget-plugin-component-kit/Alert" ;
6+ import { If } from "@mendix/widget-plugin-component-kit/If" ;
87import { Grid } from "./Grid" ;
98import { SizeContainer } from "./SizeContainer" ;
9+ import { SignatureProps } from "../utils/customTypes" ;
10+ import Utils from "../utils/Utils" ;
1011
1112export function SignatureComponent ( props : SignatureProps ) : ReactElement {
1213 const { className, alertMessage, wrapperStyle, imageSource, onSignEndAction } = props ;
14+ const readOnly = imageSource . readOnly ;
15+ const showGrid = props . showGrid && ! readOnly ;
1316
1417 const handleSignEnd = ( imageDataUrl ?: string ) : void => {
1518 if ( imageDataUrl ) {
1619 imageSource . setValue ( Utils . convertUrlToBlob ( imageDataUrl ) ) ;
1720 }
1821
1922 // Trigger microflow to update signature attribute
20- if ( onSignEndAction ) {
21- onSignEndAction ( imageDataUrl ) ;
23+ if ( onSignEndAction && ! onSignEndAction . isExecuting && onSignEndAction . canExecute ) {
24+ onSignEndAction . execute ( { signatureImage : imageDataUrl } ) ;
2225 }
2326 } ;
2427
@@ -33,7 +36,9 @@ export function SignatureComponent(props: SignatureProps): ReactElement {
3336 onResize = { onResize }
3437 >
3538 < Alert bootstrapStyle = "danger" > { alertMessage } </ Alert >
36- < Grid { ...props } />
39+ < If condition = { showGrid } >
40+ < Grid { ...props } />
41+ </ If >
3742 < canvas className = "widget-signature-canvas" ref = { canvasRef } />
3843 </ SizeContainer >
3944 ) ;
0 commit comments