MOBILE-3636 assign: Minor fixes

main
Pau Ferrer Ocaña 2021-02-24 09:30:00 +01:00
parent 4cf2a40ca7
commit cf7f4b4951
14 changed files with 16 additions and 49 deletions

View File

@ -13,10 +13,6 @@
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreSharedModule } from '@/core/shared.module'; import { CoreSharedModule } from '@/core/shared.module';
import { CoreCourseComponentsModule } from '@features/course/components/components.module'; import { CoreCourseComponentsModule } from '@features/course/components/components.module';
@ -35,10 +31,6 @@ import { AddonModAssignEditFeedbackModalComponent } from './edit-feedback-modal/
AddonModAssignEditFeedbackModalComponent, AddonModAssignEditFeedbackModalComponent,
], ],
imports: [ imports: [
CommonModule,
IonicModule,
TranslateModule.forChild(),
FormsModule,
CoreSharedModule, CoreSharedModule,
CoreCourseComponentsModule, CoreCourseComponentsModule,
], ],

View File

@ -104,20 +104,11 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
* *
* @return Promise resolved with the input data, rejected if cancelled. * @return Promise resolved with the input data, rejected if cancelled.
*/ */
editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> { async editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> {
if (!this.canEdit) { if (!this.canEdit) {
throw new CoreError('Cannot edit feedback'); throw new CoreError('Cannot edit feedback');
} }
return new Promise((resolve, reject): void => {
this.showEditFeedbackModal(resolve, reject);
});
}
protected async showEditFeedbackModal(
resolve: (value: AddonModAssignFeedbackCommentsTextData | PromiseLike<AddonModAssignFeedbackCommentsTextData>) => void,
reject: () => void,
): Promise < void> {
// Create the navigation modal. // Create the navigation modal.
const modal = await ModalController.instance.create({ const modal = await ModalController.instance.create({
component: AddonModAssignEditFeedbackModalComponent, component: AddonModAssignEditFeedbackModalComponent,
@ -134,9 +125,9 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
const result = await modal.onDidDismiss(); const result = await modal.onDidDismiss();
if (typeof result.data == 'undefined') { if (typeof result.data == 'undefined') {
reject(); throw null; // User cancelled.
} else { } else {
resolve(result.data); return result.data;
} }
} }

View File

@ -1,7 +1,8 @@
<core-loading [hideUntil]="loaded" class="core-loading-center"> <core-loading [hideUntil]="loaded" class="core-loading-center">
<!-- User and status of the submission. --> <!-- User and status of the submission. -->
<ion-item class="ion-text-wrap" *ngIf="!blindMarking && user" core-user-link [userId]="submitId" [courseId]="courseId" [title]="user!.fullname"> <ion-item class="ion-text-wrap" *ngIf="!blindMarking && user" core-user-link [userId]="submitId" [courseId]="courseId"
[title]="user!.fullname">
<core-user-avatar [user]="user" slot="start"></core-user-avatar> <core-user-avatar [user]="user" slot="start"></core-user-avatar>
<ion-label> <ion-label>
<h2>{{ user!.fullname }}</h2> <h2>{{ user!.fullname }}</h2>

View File

@ -28,7 +28,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreEditorComponentsModule, CoreEditorComponentsModule,
], ],
providers: [ providers: [
AddonModAssignFeedbackCommentsHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreSharedModule, CoreSharedModule,
], ],
providers: [ providers: [
AddonModAssignFeedbackEditPdfHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate
CoreSharedModule, CoreSharedModule,
], ],
providers: [ providers: [
AddonModAssignFeedbackFileHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -15,7 +15,6 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { CoreError } from '@classes/errors/error'; import { CoreError } from '@classes/errors/error';
import { CoreIonLoadingElement } from '@classes/ion-loading';
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
@ -208,26 +207,15 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy {
* *
* @return Promise resolved with boolean: whether data has changed. * @return Promise resolved with boolean: whether data has changed.
*/ */
protected hasDataChanged(): Promise<boolean> { protected async hasDataChanged(): Promise<boolean> {
// Usually the hasSubmissionDataChanged call will be resolved inmediately, causing the modal to be shown just an instant. // Usually the hasSubmissionDataChanged call will be resolved inmediately, causing the modal to be shown just an instant.
// We'll wait a bit before showing it to prevent this "blink". // We'll wait a bit before showing it to prevent this "blink".
let modal: CoreIonLoadingElement; const modal = await CoreDomUtils.instance.showModalLoading();
let showModal = true;
setTimeout(async () => {
if (showModal) {
modal = await CoreDomUtils.instance.showModalLoading();
}
}, 100);
const data = this.getInputData(); const data = this.getInputData();
return AddonModAssignHelper.instance.hasSubmissionDataChanged(this.assign!, this.userSubmission, data).finally(() => { return AddonModAssignHelper.instance.hasSubmissionDataChanged(this.assign!, this.userSubmission, data).finally(() => {
if (modal) { modal.dismiss();
modal.dismiss();
} else {
showModal = false;
}
}); });
} }

View File

@ -245,7 +245,6 @@ export class AddonModAssignHelperProvider {
// If no participants returned and all groups specified, get participants by groups. // If no participants returned and all groups specified, get participants by groups.
const groupsInfo = await CoreGroups.instance.getActivityGroupInfo(assign.cmid, false, undefined, modOptions.siteId); const groupsInfo = await CoreGroups.instance.getActivityGroupInfo(assign.cmid, false, undefined, modOptions.siteId);
[];
const participantsIndexed: {[id: number]: AddonModAssignParticipant} = {}; const participantsIndexed: {[id: number]: AddonModAssignParticipant} = {};
@ -582,7 +581,7 @@ export class AddonModAssignHelperProvider {
siteId?: string, siteId?: string,
): Promise<AddonModAssignSavePluginData> { ): Promise<AddonModAssignSavePluginData> {
const pluginData = {}; const pluginData: Record<string, unknown> = {};
const promises = feedback.plugins const promises = feedback.plugins
? feedback.plugins.map((plugin) => ? feedback.plugins.map((plugin) =>
AddonModAssignFeedbackDelegate.instance.preparePluginFeedbackData(assignId, userId, plugin, pluginData, siteId)) AddonModAssignFeedbackDelegate.instance.preparePluginFeedbackData(assignId, userId, plugin, pluginData, siteId))

View File

@ -31,6 +31,7 @@ import { AddonModAssignOffline } from './assign-offline';
import { AddonModAssignSubmissionDelegate } from './submission-delegate'; import { AddonModAssignSubmissionDelegate } from './submission-delegate';
import { CoreComments } from '@features/comments/services/comments'; import { CoreComments } from '@features/comments/services/comments';
import { AddonModAssignSubmissionFormatted } from './assign-helper'; import { AddonModAssignSubmissionFormatted } from './assign-helper';
import { CoreWSError } from '@classes/errors/wserror';
const ROOT_CACHE_KEY = 'mmaModAssign:'; const ROOT_CACHE_KEY = 'mmaModAssign:';
@ -1119,7 +1120,7 @@ export class AddonModAssignProvider {
if (warnings.length) { if (warnings.length) {
// The WebService returned warnings, reject. // The WebService returned warnings, reject.
throw warnings[0]; throw new CoreWSError(warnings[0]);
} }
} }
@ -1202,7 +1203,7 @@ export class AddonModAssignProvider {
if (warnings.length) { if (warnings.length) {
// The WebService returned warnings, reject. // The WebService returned warnings, reject.
throw warnings[0]; throw new CoreWSError(warnings[0]);
} }
} }
@ -1371,7 +1372,7 @@ export class AddonModAssignProvider {
if (warnings.length) { if (warnings.length) {
// The WebService returned warnings, reject. // The WebService returned warnings, reject.
throw warnings[0]; throw new CoreWSError(warnings[0]);
} }
} }

View File

@ -16,7 +16,8 @@ import { CoreSiteSchema } from '@services/sites';
/** /**
* Database variables for AddonModAssignOfflineProvider. * Database variables for AddonModAssignOfflineProvider.
*/export const SUBMISSIONS_TABLE = 'addon_mod_assign_submissions'; */
export const SUBMISSIONS_TABLE = 'addon_mod_assign_submissions';
export const SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading'; export const SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading';
export const OFFLINE_SITE_SCHEMA: CoreSiteSchema = { export const OFFLINE_SITE_SCHEMA: CoreSiteSchema = {
name: 'AddonModAssignOfflineProvider', name: 'AddonModAssignOfflineProvider',

View File

@ -28,7 +28,6 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp
CoreCommentsComponentsModule, CoreCommentsComponentsModule,
], ],
providers: [ providers: [
AddonModAssignSubmissionCommentsHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -26,7 +26,6 @@ import { AddonModAssignSubmissionDelegate } from '../../services/submission-dele
CoreSharedModule, CoreSharedModule,
], ],
providers: [ providers: [
AddonModAssignSubmissionFileHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -28,7 +28,6 @@ import { AddonModAssignSubmissionDelegate } from '../../services/submission-dele
CoreEditorComponentsModule, CoreEditorComponentsModule,
], ],
providers: [ providers: [
AddonModAssignSubmissionOnlineTextHandler,
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER,
multi: true, multi: true,

View File

@ -42,7 +42,7 @@ export class CoreIonLoadingElement {
* Present the loading. * Present the loading.
*/ */
async present(): Promise<void> { async present(): Promise<void> {
// Wait a bit before presenting the modal, to prevent it being displayed if dissmiss is called fast. // Wait a bit before presenting the modal, to prevent it being displayed if dismiss is called fast.
await CoreUtils.instance.wait(40); await CoreUtils.instance.wait(40);
if (!this.isDismissed) { if (!this.isDismissed) {