@@ -96,28 +96,25 @@ export class AddonModDataEditPage {
9696 *
9797 * @return Resolved if we can leave it, rejected if not.
9898 */
99- ionViewCanLeave ( ) : boolean | Promise < void > {
99+ async ionViewCanLeave ( ) : Promise < void > {
100100 if ( this . forceLeave || ! this . entry ) {
101- return true ;
101+ return ;
102102 }
103103
104104 const inputData = this . editForm . value ;
105105
106- return this . dataHelper . hasEditDataChanged ( inputData , this . fieldsArray , this . data . id ,
107- this . entry . contents ) . then ( ( changed ) => {
108- if ( ! changed ) {
109- return Promise . resolve ( ) ;
110- }
106+ const changed = await this . dataHelper . hasEditDataChanged ( inputData , this . fieldsArray , this . data . id , this . entry . contents ) ;
111107
108+ if ( changed ) {
112109 // Show confirmation if some data has been modified.
113- return this . domUtils . showConfirm ( this . translate . instant ( 'core.confirmcanceledit' ) ) ;
114- } ) . then ( ( ) => {
115- // Delete the local files from the tmp folder.
116- return this . dataHelper . getEditTmpFiles ( inputData , this . fieldsArray , this . data . id ,
117- this . entry . contents ) . then ( ( files ) => {
118- this . fileUploaderProvider . clearTmpFiles ( files ) ;
119- } ) ;
120- } ) ;
110+ await this . domUtils . showConfirm ( this . translate . instant ( 'core.confirmcanceledit' ) ) ;
111+ }
112+
113+ // Delete the local files from the tmp folder.
114+ const files = await this . dataHelper . getEditTmpFiles ( inputData , this . fieldsArray , this . data . id , this . entry . contents ) ;
115+ this . fileUploaderProvider . clearTmpFiles ( files ) ;
116+
117+ this . domUtils . triggerFormCancelledEvent ( this . formElement . nativeElement , this . siteId ) ;
121118 }
122119
123120 /**
@@ -218,10 +215,7 @@ export class AddonModDataEditPage {
218215 // This is done if entry is updated when editing or creating if not.
219216 if ( ( this . entryId && result . updated ) || ( ! this . entryId && result . newentryid ) ) {
220217
221- this . eventsProvider . trigger ( CoreEventsProvider . FORM_SUBMITTED , {
222- form : this . formElement . nativeElement ,
223- online : result . sent ,
224- } , this . siteId ) ;
218+ this . domUtils . triggerFormSubmittedEvent ( this . formElement . nativeElement , result . sent , this . siteId ) ;
225219
226220 const promises = [ ] ;
227221
0 commit comments