commit
683734e13d
|
@ -70,16 +70,16 @@
|
|||
<ion-item text-wrap *ngIf="canEdit">
|
||||
<div *ngIf="!unsupportedEditPlugins.length && !showErrorStatementEdit">
|
||||
<!-- If has offline data, show edit. -->
|
||||
<a ion-button block color="primary" *ngIf="hasOffline" (click)="goToEdit()">{{ 'addon.mod_assign.editsubmission' | translate }}</a>
|
||||
<a ion-button block text-wrap color="primary" *ngIf="hasOffline" (click)="goToEdit()">{{ 'addon.mod_assign.editsubmission' | translate }}</a>
|
||||
<!-- If no submission or is new, show add submission. -->
|
||||
<a ion-button block color="primary" *ngIf="!hasOffline && (!userSubmission || !userSubmission.status || userSubmission.status == statusNew)" (click)="goToEdit()">{{ 'addon.mod_assign.addsubmission' | translate }}</a>
|
||||
<a ion-button block text-wrap color="primary" *ngIf="!hasOffline && (!userSubmission || !userSubmission.status || userSubmission.status == statusNew)" (click)="goToEdit()">{{ 'addon.mod_assign.addsubmission' | translate }}</a>
|
||||
<!-- If reopened, show addfromprevious and addnewattempt. -->
|
||||
<ng-container *ngIf="!hasOffline && userSubmission && userSubmission.status == statusReopened">
|
||||
<a ion-button block color="primary" (click)="copyPrevious()">{{ 'addon.mod_assign.addnewattemptfromprevious' | translate }}</a>
|
||||
<a ion-button block color="primary" (click)="goToEdit()">{{ 'addon.mod_assign.addnewattempt' | translate }}</a>
|
||||
<a ion-button block text-wrap color="primary" (click)="copyPrevious()">{{ 'addon.mod_assign.addnewattemptfromprevious' | translate }}</a>
|
||||
<a ion-button block text-wrap color="primary" (click)="goToEdit()">{{ 'addon.mod_assign.addnewattempt' | translate }}</a>
|
||||
</ng-container>
|
||||
<!-- Else show editsubmission. -->
|
||||
<a ion-button block color="primary" *ngIf="!hasOffline && userSubmission && userSubmission.status && userSubmission.status != statusNew && userSubmission.status != statusReopened" (click)="goToEdit()">{{ 'addon.mod_assign.editsubmission' | translate }}</a>
|
||||
<a ion-button block text-wrap color="primary" *ngIf="!hasOffline && userSubmission && userSubmission.status && userSubmission.status != statusNew && userSubmission.status != statusReopened" (click)="goToEdit()">{{ 'addon.mod_assign.editsubmission' | translate }}</a>
|
||||
</div>
|
||||
<div *ngIf="unsupportedEditPlugins && unsupportedEditPlugins.length && !showErrorStatementEdit">
|
||||
<p class="core-danger-item">{{ 'addon.mod_assign.erroreditpluginsnotsupported' | translate }}</p>
|
||||
|
@ -99,7 +99,7 @@
|
|||
</ion-item>
|
||||
<!-- Submit button. -->
|
||||
<ion-item text-wrap *ngIf="!showErrorStatementSubmit">
|
||||
<a ion-button block (click)="submitForGrading(submitModel.submissionStatement)">{{ 'addon.mod_assign.submitassignment' | translate }}</a>
|
||||
<a ion-button block text-wrap (click)="submitForGrading(submitModel.submissionStatement)">{{ 'addon.mod_assign.submitassignment' | translate }}</a>
|
||||
<p>{{ 'addon.mod_assign.submitassignment_help' | translate }}</p>
|
||||
</ion-item>
|
||||
<!-- Error because we lack submissions statement. -->
|
||||
|
|
|
@ -9,10 +9,13 @@
|
|||
</ion-refresher>
|
||||
<core-loading [hideUntil]="notificationsLoaded">
|
||||
<div padding *ngIf="canMarkAllNotificationsAsRead">
|
||||
<button ion-button block (click)="markAllNotificationsAsRead()" color="light" icon-start>
|
||||
<button ion-button block (click)="markAllNotificationsAsRead()" color="light" icon-start *ngIf="!loadingMarkAllNotificationsAsRead">
|
||||
<core-icon name="fa-check"></core-icon>
|
||||
{{ 'addon.notifications.markallread' | translate }}
|
||||
</button>
|
||||
<button ion-button block color="light" icon-start *ngIf="loadingMarkAllNotificationsAsRead">
|
||||
<ion-spinner></ion-spinner>
|
||||
</button>
|
||||
</div>
|
||||
<ion-card *ngFor="let notification of notifications">
|
||||
<ion-item>
|
||||
|
|
|
@ -37,6 +37,7 @@ export class AddonNotificationsListPage {
|
|||
notificationsLoaded = false;
|
||||
canLoadMore = false;
|
||||
canMarkAllNotificationsAsRead = false;
|
||||
loadingMarkAllNotificationsAsRead = false;
|
||||
|
||||
protected readCount = 0;
|
||||
protected unreadCount = 0;
|
||||
|
@ -118,15 +119,6 @@ export class AddonNotificationsListPage {
|
|||
this.canLoadMore = true;
|
||||
}
|
||||
|
||||
// Check if mark all notifications as read is enabled and there are some to read.
|
||||
if (this.notificationsProvider.isMarkAllNotificationsAsReadEnabled()) {
|
||||
promises.push(this.notificationsProvider.getUnreadNotificationsCount().then((unread) => {
|
||||
this.canMarkAllNotificationsAsRead = unread > 0;
|
||||
}));
|
||||
} else {
|
||||
this.canMarkAllNotificationsAsRead = false;
|
||||
}
|
||||
|
||||
return Promise.all(promises).then(() => {
|
||||
// Mark retrieved notifications as read if they are not.
|
||||
this.markNotificationsAsRead(unread);
|
||||
|
@ -141,15 +133,17 @@ export class AddonNotificationsListPage {
|
|||
* Mark all notifications as read.
|
||||
*/
|
||||
markAllNotificationsAsRead(): void {
|
||||
this.notificationsProvider.markAllNotificationsAsRead().then(() => {
|
||||
this.loadingMarkAllNotificationsAsRead = true;
|
||||
this.notificationsProvider.markAllNotificationsAsRead().catch(() => {
|
||||
// Omit failure.
|
||||
}).finally(() => {
|
||||
const siteId = this.sitesProvider.getCurrentSiteId();
|
||||
this.eventsProvider.trigger(AddonNotificationsProvider.READ_CHANGED_EVENT, null, siteId);
|
||||
|
||||
this.notificationsProvider.getUnreadNotificationsCount().then((unread) => {
|
||||
this.canMarkAllNotificationsAsRead = unread > 0;
|
||||
this.loadingMarkAllNotificationsAsRead = false;
|
||||
});
|
||||
}).catch(() => {
|
||||
// Omit failure.
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -159,12 +153,14 @@ export class AddonNotificationsListPage {
|
|||
* @param {any[]} notifications Array of notification objects.
|
||||
*/
|
||||
protected markNotificationsAsRead(notifications: any[]): void {
|
||||
let promise;
|
||||
|
||||
if (notifications.length > 0) {
|
||||
const promises = notifications.map((notification) => {
|
||||
return this.notificationsProvider.markNotificationRead(notification.id);
|
||||
});
|
||||
|
||||
Promise.all(promises).catch(() => {
|
||||
promise = Promise.all(promises).catch(() => {
|
||||
// Ignore errors.
|
||||
}).finally(() => {
|
||||
this.notificationsProvider.invalidateNotificationsList().finally(() => {
|
||||
|
@ -172,7 +168,21 @@ export class AddonNotificationsListPage {
|
|||
this.eventsProvider.trigger(AddonNotificationsProvider.READ_CHANGED_EVENT, null, siteId);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
promise = Promise.resolve();
|
||||
}
|
||||
|
||||
promise.finally(() => {
|
||||
// Check if mark all notifications as read is enabled and there are some to read.
|
||||
if (this.notificationsProvider.isMarkAllNotificationsAsReadEnabled()) {
|
||||
this.loadingMarkAllNotificationsAsRead = true;
|
||||
return this.notificationsProvider.getUnreadNotificationsCount().then((unread) => {
|
||||
this.canMarkAllNotificationsAsRead = unread > 0;
|
||||
this.loadingMarkAllNotificationsAsRead = false;
|
||||
});
|
||||
}
|
||||
this.canMarkAllNotificationsAsRead = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue