From 53e346d7aea6fb41a13628396cb836c9e5c82997 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Thu, 30 May 2024 16:03:43 +0200 Subject: [PATCH] MOBILE-4470 blog: trigger form submitted event --- src/addons/blog/pages/edit-entry/edit-entry.html | 2 +- src/addons/blog/pages/edit-entry/edit-entry.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/addons/blog/pages/edit-entry/edit-entry.html b/src/addons/blog/pages/edit-entry/edit-entry.html index b9ecd73af..824644ea0 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.html +++ b/src/addons/blog/pages/edit-entry/edit-entry.html @@ -11,7 +11,7 @@ -
+ diff --git a/src/addons/blog/pages/edit-entry/edit-entry.ts b/src/addons/blog/pages/edit-entry/edit-entry.ts index f22dca78a..1e0c9877d 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.ts +++ b/src/addons/blog/pages/edit-entry/edit-entry.ts @@ -22,7 +22,7 @@ import { AddonBlogProvider, AddonBlogPublishState, } from '@addons/blog/services/blog'; -import { Component, OnInit } from '@angular/core'; +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { CoreError } from '@classes/errors/error'; import { CoreCommentsComponentsModule } from '@features/comments/components/components.module'; @@ -40,6 +40,7 @@ import { CoreUtils } from '@services/utils/utils'; import { CoreWSFile } from '@services/ws'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; +import { CoreForms } from '@singletons/form'; @Component({ selector: 'addon-blog-edit-entry', @@ -54,6 +55,8 @@ import { CoreEvents } from '@singletons/events'; }) export class AddonBlogEditEntryPage implements CanLeave, OnInit { + @ViewChild('editEntryForm') formElement!: ElementRef; + publishState = AddonBlogPublishState; form = new FormGroup({ subject: new FormControl('', { nonNullable: true, validators: [Validators.required] }), @@ -316,6 +319,8 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit { await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); } + CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); + return true; } @@ -360,6 +365,7 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit { CoreEvents.trigger(ADDON_BLOG_ENTRY_UPDATED); this.forceLeave = true; + CoreForms.triggerFormSubmittedEvent(this.formElement, true, CoreSites.getCurrentSiteId()); return CoreNavigator.back(); }