@@ -16,6 +16,7 @@ export interface IProcessingFormDialogOptions extends IBaseFormProps {
1616  sourceData : IDict ; 
1717  title : string ; 
1818  syncData : ( props : IDict )  =>  void ; 
19+   cancel ?: ( )  =>  void ; 
1920  syncSelectedPropField ?: ( 
2021    id : string  |  null , 
2122    value : any , 
@@ -37,19 +38,25 @@ export interface IProcessingFormWrapperProps
3738const  ProcessingFormWrapper : React . FC < IProcessingFormWrapperProps >  =  props  =>  { 
3839  const  [ ready ,  setReady ]  =  React . useState < boolean > ( false ) ; 
3940
40-   const  okSignal  =  React . useRef < Signal < Dialog < any > ,  number > > ( ) ; 
41-   const  formErrorSignal  =  React . useRef < Signal < Dialog < any > ,  boolean > > ( ) ; 
41+   const  okSignal  =  React . useRef < Signal < Dialog < any > ,  number >  |  undefined > ( 
42+     undefined , 
43+   ) ; 
44+   const  formErrorSignal  =  React . useRef < 
45+     Signal < Dialog < any > ,  boolean >  |  undefined 
46+   > ( undefined ) ; 
4247
4348  Promise . all ( [ 
4449    props . okSignalPromise . promise , 
45-     props . formErrorSignalPromise ?. promise , 
50+     props . formErrorSignalPromise 
51+       ? props . formErrorSignalPromise . promise 
52+       : Promise . resolve ( undefined ) , 
4653  ] ) . then ( ( [ ok ,  formChanged ] )  =>  { 
4754    okSignal . current  =  ok ; 
48-     formErrorSignal . current  =  formChanged ; 
55+     formErrorSignal . current  =  formChanged   ||   undefined ; 
4956    setReady ( true ) ; 
5057  } ) ; 
5158
52-   let  FormComponent ; 
59+   let  FormComponent :  React . ComponentType < any > ; 
5360  switch  ( props . processingType )  { 
5461    case  'Dissolve' :
5562      FormComponent  =  DissolveForm ; 
@@ -138,6 +145,12 @@ export class ProcessingFormDialog extends Dialog<IDict> {
138145          okSignalPromise = { okSignalPromise } 
139146          formErrorSignalPromise = { formErrorSignalPromise } 
140147          syncData = { syncData }  // Use the modified sync function 
148+           cancel = { 
149+             options . cancel  ?? 
150+             ( ( )  =>  { 
151+               /* no action needed on cancel */ 
152+             } ) 
153+           } 
141154        /> 
142155      </ div > 
143156    ) ; 
@@ -157,9 +170,14 @@ export class ProcessingFormDialog extends Dialog<IDict> {
157170    formErrorSignal . connect ( ( _ ,  extraErrors )  =>  { 
158171      const  invalid  =  extraErrors  ||  ! ! this . node . querySelector ( ':invalid' ) ; 
159172      if  ( invalid )  { 
160-         this . node 
161-           . getElementsByClassName ( 'jp-mod-accept' ) [ 0 ] 
162-           . setAttribute ( 'disabled' ,  '' ) ; 
173+         const  okBtn  =  this . node . getElementsByClassName ( 
174+           'jp-mod-accept' , 
175+         ) [ 0 ]  as  HTMLButtonElement ; 
176+         if  ( invalid )  { 
177+           okBtn . setAttribute ( 'disabled' ,  '' ) ; 
178+         }  else  { 
179+           okBtn . removeAttribute ( 'disabled' ) ; 
180+         } 
163181      }  else  { 
164182        this . node 
165183          . getElementsByClassName ( 'jp-mod-accept' ) [ 0 ] 
@@ -183,5 +201,5 @@ export class ProcessingFormDialog extends Dialog<IDict> {
183201    } 
184202  } 
185203
186-   private  okSignal : Signal < Dialog < any > ,  number > ; 
204+   private  okSignal : Signal < Dialog < IDict > ,  number > ; 
187205} 
0 commit comments