MOBILE-4470 blog: trigger form submitted event
parent
05e6bcb0b0
commit
53e346d7ae
|
@ -11,7 +11,7 @@
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<core-loading [hideUntil]="loaded">
|
<core-loading [hideUntil]="loaded">
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form" #editEntryForm>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-input labelPlacement="stacked" formControlName="subject" type="text"
|
<ion-input labelPlacement="stacked" formControlName="subject" type="text"
|
||||||
[placeholder]="'addon.blog.entrytitle' | translate" name="title" [label]="'addon.blog.entrytitle' | translate" />
|
[placeholder]="'addon.blog.entrytitle' | translate" name="title" [label]="'addon.blog.entrytitle' | translate" />
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
AddonBlogProvider,
|
AddonBlogProvider,
|
||||||
AddonBlogPublishState,
|
AddonBlogPublishState,
|
||||||
} from '@addons/blog/services/blog';
|
} 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 { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreCommentsComponentsModule } from '@features/comments/components/components.module';
|
import { CoreCommentsComponentsModule } from '@features/comments/components/components.module';
|
||||||
|
@ -40,6 +40,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
import { CoreForms } from '@singletons/form';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'addon-blog-edit-entry',
|
selector: 'addon-blog-edit-entry',
|
||||||
|
@ -54,6 +55,8 @@ import { CoreEvents } from '@singletons/events';
|
||||||
})
|
})
|
||||||
export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
||||||
|
|
||||||
|
@ViewChild('editEntryForm') formElement!: ElementRef;
|
||||||
|
|
||||||
publishState = AddonBlogPublishState;
|
publishState = AddonBlogPublishState;
|
||||||
form = new FormGroup({
|
form = new FormGroup({
|
||||||
subject: new FormControl<string>('', { nonNullable: true, validators: [Validators.required] }),
|
subject: new FormControl<string>('', { nonNullable: true, validators: [Validators.required] }),
|
||||||
|
@ -316,6 +319,8 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
||||||
await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit'));
|
await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +365,7 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
||||||
|
|
||||||
CoreEvents.trigger(ADDON_BLOG_ENTRY_UPDATED);
|
CoreEvents.trigger(ADDON_BLOG_ENTRY_UPDATED);
|
||||||
this.forceLeave = true;
|
this.forceLeave = true;
|
||||||
|
CoreForms.triggerFormSubmittedEvent(this.formElement, true, CoreSites.getCurrentSiteId());
|
||||||
|
|
||||||
return CoreNavigator.back();
|
return CoreNavigator.back();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue