forked from EVOgeek/Vmeda.Online
		
	Merge pull request #3953 from crazyserver/MOBILE-4329
MOBILE-4329 dataprivacy: Add link handlers
This commit is contained in:
		
						commit
						e79c549c2e
					
				| @ -35,8 +35,8 @@ export class AddonBadgesBadgeLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(`/badges/${params.hash}`, { siteId }); |                 await CoreNavigator.navigateToSitePath(`/badges/${params.hash}`, { siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -36,8 +36,8 @@ export class AddonBadgesMyBadgesLinkHandlerService extends CoreContentLinksHandl | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] { |     getActions(): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath('/badges', { siteId }); |                 await CoreNavigator.navigateToSitePath('/badges', { siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -44,8 +44,8 @@ export class AddonBlogIndexLinkHandlerService extends CoreContentLinksHandlerBas | |||||||
|         params.tagid ? pageParams['tagId'] = parseInt(params.tagid, 10) : null; |         params.tagid ? pageParams['tagId'] = parseInt(params.tagid, 10) : null; | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath('/blog', { params: pageParams, siteId }); |                 await CoreNavigator.navigateToSitePath('/blog', { params: pageParams, siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandler | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId?: string): void => { |             action: async (siteId?: string): Promise<void> => { | ||||||
|                 if (!params.view || params.view == 'month' || params.view == 'mini' || params.view == 'minithree') { |                 if (!params.view || params.view == 'month' || params.view == 'mini' || params.view == 'minithree') { | ||||||
|                     // Monthly view, open the calendar tab.
 |                     // Monthly view, open the calendar tab.
 | ||||||
|                     const stateParams: Params = { |                     const stateParams: Params = { | ||||||
| @ -59,7 +59,7 @@ export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandler | |||||||
|                     stateParams.year = momentInstance.year(); |                     stateParams.year = momentInstance.year(); | ||||||
|                     stateParams.month = momentInstance.month() + 1; |                     stateParams.month = momentInstance.month() + 1; | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath('/calendar/index', { |                     await CoreNavigator.navigateToSitePath('/calendar/index', { | ||||||
|                         params: stateParams, |                         params: stateParams, | ||||||
|                         siteId, |                         siteId, | ||||||
|                         preferCurrentTab: false, |                         preferCurrentTab: false, | ||||||
| @ -77,7 +77,7 @@ export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandler | |||||||
|                     stateParams.month = momentInstance.month() + 1; |                     stateParams.month = momentInstance.month() + 1; | ||||||
|                     stateParams.day = momentInstance.date(); |                     stateParams.day = momentInstance.date(); | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath('/calendar/day', { params: stateParams, siteId }); |                     await CoreNavigator.navigateToSitePath('/calendar/day', { params: stateParams, siteId }); | ||||||
| 
 | 
 | ||||||
|                 } else if (params.view == 'upcoming' || params.view == 'upcoming_mini') { |                 } else if (params.view == 'upcoming' || params.view == 'upcoming_mini') { | ||||||
|                     // Upcoming view, open the calendar tab.
 |                     // Upcoming view, open the calendar tab.
 | ||||||
| @ -86,7 +86,7 @@ export class AddonCalendarViewLinkHandlerService extends CoreContentLinksHandler | |||||||
|                         upcoming: true, |                         upcoming: true, | ||||||
|                     }; |                     }; | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath('/calendar/index', { |                     await CoreNavigator.navigateToSitePath('/calendar/index', { | ||||||
|                         params: stateParams, |                         params: stateParams, | ||||||
|                         siteId, |                         siteId, | ||||||
|                         preferCurrentTab: false, |                         preferCurrentTab: false, | ||||||
|  | |||||||
| @ -38,9 +38,9 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink | |||||||
|         courseId = courseId || parseInt(params.courseid || params.cid, 10); |         courseId = courseId || parseInt(params.courseid || params.cid, 10); | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 if (courseId) { |                 if (courseId) { | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         `${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, |                         `${COURSE_PAGE_NAME}/${courseId}/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, | ||||||
|                         { |                         { | ||||||
|                             params: { userId: params.userid }, |                             params: { userId: params.userid }, | ||||||
| @ -52,7 +52,7 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (params.planid) { |                 if (params.planid) { | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         `${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/competencies/${params.planid}`, |                         `${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/competencies/${params.planid}`, | ||||||
|                         { |                         { | ||||||
|                             params: { userId: params.userid }, |                             params: { userId: params.userid }, | ||||||
|  | |||||||
| @ -35,8 +35,8 @@ export class AddonCompetencyPlanLinkHandlerService extends CoreContentLinksHandl | |||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/${params.id}`, |                     `${ADDON_COMPETENCY_LEARNING_PLANS_PAGE}/${params.id}`, | ||||||
|                     { siteId }, |                     { siteId }, | ||||||
|                 ); |                 ); | ||||||
|  | |||||||
| @ -35,8 +35,8 @@ export class AddonCompetencyPlansLinkHandlerService extends CoreContentLinksHand | |||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     ADDON_COMPETENCY_LEARNING_PLANS_PAGE, |                     ADDON_COMPETENCY_LEARNING_PLANS_PAGE, | ||||||
|                     { params: { userId: params.userid }, siteId }, |                     { params: { userId: params.userid }, siteId }, | ||||||
|                 ); |                 ); | ||||||
|  | |||||||
| @ -35,8 +35,8 @@ export class AddonCompetencyUserCompetencyLinkHandlerService extends CoreContent | |||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${params.id}/${ADDON_COMPETENCY_SUMMARY_PAGE}`, |                     `${ADDON_COMPETENCY_COMPETENCIES_PAGE}/${params.id}/${ADDON_COMPETENCY_SUMMARY_PAGE}`, | ||||||
|                     { siteId }, |                     { siteId }, | ||||||
|                 ); |                 ); | ||||||
|  | |||||||
| @ -53,7 +53,7 @@ export class AddonCourseCompletionStatusLinkHandlerService extends CoreContentLi | |||||||
|                     userId, |                     userId, | ||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     '/coursecompletion', |                     '/coursecompletion', | ||||||
|                     { params: pageParams, siteId }, |                     { params: pageParams, siteId }, | ||||||
|                 ); |                 ); | ||||||
|  | |||||||
| @ -35,8 +35,8 @@ export class AddonMessagesContactRequestLinkHandlerService extends CoreContentLi | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath('/messages/contacts', { siteId }); |                 await CoreNavigator.navigateToSitePath('/messages/contacts', { siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -45,9 +45,9 @@ export class AddonMessagesDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const userId = parseInt(params.id || params.user2, 10); |                 const userId = parseInt(params.id || params.user2, 10); | ||||||
|                 CoreNavigator.navigateToSitePath(`/messages/discussion/user/${userId}`, { siteId }); |                 await CoreNavigator.navigateToSitePath(`/messages/discussion/user/${userId}`, { siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ export class AddonMessagesIndexLinkHandlerService extends CoreContentLinksHandle | |||||||
|     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: async (siteId): Promise<void> => { |             action: async (siteId): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(AddonMessagesMainMenuHandlerService.PAGE_NAME, { |                 await CoreNavigator.navigateToSitePath(AddonMessagesMainMenuHandlerService.PAGE_NAME, { | ||||||
|                     siteId, |                     siteId, | ||||||
|                     preferCurrentTab: false, |                     preferCurrentTab: false, | ||||||
|                 }); |                 }); | ||||||
|  | |||||||
| @ -13,7 +13,6 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Params } from '@angular/router'; |  | ||||||
| import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| @ -34,14 +33,14 @@ export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandl | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params, courseId?: number): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>, courseId?: number): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const dataId = parseInt(params.d, 10); |                 const dataId = parseInt(params.d, 10); | ||||||
|                 const entryId = parseInt(params.approve, 10) || parseInt(params.disapprove, 10); |                 const entryId = parseInt(params.approve, 10) || parseInt(params.disapprove, 10); | ||||||
|                 const approve = parseInt(params.approve, 10) ? true : false; |                 const approve = parseInt(params.approve, 10) ? true : false; | ||||||
| 
 | 
 | ||||||
|                 AddonModDataHelper.approveOrDisapproveEntry(dataId, entryId, approve, courseId, siteId); |                 await AddonModDataHelper.approveOrDisapproveEntry(dataId, entryId, approve, courseId, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
| @ -49,7 +48,7 @@ export class AddonModDataApproveLinkHandlerService extends CoreContentLinksHandl | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         if (params.d === undefined || (params.approve === undefined && params.disapprove === undefined)) { |         if (params.d === undefined || (params.approve === undefined && params.disapprove === undefined)) { | ||||||
|             // Required fields not defined. Cannot treat the URL.
 |             // Required fields not defined. Cannot treat the URL.
 | ||||||
|             return false; |             return false; | ||||||
|  | |||||||
| @ -13,7 +13,6 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Params } from '@angular/router'; |  | ||||||
| import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| @ -33,13 +32,13 @@ export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandle | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params, courseId?: number): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>, courseId?: number): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const dataId = parseInt(params.d, 10); |                 const dataId = parseInt(params.d, 10); | ||||||
|                 const entryId = parseInt(params.delete, 10); |                 const entryId = parseInt(params.delete, 10); | ||||||
| 
 | 
 | ||||||
|                 AddonModDataHelper.showDeleteEntryModal(dataId, entryId, courseId, siteId); |                 await AddonModDataHelper.showDeleteEntryModal(dataId, entryId, courseId, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
| @ -47,7 +46,7 @@ export class AddonModDataDeleteLinkHandlerService extends CoreContentLinksHandle | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         if (params.d === undefined || params.delete === undefined) { |         if (params.d === undefined || params.delete === undefined) { | ||||||
|             // Required fields not defined. Cannot treat the URL.
 |             // Required fields not defined. Cannot treat the URL.
 | ||||||
|             return false; |             return false; | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: async (siteId): Promise<void> => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const modal = await CoreDomUtils.showModalLoading(); |                 const modal = await CoreDomUtils.showModalLoading(); | ||||||
| @ -54,7 +54,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|                         title: module.name, |                         title: module.name, | ||||||
|                     }; |                     }; | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         `${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/edit/${rId}`, |                         `${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/edit/${rId}`, | ||||||
|                         { siteId, params: pageParams }, |                         { siteId, params: pageParams }, | ||||||
|                     ); |                     ); | ||||||
| @ -69,7 +69,7 @@ export class AddonModDataEditLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         if (params.d === undefined) { |         if (params.d === undefined) { | ||||||
|             // Id not defined. Cannot treat the URL.
 |             // Id not defined. Cannot treat the URL.
 | ||||||
|             return false; |             return false; | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: async (siteId): Promise<void> => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const modal = await CoreDomUtils.showModalLoading(); |                 const modal = await CoreDomUtils.showModalLoading(); | ||||||
| @ -65,7 +65,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|                         pageParams.offset = page || 0; |                         pageParams.offset = page || 0; | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         `${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/${rId}`, |                         `${AddonModDataModuleHandlerService.PAGE_NAME}/${module.course}/${module.id}/${rId}`, | ||||||
|                         { siteId, params: pageParams }, |                         { siteId, params: pageParams }, | ||||||
|                     ); |                     ); | ||||||
| @ -80,7 +80,7 @@ export class AddonModDataShowLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         if (params.d === undefined) { |         if (params.d === undefined) { | ||||||
|             // Id not defined. Cannot treat the URL.
 |             // Id not defined. Cannot treat the URL.
 | ||||||
|             return false; |             return false; | ||||||
|  | |||||||
| @ -53,7 +53,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks | |||||||
|                         siteId, |                         siteId, | ||||||
|                     ); |                     ); | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}`, |                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}`, | ||||||
|                         { |                         { | ||||||
|                             params: { |                             params: { | ||||||
|  | |||||||
| @ -49,7 +49,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks | |||||||
|                         { siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE }, |                         { siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE }, | ||||||
|                     ); |                     ); | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, |                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, | ||||||
|                         { |                         { | ||||||
|                             params: { |                             params: { | ||||||
|  | |||||||
| @ -49,7 +49,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan | |||||||
|                         { siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE }, |                         { siteId, readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE }, | ||||||
|                     ); |                     ); | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, |                         AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/form`, | ||||||
|                         { |                         { | ||||||
|                             params: { |                             params: { | ||||||
|  | |||||||
| @ -34,8 +34,8 @@ export class AddonModFeedbackShowEntriesLinkHandlerService extends CoreContentLi | |||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string) => { |             action: async (siteId: string) => { | ||||||
|                 AddonModFeedbackHelper.handleShowEntriesLink(params, siteId); |                 await AddonModFeedbackHelper.handleShowEntriesLink(params, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -36,7 +36,7 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|     getActions( |     getActions( | ||||||
|         siteIds: string[], |         siteIds: string[], | ||||||
|         url: string, |         url: string, | ||||||
|         params: Params, |         params: Record<string, string>, | ||||||
|         courseId?: number, |         courseId?: number, | ||||||
|         data?: { instance?: string; cmid?: string; postid?: string }, |         data?: { instance?: string; cmid?: string; postid?: string }, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
| @ -46,10 +46,10 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|         // However canreply will be false.
 |         // However canreply will be false.
 | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const discussionId = parseInt(params.d, 10); |                 const discussionId = parseInt(params.d, 10); | ||||||
|                 const cmId = data?.cmid && Number(data.cmid); |                 const cmId = data?.cmid && Number(data.cmid); | ||||||
|                 courseId = courseId || (params.courseid && Number(params.courseid)) || (params.cid && Number(params.cid)); |                 courseId = Number(courseId || params.courseid || params.cid); | ||||||
| 
 | 
 | ||||||
|                 const pageParams: Params = { |                 const pageParams: Params = { | ||||||
|                     forumId: data?.instance && parseInt(data.instance, 10), |                     forumId: data?.instance && parseInt(data.instance, 10), | ||||||
| @ -65,7 +65,7 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|                     pageParams.parent = parseInt(params.parent); |                     pageParams.parent = parseInt(params.parent); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`, |                     `${AddonModForumModuleHandlerService.PAGE_NAME}/discussion/${discussionId}`, | ||||||
|                     { siteId, params: pageParams }, |                     { siteId, params: pageParams }, | ||||||
|                 ); |                 ); | ||||||
| @ -73,13 +73,6 @@ export class AddonModForumDiscussionLinkHandlerService extends CoreContentLinksH | |||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * @inheritdoc |  | ||||||
|      */ |  | ||||||
|     async isEnabled(): Promise<boolean> { |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const AddonModForumDiscussionLinkHandler = makeSingleton(AddonModForumDiscussionLinkHandlerService); | export const AddonModForumDiscussionLinkHandler = makeSingleton(AddonModForumDiscussionLinkHandlerService); | ||||||
|  | |||||||
| @ -13,7 +13,6 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Params } from '@angular/router'; |  | ||||||
| import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { CoreCourse } from '@features/course/services/course'; | import { CoreCourse } from '@features/course/services/course'; | ||||||
| @ -40,7 +39,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler | |||||||
|     getActions( |     getActions( | ||||||
|         siteIds: string[], |         siteIds: string[], | ||||||
|         url: string, |         url: string, | ||||||
|         params: Params, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: async (siteId): Promise<void> => { |             action: async (siteId): Promise<void> => { | ||||||
| @ -69,7 +68,7 @@ export class AddonModForumPostLinkHandlerService extends CoreContentLinksHandler | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         return params.forum !== undefined; |         return params.forum !== undefined; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -87,10 +87,10 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink | |||||||
|      * @param courseId Course ID. |      * @param courseId Course ID. | ||||||
|      * @param siteId Site ID. |      * @param siteId Site ID. | ||||||
|      */ |      */ | ||||||
|     protected openAttemptResults(cmId: number, attemptId: number, courseId: number, siteId: string): void { |     protected async openAttemptResults(cmId: number, attemptId: number, courseId: number, siteId: string): Promise<void> { | ||||||
|         const path = AddonModH5PActivityModuleHandlerService.PAGE_NAME + `/${courseId}/${cmId}/attemptresults/${attemptId}`; |         const path = AddonModH5PActivityModuleHandlerService.PAGE_NAME + `/${courseId}/${cmId}/attemptresults/${attemptId}`; | ||||||
| 
 | 
 | ||||||
|         CoreNavigator.navigateToSitePath(path, { |         await CoreNavigator.navigateToSitePath(path, { | ||||||
|             siteId, |             siteId, | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -52,16 +52,16 @@ export class AddonModLessonIndexLinkHandlerService extends CoreContentLinksModul | |||||||
|         courseId?: number, |         courseId?: number, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
| 
 | 
 | ||||||
|         courseId = Number(courseId || params.courseid || params.cid); |         const cId = Number(courseId || params.courseid || params.cid); | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 /* Ignore the pageid param. If we open the lesson player with a certain page and the user hasn't started |                 /* Ignore the pageid param. If we open the lesson player with a certain page and the user hasn't started | ||||||
|                    the lesson, an error is thrown: could not find lesson_timer records. */ |                    the lesson, an error is thrown: could not find lesson_timer records. */ | ||||||
|                 if (params.userpassword) { |                 if (params.userpassword) { | ||||||
|                     this.navigateToModuleWithPassword(parseInt(params.id, 10), courseId!, params.userpassword, siteId); |                     await this.navigateToModuleWithPassword(parseInt(params.id, 10), cId, params.userpassword, siteId); | ||||||
|                 } else { |                 } else { | ||||||
|                     CoreCourseHelper.navigateToModule(parseInt(params.id, 10), { |                     await CoreCourseHelper.navigateToModule(parseInt(params.id, 10), { | ||||||
|                         courseId, |                         courseId, | ||||||
|                         siteId, |                         siteId, | ||||||
|                     }); |                     }); | ||||||
|  | |||||||
| @ -47,12 +47,12 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId) => { |             action: async (siteId) => { | ||||||
|                 if (!params.action || params.action == 'reportoverview') { |                 if (!params.action || params.action == 'reportoverview') { | ||||||
|                     // Go to overview.
 |                     // Go to overview.
 | ||||||
|                     this.openReportOverview(Number(params.id), Number(params.group), siteId); |                     await this.openReportOverview(Number(params.id), Number(params.group), siteId); | ||||||
|                 } else if (params.action == 'reportdetail') { |                 } else if (params.action == 'reportdetail') { | ||||||
|                     this.openUserRetake(Number(params.id), Number(params.userid), Number(params.try), siteId); |                     await this.openUserRetake(Number(params.id), Number(params.userid), Number(params.try), siteId); | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|  | |||||||
| @ -49,10 +49,10 @@ export class AddonModQuizReviewLinkHandlerService extends CoreContentLinksHandle | |||||||
|         const quizId = data?.instance ? Number(data.instance) : undefined; |         const quizId = data?.instance ? Number(data.instance) : undefined; | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const attemptId = parseInt(params.attempt, 10); |                 const attemptId = parseInt(params.attempt, 10); | ||||||
|                 const page = parseInt(params.page, 10); |                 const page = parseInt(params.page, 10); | ||||||
|                 AddonModQuizHelper.handleReviewLink(attemptId, page, quizId, siteId); |                 await AddonModQuizHelper.handleReviewLink(attemptId, page, quizId, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ export class AddonModScormPlayerLinkHandlerService extends CoreContentLinksHandl | |||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 if (cmId) { |                 if (cmId) { | ||||||
|                     CoreCourseHelper.navigateToModule( |                     await CoreCourseHelper.navigateToModule( | ||||||
|                         cmId, |                         cmId, | ||||||
|                         { |                         { | ||||||
|                             courseId, |                             courseId, | ||||||
| @ -65,7 +65,7 @@ export class AddonModScormPlayerLinkHandlerService extends CoreContentLinksHandl | |||||||
|                         }, |                         }, | ||||||
|                     ); |                     ); | ||||||
|                 } else { |                 } else { | ||||||
|                     CoreCourseHelper.navigateToModuleByInstance( |                     await CoreCourseHelper.navigateToModuleByInstance( | ||||||
|                         instanceId, |                         instanceId, | ||||||
|                         'scorm', |                         'scorm', | ||||||
|                         { |                         { | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ export class AddonModWikiEditLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|                         section = params.section.replace(/\+/g, ' '); |                         section = params.section.replace(/\+/g, ' '); | ||||||
|                     } |                     } | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/edit`, |                         AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/edit`, | ||||||
|                         { |                         { | ||||||
|                             params: { |                             params: { | ||||||
|  | |||||||
| @ -67,7 +67,7 @@ export class AddonModWikiPageOrMapLinkHandlerService extends CoreContentLinksHan | |||||||
|                         timestamp: Date.now(), |                         timestamp: Date.now(), | ||||||
|                     })); |                     })); | ||||||
| 
 | 
 | ||||||
|                     CoreNavigator.navigateToSitePath( |                     await CoreNavigator.navigateToSitePath( | ||||||
|                         AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/page/${hash}`, |                         AddonModWikiModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/page/${hash}`, | ||||||
|                         { |                         { | ||||||
|                             params: { |                             params: { | ||||||
|  | |||||||
| @ -35,8 +35,8 @@ export class AddonNotificationsLinkHandlerService extends CoreContentLinksHandle | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] { |     getActions(): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(AddonNotificationsMainMenuHandlerService.PAGE_NAME, { |                 await CoreNavigator.navigateToSitePath(AddonNotificationsMainMenuHandlerService.PAGE_NAME, { | ||||||
|                     preferCurrentTab: false, |                     preferCurrentTab: false, | ||||||
|                     siteId, |                     siteId, | ||||||
|                 }); |                 }); | ||||||
|  | |||||||
| @ -37,8 +37,11 @@ export class AddonNotificationsPreferencesLinkHandlerService extends CoreContent | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] { |     getActions(): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(`preferences/${AddonNotificationsSettingsHandlerService.PAGE_NAME}`, { siteId }); |                 await CoreNavigator.navigateToSitePath( | ||||||
|  |                     `preferences/${AddonNotificationsSettingsHandlerService.PAGE_NAME}`, | ||||||
|  |                     { siteId }, | ||||||
|  |                 ); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB | |||||||
|                 const site = await CoreSites.getSite(siteId); |                 const site = await CoreSites.getSite(siteId); | ||||||
|                 if (!params.userid || Number(params.userid) == site.getUserId()) { |                 if (!params.userid || Number(params.userid) == site.getUserId()) { | ||||||
|                     // No user specified or current user. Navigate to module.
 |                     // No user specified or current user. Navigate to module.
 | ||||||
|                     CoreCourseHelper.navigateToModule( |                     await CoreCourseHelper.navigateToModule( | ||||||
|                         Number(params.id), |                         Number(params.id), | ||||||
|                         { |                         { | ||||||
|                             courseId: courseIdentifier, |                             courseId: courseIdentifier, | ||||||
| @ -86,10 +86,10 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB | |||||||
|                     ); |                     ); | ||||||
|                 } else if (this.canReview) { |                 } else if (this.canReview) { | ||||||
|                     // Use the goToReview function.
 |                     // Use the goToReview function.
 | ||||||
|                     this.goToReview(url, params, courseIdentifier, siteId); |                     await this.goToReview(url, params, courseIdentifier, siteId); | ||||||
|                 } else { |                 } else { | ||||||
|                     // Not current user and cannot review it in the app, open it in browser.
 |                     // Not current user and cannot review it in the app, open it in browser.
 | ||||||
|                     site.openInBrowserWithAutoLogin(url); |                     await site.openInBrowserWithAutoLogin(url); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 modal.dismiss(); |                 modal.dismiss(); | ||||||
|  | |||||||
| @ -87,8 +87,8 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB | |||||||
|             const instanceId = parseInt(params[this.instanceIdParam], 10); |             const instanceId = parseInt(params[this.instanceIdParam], 10); | ||||||
| 
 | 
 | ||||||
|             return [{ |             return [{ | ||||||
|                 action: (siteId) => { |                 action: async (siteId) => { | ||||||
|                     CoreCourseHelper.navigateToModuleByInstance( |                     await CoreCourseHelper.navigateToModuleByInstance( | ||||||
|                         instanceId, |                         instanceId, | ||||||
|                         this.modName, |                         this.modName, | ||||||
|                         { |                         { | ||||||
| @ -103,8 +103,8 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId) => { |             action: async (siteId) => { | ||||||
|                 CoreCourseHelper.navigateToModule( |                 await CoreCourseHelper.navigateToModule( | ||||||
|                     parseInt(params.id, 10), |                     parseInt(params.id, 10), | ||||||
|                     { |                     { | ||||||
|                         courseId, |                         courseId, | ||||||
|  | |||||||
| @ -60,8 +60,8 @@ export class CoreContentLinksModuleListHandler extends CoreContentLinksHandlerBa | |||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath('course/' + params.id + '/list-mod-type', { |                 await CoreNavigator.navigateToSitePath('course/' + params.id + '/list-mod-type', { | ||||||
|                     params: { |                     params: { | ||||||
|                         modName: this.modName, |                         modName: this.modName, | ||||||
|                         title: this.title || Translate.instant('addon.mod_' + this.modName + '.modulenameplural'), |                         title: this.title || Translate.instant('addon.mod_' + this.modName + '.modulenameplural'), | ||||||
|  | |||||||
| @ -118,7 +118,7 @@ export interface CoreContentLinksAction { | |||||||
|      * |      * | ||||||
|      * @param siteId The site ID. |      * @param siteId The site ID. | ||||||
|      */ |      */ | ||||||
|     action(siteId: string): void; |     action(siteId: string): Promise<void>; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler | |||||||
|     getActions( |     getActions( | ||||||
|         siteIds: string[], |         siteIds: string[], | ||||||
|         url: string, |         url: string, | ||||||
|         params: Params, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         const courseId = parseInt(params.id, 10); |         const courseId = parseInt(params.id, 10); | ||||||
|         const sectionId = params.sectionid ? parseInt(params.sectionid, 10) : undefined; |         const sectionId = params.sectionid ? parseInt(params.sectionid, 10) : undefined; | ||||||
| @ -78,7 +78,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 siteId = siteId || CoreSites.getCurrentSiteId(); |                 siteId = siteId || CoreSites.getCurrentSiteId(); | ||||||
|                 if (siteId === CoreSites.getCurrentSiteId()) { |                 if (siteId === CoreSites.getCurrentSiteId()) { | ||||||
|                     // Check if we already are in the course index page.
 |                     // Check if we already are in the course index page.
 | ||||||
| @ -87,15 +87,15 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler | |||||||
|                         CoreCourse.selectCourseTab('', pageParams); |                         CoreCourse.selectCourseTab('', pageParams); | ||||||
| 
 | 
 | ||||||
|                         return; |                         return; | ||||||
|                     } else { |  | ||||||
|                         this.actionOpen(courseId, url, pageParams).catch(() => { |  | ||||||
|                             // Ignore errors.
 |  | ||||||
|                         }); |  | ||||||
|                     } |                     } | ||||||
|                 } else { | 
 | ||||||
|                     // Make the course the new history root (to avoid "loops" in history).
 |                     await CoreUtils.ignoreErrors(this.actionOpen(courseId, url, pageParams)); | ||||||
|                     CoreCourseHelper.getAndOpenCourse(courseId, pageParams, siteId); | 
 | ||||||
|  |                     return; | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|  |                 // Make the course the new history root (to avoid "loops" in history).
 | ||||||
|  |                 await CoreCourseHelper.getAndOpenCourse(courseId, pageParams, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
| @ -103,7 +103,7 @@ export class CoreCoursesCourseLinkHandlerService extends CoreContentLinksHandler | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async isEnabled(siteId: string, url: string, params: Params): Promise<boolean> { |     async isEnabled(siteId: string, url: string, params: Record<string, string>): Promise<boolean> { | ||||||
|         const courseId = parseInt(params.id, 10); |         const courseId = parseInt(params.id, 10); | ||||||
| 
 | 
 | ||||||
|         if (!courseId) { |         if (!courseId) { | ||||||
|  | |||||||
| @ -33,9 +33,9 @@ export class CoreCoursesIndexLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 let pageName = CoreCoursesMyCoursesMainMenuHandlerService.PAGE_NAME; |                 let pageName = CoreCoursesMyCoursesMainMenuHandlerService.PAGE_NAME; | ||||||
|                 const pageParams: Params = {}; |                 const pageParams: Params = {}; | ||||||
| 
 | 
 | ||||||
| @ -46,7 +46,7 @@ export class CoreCoursesIndexLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|                     pageParams.mode = 'all'; |                     pageParams.mode = 'all'; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 CoreNavigator.navigateToSitePath(pageName, { params: pageParams, siteId }); |                 await CoreNavigator.navigateToSitePath(pageName, { params: pageParams, siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -36,9 +36,9 @@ export class CoreCoursesDashboardLinkHandlerService extends CoreContentLinksHand | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 // Use redirect to select the tab.
 |                 // Use redirect to select the tab.
 | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreDashboardHomeHandlerService.PAGE_NAME}`, |                     `/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreDashboardHomeHandlerService.PAGE_NAME}`, | ||||||
|                     { |                     { | ||||||
|                         siteId, |                         siteId, | ||||||
|  | |||||||
| @ -16,7 +16,6 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
| import { makeSingleton } from '@singletons'; | import { makeSingleton } from '@singletons'; | ||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { Params } from '@angular/router'; |  | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| /** | /** | ||||||
|  * Handler to treat links to my courses page. |  * Handler to treat links to my courses page. | ||||||
| @ -36,26 +35,22 @@ export class CoreCoursesMyCoursesLinkHandlerService extends CoreContentLinksHand | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (): void => { |             action: async (): Promise<void> => { | ||||||
|                 this.actionOpen({ |                 await CoreNavigator.navigate( | ||||||
|                     sort: params.sort || undefined, |                     '/main/courses/my', | ||||||
|                     filter: params.filter || undefined, |                     { | ||||||
|                     search: params.search || undefined, |                         params: { | ||||||
|                     layout: params.layout || undefined, |                             sort: params.sort || undefined, | ||||||
|                 }); |                             filter: params.filter || undefined, | ||||||
|  |                             search: params.search || undefined, | ||||||
|  |                             layout: params.layout || undefined, | ||||||
|  |                         }, | ||||||
|  |                     }, | ||||||
|  |                 ); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Open my courses. |  | ||||||
|      * |  | ||||||
|      * @param params Params to send to the new page. |  | ||||||
|      */ |  | ||||||
|     protected actionOpen(params: Params): void { |  | ||||||
|         CoreNavigator.navigate('/main/courses/my', { params }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const CoreCoursesMyCoursesLinkHandler = makeSingleton(CoreCoursesMyCoursesLinkHandlerService); | export const CoreCoursesMyCoursesLinkHandler = makeSingleton(CoreCoursesMyCoursesLinkHandlerService); | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ import { ModalController } from '@singletons'; | |||||||
| export class CoreDataPrivacyNewRequestComponent implements OnInit { | export class CoreDataPrivacyNewRequestComponent implements OnInit { | ||||||
| 
 | 
 | ||||||
|     @Input() accessInfo?: CoreDataPrivacyGetAccessInformationWSResponse; |     @Input() accessInfo?: CoreDataPrivacyGetAccessInformationWSResponse; | ||||||
|  |     @Input() createType?: CoreDataPrivacyDataRequestType; | ||||||
| 
 | 
 | ||||||
|     message = ''; |     message = ''; | ||||||
| 
 | 
 | ||||||
| @ -65,9 +66,24 @@ export class CoreDataPrivacyNewRequestComponent implements OnInit { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Just in case only deleting is allowed, change the default type.
 |         switch (this.createType) { | ||||||
|         if (!this.accessInfo.cancreatedatadownloadrequest && this.accessInfo.cancreatedatadeletionrequest){ |             case CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_EXPORT: | ||||||
|             this.typeControl.setValue(CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_DELETE); |                 if (this.accessInfo?.cancreatedatadownloadrequest) { | ||||||
|  |                     this.typeControl.setValue(this.createType); | ||||||
|  | 
 | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_DELETE: | ||||||
|  |                 if (this.accessInfo?.cancreatedatadeletionrequest) { | ||||||
|  |                     this.typeControl.setValue(this.createType); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 // Just in case only deleting is allowed, change the default type.
 | ||||||
|  |                 if (!this.accessInfo.cancreatedatadownloadrequest && this.accessInfo.cancreatedatadeletionrequest){ | ||||||
|  |                     this.typeControl.setValue(CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_DELETE); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -19,6 +19,9 @@ import { Routes } from '@angular/router'; | |||||||
| import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; | ||||||
| import { CoreDataPrivacyComponentsModule } from './components/components.module'; | import { CoreDataPrivacyComponentsModule } from './components/components.module'; | ||||||
| import { CORE_DATAPRIVACY_PAGE_NAME } from './constants'; | import { CORE_DATAPRIVACY_PAGE_NAME } from './constants'; | ||||||
|  | import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
|  | import { CoreDataPrivacyDataRequestsLinkHandler } from './services/handlers/datarequests-link'; | ||||||
|  | import { CoreDataPrivacyCreateDataRequestLinkHandler } from './services/handlers/createdatarequest-link'; | ||||||
| 
 | 
 | ||||||
| const routes: Routes = [ | const routes: Routes = [ | ||||||
|     { |     { | ||||||
| @ -38,6 +41,8 @@ const routes: Routes = [ | |||||||
|             multi: true, |             multi: true, | ||||||
|             useValue: () => { |             useValue: () => { | ||||||
|                 CoreUserDelegate.registerHandler(CoreDataPrivacyUserHandler.instance); |                 CoreUserDelegate.registerHandler(CoreDataPrivacyUserHandler.instance); | ||||||
|  |                 CoreContentLinksDelegate.registerHandler(CoreDataPrivacyDataRequestsLinkHandler.instance); | ||||||
|  |                 CoreContentLinksDelegate.registerHandler(CoreDataPrivacyCreateDataRequestLinkHandler.instance); | ||||||
|             }, |             }, | ||||||
|         }, |         }, | ||||||
|     ], |     ], | ||||||
|  | |||||||
| @ -17,9 +17,11 @@ import { CoreDataPrivacyContactDPOComponent } from '@features/dataprivacy/compon | |||||||
| import { CoreDataPrivacyNewRequestComponent } from '@features/dataprivacy/components/newrequest/newrequest'; | import { CoreDataPrivacyNewRequestComponent } from '@features/dataprivacy/components/newrequest/newrequest'; | ||||||
| import { | import { | ||||||
|     CoreDataPrivacy, |     CoreDataPrivacy, | ||||||
|  |     CoreDataPrivacyDataRequestType, | ||||||
|     CoreDataPrivacyGetAccessInformationWSResponse, |     CoreDataPrivacyGetAccessInformationWSResponse, | ||||||
|     CoreDataPrivacyRequest, |     CoreDataPrivacyRequest, | ||||||
| } from '@features/dataprivacy/services/dataprivacy'; | } from '@features/dataprivacy/services/dataprivacy'; | ||||||
|  | import { CoreNavigator } from '@services/navigator'; | ||||||
| import { CoreScreen } from '@services/screen'; | import { CoreScreen } from '@services/screen'; | ||||||
| import { CoreDomUtils } from '@services/utils/dom'; | import { CoreDomUtils } from '@services/utils/dom'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| @ -46,13 +48,33 @@ export class CoreDataPrivacyMainPage implements OnInit { | |||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     async ngOnInit(): Promise<void> { |     async ngOnInit(): Promise<void> { | ||||||
|         this.fetchContent(); |  | ||||||
| 
 |  | ||||||
|         this.isTablet = CoreScreen.isTablet; |         this.isTablet = CoreScreen.isTablet; | ||||||
| 
 | 
 | ||||||
|         this.layoutSubscription = CoreScreen.layoutObservable.subscribe(() => { |         this.layoutSubscription = CoreScreen.layoutObservable.subscribe(() => { | ||||||
|             this.isTablet = CoreScreen.isTablet; |             this.isTablet = CoreScreen.isTablet; | ||||||
|         }); |         }); | ||||||
|  | 
 | ||||||
|  |         await this.fetchContent(); | ||||||
|  | 
 | ||||||
|  |         const createType = CoreNavigator.getRouteNumberParam('createType') as CoreDataPrivacyDataRequestType; | ||||||
|  | 
 | ||||||
|  |         switch (createType) { | ||||||
|  |             case CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_EXPORT: | ||||||
|  |                 if (this.accessInfo?.cancreatedatadownloadrequest) { | ||||||
|  |                     this.newRequest(createType); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_DELETE: | ||||||
|  |                 if (this.accessInfo?.cancreatedatadeletionrequest) { | ||||||
|  |                     this.newRequest(createType); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |             case CoreDataPrivacyDataRequestType.DATAREQUEST_TYPE_OTHERS: | ||||||
|  |                 if (this.accessInfo?.cancontactdpo) { | ||||||
|  |                     this.contactDPO(); | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -111,12 +133,13 @@ export class CoreDataPrivacyMainPage implements OnInit { | |||||||
|     /** |     /** | ||||||
|      * Open the new request modal. |      * Open the new request modal. | ||||||
|      */ |      */ | ||||||
|     async newRequest(): Promise<void> { |     async newRequest(createType?: CoreDataPrivacyDataRequestType): Promise<void> { | ||||||
|         // Create and show the modal.
 |         // Create and show the modal.
 | ||||||
|         const succeed = await CoreDomUtils.openModal<boolean>({ |         const succeed = await CoreDomUtils.openModal<boolean>({ | ||||||
|             component: CoreDataPrivacyNewRequestComponent, |             component: CoreDataPrivacyNewRequestComponent, | ||||||
|             componentProps: { |             componentProps: { | ||||||
|                 accessInfo: this.accessInfo, |                 accessInfo: this.accessInfo, | ||||||
|  |                 createType, | ||||||
|             }, |             }, | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -0,0 +1,62 @@ | |||||||
|  | // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||||
|  | //
 | ||||||
|  | // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||||
|  | // you may not use this file except in compliance with the License.
 | ||||||
|  | // You may obtain a copy of the License at
 | ||||||
|  | //
 | ||||||
|  | //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||||
|  | //
 | ||||||
|  | // Unless required by applicable law or agreed to in writing, software
 | ||||||
|  | // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||||
|  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||||
|  | // See the License for the specific language governing permissions and
 | ||||||
|  | // limitations under the License.
 | ||||||
|  | 
 | ||||||
|  | import { Injectable } from '@angular/core'; | ||||||
|  | import { Params } from '@angular/router'; | ||||||
|  | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
|  | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
|  | import { CORE_DATAPRIVACY_PAGE_NAME } from '@features/dataprivacy/constants'; | ||||||
|  | import { CoreNavigator } from '@services/navigator'; | ||||||
|  | import { makeSingleton } from '@singletons'; | ||||||
|  | import { CoreDataPrivacy } from '../dataprivacy'; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Handler to treat data requests creation links. | ||||||
|  |  */ | ||||||
|  | @Injectable({ providedIn: 'root' }) | ||||||
|  | export class CoreDataPrivacyCreateDataRequestLinkHandlerService extends CoreContentLinksHandlerBase { | ||||||
|  | 
 | ||||||
|  |     name = 'CoreDataPrivacyCreateDataRequestLinkHandler'; | ||||||
|  |     pattern = /\/admin\/tool\/dataprivacy\/createdatarequest\.php.*([?&]type=\d+)/; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @inheritdoc | ||||||
|  |      */ | ||||||
|  |     getActions( | ||||||
|  |         siteIds: string[], | ||||||
|  |         url: string, | ||||||
|  |         params: Record<string, string>, | ||||||
|  |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|  | 
 | ||||||
|  |         const pageParams: Params = { | ||||||
|  |             createType: Number(params.type), | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         return [{ | ||||||
|  |             action: async (siteId): Promise<void> => { | ||||||
|  |                 await CoreNavigator.navigateToSitePath(CORE_DATAPRIVACY_PAGE_NAME, { params: pageParams,  siteId }); | ||||||
|  |             }, | ||||||
|  |         }]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @inheritdoc | ||||||
|  |      */ | ||||||
|  |     async isEnabled(): Promise<boolean> { | ||||||
|  |         return await CoreDataPrivacy.isEnabled(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const CoreDataPrivacyCreateDataRequestLinkHandler = makeSingleton(CoreDataPrivacyCreateDataRequestLinkHandlerService); | ||||||
| @ -0,0 +1,52 @@ | |||||||
|  | // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||||
|  | //
 | ||||||
|  | // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||||
|  | // you may not use this file except in compliance with the License.
 | ||||||
|  | // You may obtain a copy of the License at
 | ||||||
|  | //
 | ||||||
|  | //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||||
|  | //
 | ||||||
|  | // Unless required by applicable law or agreed to in writing, software
 | ||||||
|  | // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||||
|  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||||
|  | // See the License for the specific language governing permissions and
 | ||||||
|  | // limitations under the License.
 | ||||||
|  | 
 | ||||||
|  | import { Injectable } from '@angular/core'; | ||||||
|  | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
|  | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
|  | import { CORE_DATAPRIVACY_PAGE_NAME } from '@features/dataprivacy/constants'; | ||||||
|  | import { CoreNavigator } from '@services/navigator'; | ||||||
|  | import { makeSingleton } from '@singletons'; | ||||||
|  | import { CoreDataPrivacy } from '../dataprivacy'; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Handler to treat data requests links. | ||||||
|  |  */ | ||||||
|  | @Injectable({ providedIn: 'root' }) | ||||||
|  | export class CoreDataPrivacyDataRequestsLinkHandlerService extends CoreContentLinksHandlerBase { | ||||||
|  | 
 | ||||||
|  |     name = 'CoreDataPrivacyDataRequestsLinkHandler'; | ||||||
|  |     pattern = /\/admin\/tool\/dataprivacy\/mydatarequests\.php/; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @inheritdoc | ||||||
|  |      */ | ||||||
|  |     getActions(): CoreContentLinksAction[] { | ||||||
|  |         return [{ | ||||||
|  |             action: async (siteId): Promise<void> => { | ||||||
|  |                 await CoreNavigator.navigateToSitePath(CORE_DATAPRIVACY_PAGE_NAME, { siteId }); | ||||||
|  |             }, | ||||||
|  |         }]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * @inheritdoc | ||||||
|  |      */ | ||||||
|  |     async isEnabled(): Promise<boolean> { | ||||||
|  |         return await CoreDataPrivacy.isEnabled(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export const CoreDataPrivacyDataRequestsLinkHandler = makeSingleton(CoreDataPrivacyDataRequestsLinkHandlerService); | ||||||
| @ -32,7 +32,7 @@ export class CoreDataPrivacyUserHandlerService implements CoreUserProfileHandler | |||||||
|     protected pageName = CORE_DATAPRIVACY_PAGE_NAME; |     protected pageName = CORE_DATAPRIVACY_PAGE_NAME; | ||||||
| 
 | 
 | ||||||
|     type = CoreUserProfileHandlerType.LIST_ACCOUNT_ITEM; |     type = CoreUserProfileHandlerType.LIST_ACCOUNT_ITEM; | ||||||
|     name = 'CoreDataPrivacyDelegate'; |     name = 'CoreDataPrivacy'; | ||||||
|     priority = 100; |     priority = 100; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -0,0 +1,71 @@ | |||||||
|  | // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||||
|  | //
 | ||||||
|  | // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||||
|  | // you may not use this file except in compliance with the License.
 | ||||||
|  | // You may obtain a copy of the License at
 | ||||||
|  | //
 | ||||||
|  | //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||||
|  | //
 | ||||||
|  | // Unless required by applicable law or agreed to in writing, software
 | ||||||
|  | // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||||
|  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||||
|  | // See the License for the specific language governing permissions and
 | ||||||
|  | // limitations under the License.
 | ||||||
|  | 
 | ||||||
|  | import { CoreDataPrivacyDataRequestsLinkHandler } from '@features/dataprivacy/services/handlers/datarequests-link'; | ||||||
|  | import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
|  | import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper'; | ||||||
|  | import { mockSingleton } from '@/testing/utils'; | ||||||
|  | import { CoreSites } from '@services/sites'; | ||||||
|  | import { CoreSite } from '@classes/sites/site'; | ||||||
|  | import { CoreNavigator } from '@services/navigator'; | ||||||
|  | import { CORE_DATAPRIVACY_PAGE_NAME } from '@features/dataprivacy/constants'; | ||||||
|  | import { CoreDataPrivacyCreateDataRequestLinkHandler } from '../services/handlers/createdatarequest-link'; | ||||||
|  | import { CoreDataPrivacy } from '../services/dataprivacy'; | ||||||
|  | 
 | ||||||
|  | describe('CoreDataPrivacyDataRequestsLinkHandlerService', () => { | ||||||
|  | 
 | ||||||
|  |     let site: CoreSite; | ||||||
|  | 
 | ||||||
|  |     beforeAll(() => { | ||||||
|  |         site = new CoreSite('siteId', 'https://school.edu', ''); | ||||||
|  | 
 | ||||||
|  |         mockSingleton(CoreDataPrivacy, { | ||||||
|  |             isEnabled: () => Promise.resolve(true), | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         CoreContentLinksDelegate.registerHandler(CoreDataPrivacyDataRequestsLinkHandler.instance); | ||||||
|  |         CoreContentLinksDelegate.registerHandler(CoreDataPrivacyCreateDataRequestLinkHandler.instance); | ||||||
|  | 
 | ||||||
|  |         mockSingleton(CoreNavigator, ['navigateToSitePath']); | ||||||
|  |         mockSingleton(CoreSites, { | ||||||
|  |             isLoggedIn: () => true, | ||||||
|  |             getCurrentSiteId: () => site.id, | ||||||
|  |             getSiteIdsFromUrl: () => Promise.resolve([site.id]), | ||||||
|  |             getSite: () => Promise.resolve(site), | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it('opens data privacy page', async () => { | ||||||
|  |         await CoreContentLinksHelper.handleLink('https://school.edu/admin/tool/dataprivacy/mydatarequests.php'); | ||||||
|  | 
 | ||||||
|  |         expect(CoreNavigator.navigateToSitePath).toHaveBeenCalledWith(CORE_DATAPRIVACY_PAGE_NAME, { siteId: site.id }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it('opens data request modal', async () => { | ||||||
|  |         await CoreContentLinksHelper.handleLink('https://school.edu/admin/tool/dataprivacy/createdatarequest.php?type=1'); | ||||||
|  | 
 | ||||||
|  |         expect(CoreNavigator.navigateToSitePath).toHaveBeenCalledWith( | ||||||
|  |             CORE_DATAPRIVACY_PAGE_NAME, | ||||||
|  |             { params: { createType: 1 }, siteId: site.id }, | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         await CoreContentLinksHelper.handleLink('https://school.edu/admin/tool/dataprivacy/createdatarequest.php?type=3'); | ||||||
|  | 
 | ||||||
|  |         expect(CoreNavigator.navigateToSitePath).toHaveBeenCalledWith( | ||||||
|  |             CORE_DATAPRIVACY_PAGE_NAME, | ||||||
|  |             { params: { createType: 3 }, siteId: site.id }, | ||||||
|  |         ); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  | }); | ||||||
| @ -36,8 +36,8 @@ export class CoreGradesOverviewLinkHandlerService extends CoreContentLinksHandle | |||||||
|      */ |      */ | ||||||
|     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: siteId => { |             action: async siteId => { | ||||||
|                 CoreNavigator.navigateToSitePath(GRADES_PAGE_NAME, { siteId }); |                 await CoreNavigator.navigateToSitePath(GRADES_PAGE_NAME, { siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -43,11 +43,11 @@ export class CoreGradesReportLinkHandlerService extends CoreContentLinksHandlerB | |||||||
|         data = data || {}; |         data = data || {}; | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const userId = params.userid ? parseInt(params.userid, 10) : undefined; |                 const userId = params.userid ? parseInt(params.userid, 10) : undefined; | ||||||
|                 const moduleId = data?.cmid && parseInt(data.cmid, 10) || undefined; |                 const moduleId = data?.cmid && parseInt(data.cmid, 10) || undefined; | ||||||
| 
 | 
 | ||||||
|                 CoreGradesHelper.goToGrades(courseIdentifier, userId, moduleId, siteId); |                 await CoreGradesHelper.goToGrades(courseIdentifier, userId, moduleId, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -43,11 +43,11 @@ export class CoreGradesUserLinkHandlerService extends CoreContentLinksHandlerBas | |||||||
|         data = data || {}; |         data = data || {}; | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const userId = params.user ? parseInt(params.user, 10) : undefined; |                 const userId = params.user ? parseInt(params.user, 10) : undefined; | ||||||
|                 const moduleId = data?.cmid && parseInt(data.cmid, 10) || undefined; |                 const moduleId = data?.cmid && parseInt(data.cmid, 10) || undefined; | ||||||
| 
 | 
 | ||||||
|                 CoreGradesHelper.goToGrades(courseIdentifier, userId, moduleId, siteId); |                 await CoreGradesHelper.goToGrades(courseIdentifier, userId, moduleId, siteId); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -13,7 +13,6 @@ | |||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { Params } from '@angular/router'; |  | ||||||
| import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; | ||||||
| import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; | ||||||
| import { CoreNavigator } from '@services/navigator'; | import { CoreNavigator } from '@services/navigator'; | ||||||
| @ -34,10 +33,13 @@ export class CoreReportBuilderLinkHandlerService extends CoreContentLinksHandler | |||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Params): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: async (siteId): Promise<void> => { |             action: async (siteId): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(`${CoreReportBuilderHandlerService.PAGE_NAME}/${params.id || ''}`, { siteId }); |                 await CoreNavigator.navigateToSitePath( | ||||||
|  |                     `${CoreReportBuilderHandlerService.PAGE_NAME}/${params.id || ''}`, | ||||||
|  |                     { siteId }, | ||||||
|  |                 ); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -41,8 +41,8 @@ export class CoreSearchGlobalSearchLinkHandlerService extends CoreContentLinksHa | |||||||
|      */ |      */ | ||||||
|     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { |     getActions(siteIds: string[], url: string, params: Record<string, string>): CoreContentLinksAction[] { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath(CORE_SEARCH_PAGE_NAME, { |                 await CoreNavigator.navigateToSitePath(CORE_SEARCH_PAGE_NAME, { | ||||||
|                     siteId, |                     siteId, | ||||||
|                     params: { |                     params: { | ||||||
|                         query: params.q, |                         query: params.q, | ||||||
|  | |||||||
| @ -46,8 +46,8 @@ export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandler | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId: string): void => { |             action: async (siteId: string): Promise<void> => { | ||||||
|                 CoreNavigator.navigateToSitePath( |                 await CoreNavigator.navigateToSitePath( | ||||||
|                     `/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreSiteHomeHomeHandlerService.PAGE_NAME}`, |                     `/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreSiteHomeHomeHandlerService.PAGE_NAME}`, | ||||||
|                     { |                     { | ||||||
|                         preferCurrentTab: false, |                         preferCurrentTab: false, | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ export class CoreTagIndexLinkHandlerService extends CoreContentLinksHandlerBase | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const pageParams = { |                 const pageParams = { | ||||||
|                     tagId: parseInt(params.id, 10) || 0, |                     tagId: parseInt(params.id, 10) || 0, | ||||||
|                     tagName: params.tag || '', |                     tagName: params.tag || '', | ||||||
| @ -50,11 +50,11 @@ export class CoreTagIndexLinkHandlerService extends CoreContentLinksHandlerBase | |||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 if (!pageParams.tagId && (!pageParams.tagName || !pageParams.collectionId)) { |                 if (!pageParams.tagId && (!pageParams.tagName || !pageParams.collectionId)) { | ||||||
|                     CoreNavigator.navigateToSitePath('/tag/search', { siteId }); |                     await CoreNavigator.navigateToSitePath('/tag/search', { siteId }); | ||||||
|                 } else if (pageParams.areaId) { |                 } else if (pageParams.areaId) { | ||||||
|                     CoreNavigator.navigateToSitePath('/tag/index-area', { params: pageParams, siteId }); |                     await CoreNavigator.navigateToSitePath('/tag/index-area', { params: pageParams, siteId }); | ||||||
|                 } else { |                 } else { | ||||||
|                     CoreNavigator.navigateToSitePath('/tag/index', { params: pageParams, siteId }); |                     await CoreNavigator.navigateToSitePath('/tag/index', { params: pageParams, siteId }); | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|  | |||||||
| @ -38,13 +38,13 @@ export class CoreTagSearchLinkHandlerService extends CoreContentLinksHandlerBase | |||||||
|         params: Record<string, string>, |         params: Record<string, string>, | ||||||
|     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { |     ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { | ||||||
|         return [{ |         return [{ | ||||||
|             action: (siteId): void => { |             action: async (siteId): Promise<void> => { | ||||||
|                 const pageParams = { |                 const pageParams = { | ||||||
|                     collectionId: parseInt(params.tc, 10) || 0, |                     collectionId: parseInt(params.tc, 10) || 0, | ||||||
|                     query: params.query || '', |                     query: params.query || '', | ||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 CoreNavigator.navigateToSitePath('/tag/search', { params: pageParams, siteId }); |                 await CoreNavigator.navigateToSitePath('/tag/search', { params: pageParams, siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -52,7 +52,7 @@ export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBa | |||||||
|                     userId, |                     userId, | ||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|                 CoreNavigator.navigateToSitePath('/user', { params: pageParams, siteId }); |                 await CoreNavigator.navigateToSitePath('/user', { params: pageParams, siteId }); | ||||||
|             }, |             }, | ||||||
|         }]; |         }]; | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user