MOBILE-3157 utils: Add shortcut for delete confirmations
parent
32f320407d
commit
e3e559da6f
|
@ -347,10 +347,7 @@ export class AddonCalendarEventPage implements OnDestroy {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const message = this.translate.instant('core.areyousure');
|
||||
const okText = this.translate.instant('core.delete');
|
||||
|
||||
this.domUtils.showConfirm(message, undefined, okText).then(() => {
|
||||
this.domUtils.showDeleteConfirm().then(() => {
|
||||
const modal = this.domUtils.showModalLoading('core.deleting', true);
|
||||
this.calendarProvider.deleteEventReminder(id).then(() => {
|
||||
this.calendarProvider.getEventReminders(this.eventId).then((reminders) => {
|
||||
|
|
|
@ -1276,7 +1276,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
|||
deleteConversation(done?: () => void): void {
|
||||
const confirmMessage = 'addon.messages.' + (this.isSelf ? 'deleteallselfconfirm' : 'deleteallconfirm');
|
||||
|
||||
this.domUtils.showConfirm(this.translate.instant(confirmMessage)).then(() => {
|
||||
this.domUtils.showDeleteConfirm(confirmMessage).then(() => {
|
||||
this.deleteIcon = 'spinner';
|
||||
|
||||
return this.messagesProvider.deleteConversation(this.conversation.id).then(() => {
|
||||
|
|
|
@ -372,7 +372,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo
|
|||
* Delete options selected.
|
||||
*/
|
||||
delete(): void {
|
||||
this.domUtils.showConfirm(this.translate.instant('core.areyousure')).then(() => {
|
||||
this.domUtils.showDeleteConfirm().then(() => {
|
||||
const modal = this.domUtils.showModalLoading('core.sending', true);
|
||||
this.choiceProvider.deleteResponses(this.choice.id, this.choice.name, this.courseId).then(() => {
|
||||
this.domUtils.scrollToTop(this.content);
|
||||
|
|
|
@ -645,7 +645,7 @@ export class AddonModDataHelperProvider {
|
|||
showDeleteEntryModal(dataId: number, entryId: number, courseId?: number, siteId?: string): void {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
this.domUtils.showConfirm(this.translate.instant('addon.mod_data.confirmdeleterecord')).then(() => {
|
||||
this.domUtils.showDeleteConfirm('addon.mod_data.confirmdeleterecord').then(() => {
|
||||
const modal = this.domUtils.showModalLoading();
|
||||
|
||||
return this.getActivityCourseIdIfNotSet(dataId, courseId, siteId).then((courseId) => {
|
||||
|
|
|
@ -461,7 +461,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy {
|
|||
* Perform the submission delete action.
|
||||
*/
|
||||
deleteSubmission(): void {
|
||||
this.domUtils.showConfirm(this.translate.instant('addon.mod_workshop.submissiondeleteconfirm')).then(() => {
|
||||
this.domUtils.showDeleteConfirm('addon.mod_workshop.submissiondeleteconfirm').then(() => {
|
||||
const modal = this.domUtils.showModalLoading('core.deleting', true);
|
||||
let success = false;
|
||||
this.workshopProvider.deleteSubmission(this.workshopId, this.submissionId, this.courseId).then(() => {
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { Content, ModalController } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
|
@ -55,8 +54,7 @@ export class AddonNotesListComponent implements OnInit, OnDestroy {
|
|||
constructor(private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider,
|
||||
sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider, private modalCtrl: ModalController,
|
||||
private notesProvider: AddonNotesProvider, private notesSync: AddonNotesSyncProvider,
|
||||
private userProvider: CoreUserProvider, private translate: TranslateService,
|
||||
private notesOffline: AddonNotesOfflineProvider) {
|
||||
private userProvider: CoreUserProvider, private notesOffline: AddonNotesOfflineProvider) {
|
||||
// Refresh data if notes are synchronized automatically.
|
||||
this.syncObserver = eventsProvider.on(AddonNotesSyncProvider.AUTO_SYNCED, (data) => {
|
||||
if (data.courseId == this.courseId) {
|
||||
|
@ -211,7 +209,7 @@ export class AddonNotesListComponent implements OnInit, OnDestroy {
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
this.domUtils.showConfirm(this.translate.instant('addon.notes.deleteconfirm')).then(() => {
|
||||
this.domUtils.showDeleteConfirm('addon.notes.deleteconfirm').then(() => {
|
||||
this.notesProvider.deleteNote(note, this.courseId).then(() => {
|
||||
this.showDelete = false;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ export class CoreAttachmentsComponent implements OnInit {
|
|||
let promise;
|
||||
|
||||
if (askConfirm) {
|
||||
promise = this.domUtils.showConfirm(this.translate.instant('core.confirmdeletefile'));
|
||||
promise = this.domUtils.showDeleteConfirm('core.confirmdeletefile');
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ export class CoreLocalFileComponent implements OnInit {
|
|||
e.stopPropagation();
|
||||
|
||||
// Ask confirmation.
|
||||
this.domUtils.showConfirm(this.translate.instant('core.confirmdeletefile')).then(() => {
|
||||
const modal = this.domUtils.showModalLoading();
|
||||
this.domUtils.showDeleteConfirm('core.confirmdeletefile').then(() => {
|
||||
const modal = this.domUtils.showModalLoading('core.deleting', true);
|
||||
|
||||
return this.fileProvider.removeFile(this.relativePath).then(() => {
|
||||
this.onDelete.emit();
|
||||
|
|
|
@ -324,8 +324,8 @@ export class CoreCommentsViewerPage implements OnDestroy {
|
|||
comment.itemid = this.itemId;
|
||||
comment.area = this.area;
|
||||
|
||||
this.domUtils.showConfirm(this.translate.instant('core.comments.deletecommentbyon', {$a:
|
||||
{ user: comment.fullname || '', time: time } })).then(() => {
|
||||
this.domUtils.showDeleteConfirm('core.comments.deletecommentbyon', {$a:
|
||||
{ user: comment.fullname || '', time: time } }).then(() => {
|
||||
this.commentsProvider.deleteComment(comment).then(() => {
|
||||
this.showDelete = false;
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ export class CoreCourseHelperProvider {
|
|||
* @return Promise resolved when done.
|
||||
*/
|
||||
confirmAndRemoveFiles(module: any, courseId: number): Promise<any> {
|
||||
return this.domUtils.showConfirm(this.translate.instant('core.course.confirmdeletemodulefiles')).then(() => {
|
||||
return this.domUtils.showDeleteConfirm('core.course.confirmdeletemodulefiles').then(() => {
|
||||
return this.prefetchDelegate.removeModuleFiles(module, courseId);
|
||||
}).catch((error) => {
|
||||
if (error) {
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { Component } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
|
@ -40,7 +39,6 @@ export class CoreLoginSitesPage {
|
|||
private sitesProvider: CoreSitesProvider,
|
||||
private loginHelper: CoreLoginHelperProvider,
|
||||
logger: CoreLoggerProvider,
|
||||
private translate: TranslateService,
|
||||
private pushNotificationsProvider: CorePushNotificationsProvider) {
|
||||
this.logger = logger.getInstance('CoreLoginSitesPage');
|
||||
}
|
||||
|
@ -92,7 +90,7 @@ export class CoreLoginSitesPage {
|
|||
|
||||
this.filterProvider.formatText(siteName, {clean: true, singleLine: true, filter: false}, [], site.id).then((siteName) => {
|
||||
|
||||
this.domUtils.showConfirm(this.translate.instant('core.login.confirmdeletesite', { sitename: siteName })).then(() => {
|
||||
this.domUtils.showDeleteConfirm('core.login.confirmdeletesite', { sitename: siteName }).then(() => {
|
||||
this.sitesProvider.deleteSite(site.id).then(() => {
|
||||
this.sites.splice(index, 1);
|
||||
this.showDelete = false;
|
||||
|
|
|
@ -1194,6 +1194,19 @@ export class CoreDomUtilsProvider {
|
|||
return this.showAlert(title, message, buttonText, autocloseTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for a delete confirmation modal.
|
||||
*
|
||||
* @param translateMessage String key to show in the modal body translated. Default: 'core.areyousure'.
|
||||
* @param translateArgs Arguments to pass to translate if necessary.
|
||||
* @param options More options. See https://ionicframework.com/docs/v3/api/components/alert/AlertController/
|
||||
* @return Promise resolved if the user confirms and rejected with a canceled error if he cancels.
|
||||
*/
|
||||
showDeleteConfirm(translateMessage: string = 'core.areyousure', translateArgs: any = {}, options?: any): Promise<any> {
|
||||
return this.showConfirm(this.translate.instant(translateMessage, translateArgs), undefined,
|
||||
this.translate.instant('core.delete'), undefined, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a confirm modal.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue