Merge pull request #2963 from dpalou/MOBILE-3798

MOBILE-3798 competency: Remove learning plans from main menu
main
Pau Ferrer Ocaña 2021-09-30 17:11:32 +02:00 committed by GitHub
commit 5e321b57c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 32 additions and 95 deletions

View File

@ -17,7 +17,7 @@ import { CoreBlockHandlerData } from '@features/block/services/block-delegate';
import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block';
import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler';
import { makeSingleton } from '@singletons';
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Block handler.
@ -38,7 +38,7 @@ export class AddonBlockLearningPlansHandlerService extends CoreBlockBaseHandler
title: 'addon.block_learningplans.pluginname',
class: 'addon-block-learning-plans',
component: CoreBlockOnlyTitleComponent,
link: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
link: ADDON_COMPETENCY_MAIN_PAGE_NAME,
navOptions: {
preferCurrentTab: false,
},

View File

@ -25,15 +25,11 @@ import { AddonCompetencyCompetencyPage } from './pages/competency/competency';
import { AddonCompetencyCompetencySummaryPage } from './pages/competencysummary/competencysummary';
import { AddonCompetencyCourseCompetenciesPage } from './pages/coursecompetencies/coursecompetencies.page';
import { AddonCompetencyCourseCompetenciesPageModule } from './pages/coursecompetencies/coursecompetencies.module';
import { AddonCompetencyMainMenuHandlerService } from './services/handlers/mainmenu';
const mobileRoutes: Routes = [
{
path: '',
pathMatch: 'full',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage,
},
{
@ -79,9 +75,6 @@ const tabletRoutes: Routes = [
},
{
path: '',
data: {
mainMenuTabRoot: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
},
component: AddonCompetencyPlanListPage,
children: [
{

View File

@ -15,14 +15,12 @@
import { APP_INITIALIZER, NgModule, Type } from '@angular/core';
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate';
import { CoreUserDelegate } from '@features/user/services/user-delegate';
import { AddonCompetencyProvider } from './services/competency';
import { AddonCompetencyHelperProvider } from './services/competency-helper';
import { AddonCompetencyCompetencyLinkHandler } from './services/handlers/competency-link';
import { AddonCompetencyCourseOptionHandler } from './services/handlers/course-option';
import { AddonCompetencyMainMenuHandler, AddonCompetencyMainMenuHandlerService } from './services/handlers/mainmenu';
import { AddonCompetencyPlanLinkHandler } from './services/handlers/plan-link';
import { AddonCompetencyPlansLinkHandler } from './services/handlers/plans-link';
import { AddonCompetencyPushClickHandler } from './services/handlers/push-click';
@ -39,16 +37,18 @@ export const ADDON_COMPETENCY_SERVICES: Type<unknown>[] = [
AddonCompetencyHelperProvider,
];
export const ADDON_COMPETENCY_MAIN_PAGE_NAME = 'competency';
const mainMenuChildrenRoutes: Routes = [
{
path: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
path: ADDON_COMPETENCY_MAIN_PAGE_NAME,
loadChildren: () => import('./competency-lazy.module').then(m => m.AddonCompetencyLazyModule),
},
];
const courseIndexRoutes: Routes = [
{
path: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
path: ADDON_COMPETENCY_MAIN_PAGE_NAME,
loadChildren: () => import('@addons/competency/competency-course-lazy.module').then(m => m.AddonCompetencyCourseLazyModule),
},
];
@ -56,7 +56,6 @@ const courseIndexRoutes: Routes = [
@NgModule({
imports: [
CoreMainMenuTabRoutingModule.forChild(mainMenuChildrenRoutes),
CoreMainMenuRoutingModule.forChild({ children: mainMenuChildrenRoutes }),
CoreCourseIndexRoutingModule.forChild({ children: courseIndexRoutes }),
],
exports: [CoreMainMenuRoutingModule],
@ -69,7 +68,6 @@ const courseIndexRoutes: Routes = [
CoreContentLinksDelegate.registerHandler(AddonCompetencyPlanLinkHandler.instance);
CoreContentLinksDelegate.registerHandler(AddonCompetencyPlansLinkHandler.instance);
CoreContentLinksDelegate.registerHandler(AddonCompetencyUserCompetencyLinkHandler.instance);
CoreMainMenuDelegate.registerHandler(AddonCompetencyMainMenuHandler.instance);
CoreUserDelegate.registerHandler(AddonCompetencyUserHandler.instance);
CoreCourseOptionsDelegate.registerHandler(AddonCompetencyCourseOptionHandler.instance);
CorePushNotificationsDelegate.registerClickHandler(AddonCompetencyPushClickHandler.instance);

View File

@ -32,7 +32,7 @@ import { CoreNavigator } from '@services/navigator';
import { IonRefresher } from '@ionic/angular';
import { ContextLevel } from '@/core/constants';
import { CoreUtils } from '@services/utils/utils';
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Page that displays the competency information.
@ -184,7 +184,7 @@ export class AddonCompetencyCompetencyPage implements OnInit {
*/
openCompetencySummary(competencyId: number): void {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/summary/' + competencyId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId,
{
params: { contextLevel: this.contextLevel, contextInstanceId: this.contextInstanceId },
},

View File

@ -19,7 +19,7 @@ import { IonRefresher } from '@ionic/angular';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Page that displays the competency summary.
@ -102,7 +102,7 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit {
*/
openCompetencySummary(competencyId: number): void {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/summary/' + competencyId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId,
{
params: { contextLevel: this.contextLevel, contextInstanceId: this.contextInstanceId },
},

View File

@ -19,8 +19,8 @@ import { CoreUserProfile } from '@features/user/services/user';
import { IonRefresher } from '@ionic/angular';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
import { ContextLevel } from '@/core/constants';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Page that displays the list of competencies of a course.
@ -81,7 +81,7 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit {
*/
openCompetency(competencyId: number): void {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/competencies/' + competencyId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
{
params: { courseId: this.courseId, userId: this.userId },
},
@ -94,7 +94,7 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit {
* @param competencyId
*/
openCompetencySummary(competencyId: number): void {
CoreNavigator.navigateToSitePath('/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/summary/' + competencyId, {
CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + competencyId, {
params: {
contextLevel: ContextLevel.COURSE,
contextInstanceId: this.courseId,

View File

@ -19,7 +19,7 @@ import { AddonCompetencyHelper } from '../../services/competency-helper';
import { CoreNavigator } from '@services/navigator';
import { CoreUserProfile } from '@features/user/services/user';
import { IonRefresher } from '@ionic/angular';
import { AddonCompetencyMainMenuHandlerService } from '@addons/competency/services/handlers/mainmenu';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Page that displays a learning plan.
@ -80,7 +80,7 @@ export class AddonCompetencyPlanPage implements OnInit {
*/
openCompetency(competencyId: number): void {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/competencies/' + competencyId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
{ params: { planId: this.planId } },
);
}

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Handler to treat links to a competency in a plan or in a course.
@ -44,7 +44,7 @@ export class AddonCompetencyCompetencyLinkHandlerService extends CoreContentLink
};
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/competencies/' + params.competencyid,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + params.competencyid,
{ params: pageParams, siteId },
);

View File

@ -25,7 +25,7 @@ import { CoreCourseUserAdminOrNavOptionIndexed } from '@features/courses/service
import { CoreEnrolledCourseDataWithExtraInfoAndOptions } from '@features/courses/services/courses-helper';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { ContextLevel } from '@/core/constants';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
/**
* Course nav handler.
@ -75,7 +75,7 @@ export class AddonCompetencyCourseOptionHandlerService implements CoreCourseOpti
return {
title: 'addon.competency.competencies',
class: 'addon-competency-course-handler',
page: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
page: ADDON_COMPETENCY_MAIN_PAGE_NAME,
};
}

View File

@ -1,54 +0,0 @@
// (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 { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
/**
* Handler to inject an option into main menu.
*/
@Injectable( { providedIn: 'root' })
export class AddonCompetencyMainMenuHandlerService implements CoreMainMenuHandler {
static readonly PAGE_NAME = 'competency';
name = 'AddonCompetency';
priority = 500;
/**
* @inheritdoc
*/
async isEnabled(): Promise<boolean> {
// Check the user has at least one learn plan available.
const plans = await AddonCompetency.getLearningPlans();
return plans.length > 0;
}
/**
* @inheritdoc
*/
getDisplayData(): CoreMainMenuHandlerData {
return {
icon: 'fas-route',
title: 'addon.competency.myplans',
page: AddonCompetencyMainMenuHandlerService.PAGE_NAME,
class: 'addon-competency-handler',
};
}
}
export const AddonCompetencyMainMenuHandler = makeSingleton(AddonCompetencyMainMenuHandlerService);

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Handler to treat links to a plan.
@ -36,7 +36,7 @@ export class AddonCompetencyPlanLinkHandlerService extends CoreContentLinksHandl
return [{
action: (siteId: string): void => {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/' + params.id,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/' + params.id,
{ siteId },
);
},

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Handler to treat links to user plans.
@ -36,7 +36,7 @@ export class AddonCompetencyPlansLinkHandlerService extends CoreContentLinksHand
return [{
action: (siteId: string): void => {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME,
ADDON_COMPETENCY_MAIN_PAGE_NAME,
{ params: { userId: params.userid }, siteId },
);

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate';
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
@ -20,7 +21,6 @@ import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Handler for competencies push notifications clicks.
@ -56,7 +56,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
await CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlan(planId, notification.site));
await CoreNavigator.navigateToSitePath('/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/' + planId, {
await CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME + '/' + planId, {
siteId: notification.site,
});
@ -72,7 +72,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
await CoreUtils.ignoreErrors(AddonCompetency.invalidateCompetencyInPlan(planId, competencyId, notification.site));
await CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/competencies/' + competencyId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/competencies/' + competencyId,
{
params: { planId, courseId, userId },
siteId: notification.site,
@ -87,7 +87,7 @@ export class AddonCompetencyPushClickHandlerService implements CorePushNotificat
await CoreUtils.ignoreErrors(AddonCompetency.invalidateLearningPlans(userId, notification.site));
await CoreNavigator.navigateToSitePath('/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME, {
await CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME, {
params: { userId },
siteId: notification.site,
});

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Handler to treat links to a usr competency.
@ -37,7 +37,7 @@ export class AddonCompetencyUserCompetencyLinkHandlerService extends CoreContent
return [{
action: (siteId: string): void => {
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/summary/' + params.id,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/summary/' + params.id,
{ siteId },
);

View File

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { ADDON_COMPETENCY_MAIN_PAGE_NAME } from '@addons/competency/competency.module';
import { Injectable } from '@angular/core';
import { CoreUserProfile } from '@features/user/services/user';
import { CoreUserProfileHandler, CoreUserDelegateService, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { AddonCompetency } from '../competency';
import { AddonCompetencyMainMenuHandlerService } from './mainmenu';
/**
* Profile competencies handler.
@ -69,7 +69,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
event.preventDefault();
event.stopPropagation();
CoreNavigator.navigateToSitePath(
'/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME + '/course/' + courseId,
ADDON_COMPETENCY_MAIN_PAGE_NAME + '/course/' + courseId,
{
params: { userId: user.id },
},
@ -85,7 +85,7 @@ export class AddonCompetencyUserHandlerService implements CoreUserProfileHandler
action: (event, user): void => {
event.preventDefault();
event.stopPropagation();
CoreNavigator.navigateToSitePath('/' + AddonCompetencyMainMenuHandlerService.PAGE_NAME, {
CoreNavigator.navigateToSitePath(ADDON_COMPETENCY_MAIN_PAGE_NAME, {
params: { userId: user.id },
});
},