MOBILE-3323 editor: Trigger action event in missing forms
parent
b86f5c054a
commit
e62f5b7409
|
@ -57,10 +57,10 @@
|
|||
</ion-item>
|
||||
</div>
|
||||
|
||||
<ion-list [id]="'addon-forum-reply-edit-form-' + uniqueId" *ngIf="(post.id && !replyData.isEditing && replyData.replyingTo == post.id) || (!post.id && replyData.isEditing && replyData.replyingTo == post.parent)">
|
||||
<form ion-list [id]="'addon-forum-reply-edit-form-' + uniqueId" *ngIf="(post.id && !replyData.isEditing && replyData.replyingTo == post.id) || (!post.id && replyData.isEditing && replyData.replyingTo == post.parent)" #replyFormEl>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.subject' | translate }}</ion-label>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="replyData.subject"></ion-input>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="replyData.subject" name="subject"></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.message' | translate }}</ion-label>
|
||||
|
@ -68,7 +68,7 @@
|
|||
</ion-item>
|
||||
<ion-item text-wrap *ngIf="accessInfo.canpostprivatereply">
|
||||
<ion-label>{{ 'addon.mod_forum.privatereply' | translate }}</ion-label>
|
||||
<ion-checkbox item-end [(ngModel)]="replyData.isprivatereply"></ion-checkbox>
|
||||
<ion-checkbox item-end [(ngModel)]="replyData.isprivatereply" name="isprivatereply"></ion-checkbox>
|
||||
</ion-item>
|
||||
<ion-item-divider text-wrap (click)="toggleAdvanced()" class="core-expandable">
|
||||
<core-icon *ngIf="!advanced" name="fa-caret-right" item-start></core-icon>
|
||||
|
@ -88,5 +88,5 @@
|
|||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ion-list>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, Input, Output, Optional, EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component, Input, Output, Optional, EventEmitter, OnInit, OnDestroy, ViewChild, ElementRef, OnChanges, SimpleChange
|
||||
} from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { Content, PopoverController, ModalController } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
@ -37,7 +39,7 @@ import { AddonForumPostOptionsMenuComponent } from '../post-options-menu/post-op
|
|||
selector: 'addon-mod-forum-post',
|
||||
templateUrl: 'addon-mod-forum-post.html',
|
||||
})
|
||||
export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
||||
export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges {
|
||||
@Input() post: any; // Post.
|
||||
@Input() courseId: number; // Post's course ID.
|
||||
@Input() discussionId: number; // Post's' discussion ID.
|
||||
|
@ -50,8 +52,11 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
|||
@Input() accessInfo: any; // Forum access information.
|
||||
@Input() parentSubject?: string; // Subject of parent post.
|
||||
@Input() ratingInfo?: CoreRatingInfo; // Rating info item.
|
||||
@Input() leavingPage?: boolean; // Whether the page that contains this post is being left and will be destroyed.
|
||||
@Output() onPostChange: EventEmitter<void>; // Event emitted when a reply is posted or modified.
|
||||
|
||||
@ViewChild('replyFormEl') formElement: ElementRef;
|
||||
|
||||
messageControl = new FormControl();
|
||||
|
||||
uniqueId: string;
|
||||
|
@ -100,6 +105,16 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
|||
(this.forumProvider.isDeletePostAvailable() || this.forumProvider.isUpdatePostAvailable()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect changes on input properties.
|
||||
*/
|
||||
ngOnChanges(changes: {[name: string]: SimpleChange}): void {
|
||||
if (changes.leavingPage && this.leavingPage && this.formElement) {
|
||||
// Download all courses is enabled now, initialize it.
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an online post.
|
||||
*/
|
||||
|
@ -408,6 +423,8 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
|||
|
||||
this.onPostChange.emit();
|
||||
|
||||
this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, sent, this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
if (this.syncId) {
|
||||
this.syncProvider.unblockOperation(AddonModForumProvider.COMPONENT, this.syncId);
|
||||
}
|
||||
|
@ -426,6 +443,8 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
|||
// Reset data.
|
||||
this.setReplyFormData();
|
||||
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
if (this.syncId) {
|
||||
this.syncProvider.unblockOperation(AddonModForumProvider.COMPONENT, this.syncId);
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
</ion-card>
|
||||
|
||||
<div *ngIf="discussion" margin-bottom class="highlight">
|
||||
<addon-mod-forum-post [post]="discussion" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
<addon-mod-forum-post [post]="discussion" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" [leavingPage]="leavingPage" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
</div>
|
||||
|
||||
<ion-card *ngIf="sort != 'nested'">
|
||||
<ng-container *ngFor="let post of posts; first as first">
|
||||
<ion-item-divider *ngIf="!first"></ion-item-divider>
|
||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" [leavingPage]="leavingPage" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
</ng-container>
|
||||
</ion-card>
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
<ng-template #nestedPosts let-post="post">
|
||||
<ion-card>
|
||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" [leavingPage]="leavingPage" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||
</ion-card>
|
||||
<div padding-left *ngIf="post.children.length && post.children[0].subject">
|
||||
<ng-container *ngFor="let child of post.children">
|
||||
|
|
|
@ -81,6 +81,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
|||
cmId: number;
|
||||
canPin = false;
|
||||
availabilityMessage: string;
|
||||
leavingPage = false;
|
||||
|
||||
protected forumId: number;
|
||||
protected postId: number;
|
||||
|
@ -251,20 +252,17 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
|||
*
|
||||
* @return Resolved if we can leave it, rejected if not.
|
||||
*/
|
||||
ionViewCanLeave(): boolean | Promise<void> {
|
||||
let promise: any;
|
||||
async ionViewCanLeave(): Promise<void> {
|
||||
|
||||
if (this.forumHelper.hasPostDataChanged(this.replyData, this.originalData)) {
|
||||
// Show confirmation if some data has been modified.
|
||||
promise = this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
await this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
}
|
||||
|
||||
return promise.then(() => {
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.replyData.files);
|
||||
});
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.replyData.files);
|
||||
|
||||
this.leavingPage = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<form ion-list #editFormEl>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.subject' | translate }}</ion-label>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="replyData.subject"></ion-input>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="replyData.subject" name="subject"></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.message' | translate }}</ion-label>
|
||||
|
@ -36,5 +36,5 @@
|
|||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ion-list>
|
||||
</form>
|
||||
</ion-content>
|
|
@ -12,11 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ViewChild, ElementRef } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { IonicPage, ViewController, NavParams } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { AddonModForumProvider } from '../../providers/forum';
|
||||
import { AddonModForumHelperProvider } from '../../providers/helper';
|
||||
|
@ -30,6 +31,8 @@ import { AddonModForumHelperProvider } from '../../providers/helper';
|
|||
templateUrl: 'addon-mod-forum-edit-post.html',
|
||||
})
|
||||
export class AddonModForumEditPostPage {
|
||||
@ViewChild('editFormEl') formElement: ElementRef;
|
||||
|
||||
component: string; // Component this post belong to.
|
||||
componentId: number; // Component ID.
|
||||
forum: any; // The forum the post belongs to. Required for attachments and offline posts.
|
||||
|
@ -48,7 +51,8 @@ export class AddonModForumEditPostPage {
|
|||
protected domUtils: CoreDomUtilsProvider,
|
||||
protected uploaderProvider: CoreFileUploaderProvider,
|
||||
protected forumHelper: AddonModForumHelperProvider,
|
||||
protected translate: TranslateService) {
|
||||
protected translate: TranslateService,
|
||||
protected sitesProvider: CoreSitesProvider) {
|
||||
|
||||
const post = params.get('post');
|
||||
this.component = params.get('component');
|
||||
|
@ -114,7 +118,13 @@ export class AddonModForumEditPostPage {
|
|||
*
|
||||
* @param data Data to return to the page.
|
||||
*/
|
||||
closeModal(data: any): void {
|
||||
closeModal(data: any, ): void {
|
||||
if (data) {
|
||||
this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, false, this.sitesProvider.getCurrentSiteId());
|
||||
} else {
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
}
|
||||
|
||||
this.viewCtrl.dismiss(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
</ion-refresher>
|
||||
|
||||
<core-loading [hideUntil]="groupsLoaded">
|
||||
<ion-list *ngIf="showForm">
|
||||
<form ion-list *ngIf="showForm" #newDiscFormEl>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.subject' | translate }}</ion-label>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="newDiscussion.subject"></ion-input>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_forum.subject' | translate" [(ngModel)]="newDiscussion.subject" name="subject"></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_forum.message' | translate }}</ion-label>
|
||||
|
@ -29,21 +29,21 @@
|
|||
<ng-container *ngIf="advanced">
|
||||
<ion-item *ngIf="showGroups && groupIds.length > 1 && accessInfo.cancanposttomygroups">
|
||||
<ion-label>{{ 'addon.mod_forum.posttomygroups' | translate }}</ion-label>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.postToAllGroups"></ion-toggle>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.postToAllGroups" name="postallgroups"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item *ngIf="showGroups">
|
||||
<ion-label id="addon-mod-forum-groupslabel">{{ 'addon.mod_forum.group' | translate }}</ion-label>
|
||||
<ion-select [(ngModel)]="newDiscussion.groupId" [disabled]="newDiscussion.postToAllGroups" aria-labelledby="addon-mod-forum-groupslabel" interface="action-sheet">
|
||||
<ion-select [(ngModel)]="newDiscussion.groupId" [disabled]="newDiscussion.postToAllGroups" aria-labelledby="addon-mod-forum-groupslabel" interface="action-sheet" name="groupid">
|
||||
<ion-option *ngFor="let group of groups" [value]="group.id">{{ group.name }}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>{{ 'addon.mod_forum.discussionsubscription' | translate }}</ion-label>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.subscribe"></ion-toggle>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.subscribe" name="subscribe"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item *ngIf="canPin">
|
||||
<ion-label>{{ 'addon.mod_forum.discussionpinned' | translate }}</ion-label>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.pin"></ion-toggle>
|
||||
<ion-toggle [(ngModel)]="newDiscussion.pin" name="pin"></ion-toggle>
|
||||
</ion-item>
|
||||
<core-attachments *ngIf="canCreateAttachments && forum && forum.maxattachments > 0" [files]="newDiscussion.files" [maxSize]="forum.maxbytes" [maxSubmissions]="forum.maxattachments" [component]="component" [componentId]="forum.cmid" [allowOffline]="true"></core-attachments>
|
||||
</ng-container>
|
||||
|
@ -57,6 +57,6 @@
|
|||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</form>
|
||||
</core-loading>
|
||||
</ion-content>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnDestroy, Optional, ViewChild } from '@angular/core';
|
||||
import { Component, OnDestroy, Optional, ViewChild, ElementRef } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
@ -41,6 +41,7 @@ import { AddonModForumSyncProvider } from '../../providers/sync';
|
|||
})
|
||||
export class AddonModForumNewDiscussionPage implements OnDestroy {
|
||||
|
||||
@ViewChild('newDiscFormEl') formElement: ElementRef;
|
||||
@ViewChild(CoreEditorRichTextEditorComponent) messageEditor: CoreEditorRichTextEditorComponent;
|
||||
|
||||
component = AddonModForumProvider.COMPONENT;
|
||||
|
@ -74,6 +75,7 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
protected syncObserver: any;
|
||||
protected isDestroyed = false;
|
||||
protected originalData: any;
|
||||
protected forceLeave = false;
|
||||
|
||||
constructor(navParams: NavParams,
|
||||
private navCtrl: NavController,
|
||||
|
@ -408,6 +410,7 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
this.newDiscussion.postToAllGroups = false;
|
||||
this.messageEditor.clearText();
|
||||
this.originalData = this.utils.clone(this.newDiscussion);
|
||||
this.forceLeave = true; // Avoid asking for confirmation.
|
||||
|
||||
// Trigger view event, to highlight the current opened discussion in the split view.
|
||||
this.eventsProvider.trigger(AddonModForumProvider.VIEW_DISCUSSION_EVENT, {
|
||||
|
@ -415,7 +418,7 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
discussion: 0
|
||||
}, this.sitesProvider.getCurrentSiteId());
|
||||
} else {
|
||||
this.originalData = null; // Avoid asking for confirmation.
|
||||
this.forceLeave = true; // Avoid asking for confirmation.
|
||||
this.navCtrl.pop();
|
||||
}
|
||||
}
|
||||
|
@ -477,6 +480,9 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
this.domUtils.showErrorModalDefault(null, 'addon.mod_forum.errorposttoallgroups', true);
|
||||
}
|
||||
|
||||
this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, !!discussionIds,
|
||||
this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
this.returnToDiscussions(discussionIds, discTimecreated);
|
||||
}).catch((message) => {
|
||||
this.domUtils.showErrorModalDefault(message, 'addon.mod_forum.cannotcreatediscussion', true);
|
||||
|
@ -498,6 +504,8 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
}));
|
||||
|
||||
return Promise.all(promises).then(() => {
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
this.returnToDiscussions();
|
||||
});
|
||||
}).catch(() => {
|
||||
|
@ -517,20 +525,22 @@ export class AddonModForumNewDiscussionPage implements OnDestroy {
|
|||
*
|
||||
* @return Resolved if we can leave it, rejected if not.
|
||||
*/
|
||||
ionViewCanLeave(): boolean | Promise<void> {
|
||||
let promise: any;
|
||||
async ionViewCanLeave(): Promise<void> {
|
||||
if (this.forceLeave) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.forumHelper.hasPostDataChanged(this.newDiscussion, this.originalData)) {
|
||||
// Show confirmation if some data has been modified.
|
||||
promise = this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
await this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
}
|
||||
|
||||
return promise.then(() => {
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.newDiscussion.files);
|
||||
});
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.newDiscussion.files);
|
||||
|
||||
if (this.formElement) {
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,7 @@ export class AddonModForumProvider {
|
|||
static VIEW_DISCUSSION_EVENT = 'addon_mod_forum_view_discussion';
|
||||
static CHANGE_DISCUSSION_EVENT = 'addon_mod_forum_change_discussion_status';
|
||||
static MARK_READ_EVENT = 'addon_mod_forum_mark_read';
|
||||
static LEAVING_POSTS_PAGE = 'addon_mod_forum_leaving_posts_page';
|
||||
|
||||
static PREFERENCE_SORTORDER = 'forum_discussionlistsortorder';
|
||||
static SORTORDER_LASTPOST_DESC = 1;
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
</ion-header>
|
||||
<ion-content>
|
||||
<core-loading [hideUntil]="loaded">
|
||||
<ion-list>
|
||||
<form ion-list #editFormEl>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_glossary.concept' | translate }}</ion-label>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_glossary.concept' | translate" [(ngModel)]="entry.concept"></ion-input>
|
||||
<ion-input type="text" [placeholder]="'addon.mod_glossary.concept' | translate" [(ngModel)]="entry.concept" name="concept"></ion-input>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label stacked>{{ 'addon.mod_glossary.definition' | translate }}</ion-label>
|
||||
|
@ -19,13 +19,13 @@
|
|||
</ion-item>
|
||||
<ion-item *ngIf="categories.length > 0">
|
||||
<ion-label stacked id="addon-mod-glossary-categories-label">{{ 'addon.mod_glossary.categories' | translate }}</ion-label>
|
||||
<ion-select [(ngModel)]="options.categories" multiple="true" aria-labelledby="addon-mod-glossary-categories-label" interface="action-sheet" [placeholder]="'addon.mod_glossary.categories' | translate">
|
||||
<ion-select [(ngModel)]="options.categories" multiple="true" aria-labelledby="addon-mod-glossary-categories-label" interface="action-sheet" [placeholder]="'addon.mod_glossary.categories' | translate" name="categories">
|
||||
<ion-option *ngFor="let category of categories" [value]="category.id">{{ category.name }}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label stacked id="addon-mod-glossary-aliases-label">{{ 'addon.mod_glossary.aliases' | translate }}</ion-label>
|
||||
<ion-textarea [(ngModel)]="options.aliases" rows="1" core-auto-rows aria-labelledby="addon-mod-glossary-aliases-label"></ion-textarea>
|
||||
<ion-textarea [(ngModel)]="options.aliases" rows="1" core-auto-rows aria-labelledby="addon-mod-glossary-aliases-label" name="aliases"></ion-textarea>
|
||||
</ion-item>
|
||||
<ion-item-divider>{{ 'addon.mod_glossary.attachment' | translate }}</ion-item-divider>
|
||||
<core-attachments [files]="attachments" [component]="component" [componentId]="glossary.cmid" [allowOffline]="true"></core-attachments>
|
||||
|
@ -33,17 +33,17 @@
|
|||
<ion-item-divider>{{ 'addon.mod_glossary.linking' | translate }}</ion-item-divider>
|
||||
<ion-item text-wrap>
|
||||
<ion-label>{{ 'addon.mod_glossary.entryusedynalink' | translate }}</ion-label>
|
||||
<ion-toggle [(ngModel)]="options.usedynalink"></ion-toggle>
|
||||
<ion-toggle [(ngModel)]="options.usedynalink" name="usedynalink"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item text-wrap>
|
||||
<ion-label>{{ 'addon.mod_glossary.casesensitive' | translate }}</ion-label>
|
||||
<ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.casesensitive"></ion-toggle>
|
||||
<ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.casesensitive" name="casesensitive"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item text-wrap>
|
||||
<ion-label>{{ 'addon.mod_glossary.fullmatch' | translate }}</ion-label>
|
||||
<ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.fullmatch"></ion-toggle>
|
||||
<ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.fullmatch" name="fullmatch"></ion-toggle>
|
||||
</ion-item>
|
||||
</ng-container>
|
||||
</ion-list>
|
||||
</form>
|
||||
</core-loading>
|
||||
</ion-content>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
@ -34,6 +34,8 @@ import { AddonModGlossaryHelperProvider } from '../../providers/helper';
|
|||
templateUrl: 'edit.html',
|
||||
})
|
||||
export class AddonModGlossaryEditPage implements OnInit {
|
||||
@ViewChild('editFormEl') formElement: ElementRef;
|
||||
|
||||
component = AddonModGlossaryProvider.COMPONENT;
|
||||
loaded = false;
|
||||
entry = {
|
||||
|
@ -145,20 +147,20 @@ export class AddonModGlossaryEditPage implements OnInit {
|
|||
*
|
||||
* @return Resolved if we can leave it, rejected if not.
|
||||
*/
|
||||
ionViewCanLeave(): boolean | Promise<void> {
|
||||
let promise: any;
|
||||
|
||||
if (!this.saved && this.glossaryHelper.hasEntryDataChanged(this.entry, this.attachments, this.originalData)) {
|
||||
// Show confirmation if some data has been modified.
|
||||
promise = this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
async ionViewCanLeave(): Promise<void> {
|
||||
if (this.saved) {
|
||||
return;
|
||||
}
|
||||
|
||||
return promise.then(() => {
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.attachments);
|
||||
});
|
||||
if (this.glossaryHelper.hasEntryDataChanged(this.entry, this.attachments, this.originalData)) {
|
||||
// Show confirmation if some data has been modified.
|
||||
await this.domUtils.showConfirm(this.translate.instant('core.confirmcanceledit'));
|
||||
}
|
||||
|
||||
// Delete the local files from the tmp folder.
|
||||
this.uploaderProvider.clearTmpFiles(this.attachments);
|
||||
|
||||
this.domUtils.triggerFormCancelledEvent(this.formElement.nativeElement, this.sitesProvider.getCurrentSiteId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,6 +253,9 @@ export class AddonModGlossaryEditPage implements OnInit {
|
|||
};
|
||||
this.eventsProvider.trigger(AddonModGlossaryProvider.ADD_ENTRY_EVENT, data, this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
this.domUtils.triggerFormSubmittedEvent(this.formElement.nativeElement, !!entryId,
|
||||
this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
this.saved = true;
|
||||
this.navCtrl.pop();
|
||||
}).catch((error) => {
|
||||
|
|
Loading…
Reference in New Issue