MOBILE-3636 assign: Fix feedback modules
This commit is contained in:
		
							parent
							
								
									d6169879fd
								
							
						
					
					
						commit
						f57abbd102
					
				| @ -22,6 +22,7 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi | |||||||
| import { CoreCronDelegate } from '@services/cron'; | import { CoreCronDelegate } from '@services/cron'; | ||||||
| import { CORE_SITE_SCHEMAS } from '@services/sites'; | import { CORE_SITE_SCHEMAS } from '@services/sites'; | ||||||
| import { AddonModAssignComponentsModule } from './components/components.module'; | import { AddonModAssignComponentsModule } from './components/components.module'; | ||||||
|  | import { AddonModAssignFeedbackModule } from './feedback/feedback.module'; | ||||||
| import { OFFLINE_SITE_SCHEMA } from './services/database/assign'; | import { OFFLINE_SITE_SCHEMA } from './services/database/assign'; | ||||||
| import { AddonModAssignIndexLinkHandler } from './services/handlers/index-link'; | import { AddonModAssignIndexLinkHandler } from './services/handlers/index-link'; | ||||||
| import { AddonModAssignListLinkHandler } from './services/handlers/list-link'; | import { AddonModAssignListLinkHandler } from './services/handlers/list-link'; | ||||||
| @ -43,6 +44,7 @@ const routes: Routes = [ | |||||||
|         CoreMainMenuTabRoutingModule.forChild(routes), |         CoreMainMenuTabRoutingModule.forChild(routes), | ||||||
|         AddonModAssignComponentsModule, |         AddonModAssignComponentsModule, | ||||||
|         AddonModAssignSubmissionModule, |         AddonModAssignSubmissionModule, | ||||||
|  |         AddonModAssignFeedbackModule, | ||||||
|     ], |     ], | ||||||
|     providers: [ |     providers: [ | ||||||
|         { |         { | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { CoreError } from '@classes/errors/error'; | |||||||
| import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; | import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; | ||||||
| import { CoreWSExternalFile } from '@services/ws'; | import { CoreWSExternalFile } from '@services/ws'; | ||||||
| import { ModalController } from '@singletons'; | import { ModalController } from '@singletons'; | ||||||
| import { AddonModAssignFeedbackCommentsPluginData } from '../../feedback/comments/services/handler'; | import { AddonModAssignFeedbackCommentsTextData } from '../../feedback/comments/services/handler'; | ||||||
| import { | import { | ||||||
|     AddonModAssignAssign, |     AddonModAssignAssign, | ||||||
|     AddonModAssignSubmission, |     AddonModAssignSubmission, | ||||||
| @ -104,7 +104,7 @@ 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<AddonModAssignFeedbackCommentsPluginData> { |     editFeedback(): Promise<AddonModAssignFeedbackCommentsTextData> { | ||||||
|         if (!this.canEdit) { |         if (!this.canEdit) { | ||||||
|             throw new CoreError('Cannot edit feedback'); |             throw new CoreError('Cannot edit feedback'); | ||||||
|         } |         } | ||||||
| @ -115,7 +115,7 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     protected async showEditFeedbackModal( |     protected async showEditFeedbackModal( | ||||||
|         resolve: (value: AddonModAssignFeedbackCommentsPluginData | PromiseLike<AddonModAssignFeedbackCommentsPluginData>) => void, |         resolve: (value: AddonModAssignFeedbackCommentsTextData | PromiseLike<AddonModAssignFeedbackCommentsTextData>) => void, | ||||||
|         reject: () => void, |         reject: () => void, | ||||||
|     ): Promise < void> { |     ): Promise < void> { | ||||||
|         // Create the navigation modal.
 |         // Create the navigation modal.
 | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ import { AddonModAssignFeedbackCommentsComponent } from './component/comments'; | |||||||
| import { CoreSharedModule } from '@/core/shared.module'; | import { CoreSharedModule } from '@/core/shared.module'; | ||||||
| import { CoreEditorComponentsModule } from '@features/editor/components/components.module'; | import { CoreEditorComponentsModule } from '@features/editor/components/components.module'; | ||||||
| import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; | import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; | ||||||
| import { AddonModAssignSubmissionFileHandler } from '../../submission/file/services/handler'; |  | ||||||
| 
 | 
 | ||||||
| @NgModule({ | @NgModule({ | ||||||
|     declarations: [ |     declarations: [ | ||||||
| @ -35,7 +34,7 @@ import { AddonModAssignSubmissionFileHandler } from '../../submission/file/servi | |||||||
|             multi: true, |             multi: true, | ||||||
|             deps: [], |             deps: [], | ||||||
|             useFactory: () => () => { |             useFactory: () => () => { | ||||||
|                 AddonModAssignFeedbackDelegate.instance.registerHandler(AddonModAssignSubmissionFileHandler.instance); |                 AddonModAssignFeedbackDelegate.instance.registerHandler(AddonModAssignFeedbackCommentsHandler.instance); | ||||||
|             }, |             }, | ||||||
|         }, |         }, | ||||||
|     ], |     ], | ||||||
|  | |||||||
| @ -49,14 +49,11 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss | |||||||
|      * @param inputData Data entered in the feedback edit form. |      * @param inputData Data entered in the feedback edit form. | ||||||
|      * @return Text to submit. |      * @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 : []; |         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.
 |         // 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) { |         const text = inputData.assignfeedbackcomments_editor || ''; | ||||||
|             text = inputData.assignfeedbackcomments_editor.text; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         return CoreTextUtils.instance.restorePluginfileUrls(text, files || []); |         return CoreTextUtils.instance.restorePluginfileUrls(text, files || []); | ||||||
|     } |     } | ||||||
| @ -147,7 +144,7 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss | |||||||
|         assign: AddonModAssignAssign, |         assign: AddonModAssignAssign, | ||||||
|         submission: AddonModAssignSubmission, |         submission: AddonModAssignSubmission, | ||||||
|         plugin: AddonModAssignPlugin, |         plugin: AddonModAssignPlugin, | ||||||
|         inputData: AddonModAssignFeedbackCommentsPluginData, |         inputData: AddonModAssignFeedbackCommentsTextData, | ||||||
|         userId: number, |         userId: number, | ||||||
|     ): Promise<boolean> { |     ): Promise<boolean> { | ||||||
|         // Get it from plugin or offline.
 |         // Get it from plugin or offline.
 | ||||||
| @ -254,6 +251,11 @@ export class AddonModAssignFeedbackCommentsHandlerService implements AddonModAss | |||||||
| } | } | ||||||
| export const AddonModAssignFeedbackCommentsHandler = makeSingleton(AddonModAssignFeedbackCommentsHandlerService); | 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 = { | export type AddonModAssignFeedbackCommentsDraftData = { | ||||||
|     text: string; // The text for this feedback.
 |     text: string; // The text for this feedback.
 | ||||||
|     format: number; // The format for this feedback.
 |     format: number; // The format for this feedback.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user