MOBILE-3636 assign: Fix feedback modules

main
Pau Ferrer Ocaña 2021-02-22 16:53:40 +01:00
parent d6169879fd
commit f57abbd102
4 changed files with 14 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi
import { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModAssignComponentsModule } from './components/components.module';
import { AddonModAssignFeedbackModule } from './feedback/feedback.module';
import { OFFLINE_SITE_SCHEMA } from './services/database/assign';
import { AddonModAssignIndexLinkHandler } from './services/handlers/index-link';
import { AddonModAssignListLinkHandler } from './services/handlers/list-link';
@ -43,6 +44,7 @@ const routes: Routes = [
CoreMainMenuTabRoutingModule.forChild(routes),
AddonModAssignComponentsModule,
AddonModAssignSubmissionModule,
AddonModAssignFeedbackModule,
],
providers: [
{

View File

@ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component';
import { CoreWSExternalFile } from '@services/ws';
import { ModalController } from '@singletons';
import { AddonModAssignFeedbackCommentsPluginData } from '../../feedback/comments/services/handler';
import { AddonModAssignFeedbackCommentsTextData } from '../../feedback/comments/services/handler';
import {
AddonModAssignAssign,
AddonModAssignSubmission,
@ -104,7 +104,7 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
*
* @return Promise resolved with the input data, rejected if cancelled.
*/
editFeedback(): Promise<AddonModAssignFeedbackCommentsPluginData> {
editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> {
if (!this.canEdit) {
throw new CoreError('Cannot edit feedback');
}
@ -115,7 +115,7 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit {
}
protected async showEditFeedbackModal(
resolve: (value: AddonModAssignFeedbackCommentsPluginData | PromiseLike<AddonModAssignFeedbackCommentsPluginData>) => void,
resolve: (value: AddonModAssignFeedbackCommentsTextData | PromiseLike<AddonModAssignFeedbackCommentsTextData>) => void,
reject: () => void,
): Promise < void> {
// Create the navigation modal.

View File

@ -18,7 +18,6 @@ import { AddonModAssignFeedbackCommentsComponent } from './component/comments';
import { CoreSharedModule } from '@/core/shared.module';
import { CoreEditorComponentsModule } from '@features/editor/components/components.module';
import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate';
import { AddonModAssignSubmissionFileHandler } from '../../submission/file/services/handler';
@NgModule({
declarations: [
@ -35,7 +34,7 @@ import { AddonModAssignSubmissionFileHandler } from '../../submission/file/servi
multi: true,
deps: [],
useFactory: () => () => {
AddonModAssignFeedbackDelegate.instance.registerHandler(AddonModAssignSubmissionFileHandler.instance);
AddonModAssignFeedbackDelegate.instance.registerHandler(AddonModAssignFeedbackCommentsHandler.instance);
},
},
],

View File

@ -49,14 +49,11 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
* @param inputData Data entered in the feedback edit form.
* @return Text to submit.
*/
getTextFromInputData(plugin: AddonModAssignPlugin, inputData: AddonModAssignFeedbackCommentsPluginData): string {
getTextFromInputData(plugin: AddonModAssignPlugin, inputData: AddonModAssignFeedbackCommentsTextData): string {
const files = plugin.fileareas && plugin.fileareas[0] ? plugin.fileareas[0].files : [];
let text = '';
// The input data can have a string or an object with text and format. Get the text.
if (inputData.assignfeedbackcomments_editor && inputData.assignfeedbackcomments_editor.text) {
text = inputData.assignfeedbackcomments_editor.text;
}
const text = inputData.assignfeedbackcomments_editor || '';
return CoreTextUtils.instance.restorePluginfileUrls(text, files || []);
}
@ -147,7 +144,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
assign: AddonModAssignAssign,
submission: AddonModAssignSubmission,
plugin: AddonModAssignPlugin,
inputData: AddonModAssignFeedbackCommentsPluginData,
inputData: AddonModAssignFeedbackCommentsTextData,
userId: number,
): Promise<boolean> {
// Get it from plugin or offline.
@ -254,6 +251,11 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss
}
export const AddonModAssignFeedbackCommentsHandler = makeSingleton(AddonModAssignFeedbackCommentsHandlerService);
export type AddonModAssignFeedbackCommentsTextData = {
// The text for this submission.
assignfeedbackcomments_editor: string; // eslint-disable-line @typescript-eslint/naming-convention
};
export type AddonModAssignFeedbackCommentsDraftData = {
text: string; // The text for this feedback.
format: number; // The format for this feedback.