Merge pull request #3194 from NoelDeMartin/MOBILE-3833

MOBILE-3833 courses: Add site home link handler & fix site listing styles
main
Dani Palou 2022-03-22 12:29:17 +01:00 committed by GitHub
commit 64da66be79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 10 deletions

View File

@ -15,17 +15,18 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
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 { CoreMainMenuHomeHandlerService } from '@features/mainmenu/services/handlers/mainmenu';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreDashboardHomeHandler, CoreDashboardHomeHandlerService } from './dashboard-home'; import { CoreDashboardHomeHandler, CoreDashboardHomeHandlerService } from './dashboard-home';
/** /**
* Handler to treat links to my overview. * Handler to treat links to dashboard.
*/ */
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class CoreCoursesDashboardLinkHandlerService extends CoreContentLinksHandlerBase { export class CoreCoursesDashboardLinkHandlerService extends CoreContentLinksHandlerBase {
name = 'CoreCoursesMyOverviewLinkHandler'; name = 'CoreCoursesDashboardLinkHandler';
pattern = /\/my\/?$/; pattern = /\/my\/?$/;
/** /**
@ -37,7 +38,13 @@ export class CoreCoursesDashboardLinkHandlerService extends CoreContentLinksHand
return [{ return [{
action: (siteId): void => { action: (siteId): void => {
// Use redirect to select the tab. // Use redirect to select the tab.
CoreNavigator.navigateToSitePath(CoreDashboardHomeHandlerService.PAGE_NAME, { siteId }); CoreNavigator.navigateToSitePath(
`/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreDashboardHomeHandlerService.PAGE_NAME}`,
{
siteId,
preferCurrentTab: false,
},
);
}, },
}]; }];
} }

View File

@ -38,7 +38,8 @@
max-width: fit-content; max-width: fit-content;
width: auto; width: auto;
height: auto; height: auto;
margin: 0 50% 0 auto; // LTR will be applied on transform. margin: 0 auto;
margin-left: 50%;
@include transform(translate3d(-50%,0,0)); @include transform(translate3d(-50%,0,0));
object-fit: cover; object-fit: cover;
object-position: 50% 50%; object-position: 50% 50%;
@ -50,6 +51,15 @@
} }
} }
:host-context([dir="rtl"]) {
.item ion-thumbnail img {
margin-left: 0;
margin-right: 50%;
}
}
.core-login-site-logo, .core-login-site-logo,
.core-login-site-list, .core-login-site-list,
.core-login-site-list-found { .core-login-site-list-found {

View File

@ -20,6 +20,8 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl
import { CoreSiteHome } from '../sitehome'; import { CoreSiteHome } from '../sitehome';
import { makeSingleton } from '@singletons'; import { makeSingleton } from '@singletons';
import { CoreNavigator } from '@services/navigator'; import { CoreNavigator } from '@services/navigator';
import { CoreSiteHomeHomeHandlerService } from './sitehome-home';
import { CoreMainMenuHomeHandlerService } from '@features/mainmenu/services/handlers/mainmenu';
/** /**
* Handler to treat links to site home index. * Handler to treat links to site home index.
@ -29,7 +31,7 @@ export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandler
name = 'CoreSiteHomeIndexLinkHandler'; name = 'CoreSiteHomeIndexLinkHandler';
featureName = 'CoreMainMenuDelegate_CoreSiteHome'; featureName = 'CoreMainMenuDelegate_CoreSiteHome';
pattern = /\/course\/view\.php.*([?&]id=\d+)/; pattern = /\/course\/view\.php.*([?&]id=\d+)|\/index\.php(\?redirect=0)?/;
/** /**
* @inheritdoc * @inheritdoc
@ -37,10 +39,13 @@ export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandler
getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> { getActions(): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
return [{ return [{
action: (siteId: string): void => { action: (siteId: string): void => {
CoreNavigator.navigateToSitePath('/home/site', { CoreNavigator.navigateToSitePath(
`/${CoreMainMenuHomeHandlerService.PAGE_NAME}/${CoreSiteHomeHomeHandlerService.PAGE_NAME}`,
{
preferCurrentTab: false, preferCurrentTab: false,
siteId, siteId,
}); },
);
}, },
}]; }];
} }
@ -51,7 +56,7 @@ export class CoreSiteHomeIndexLinkHandlerService extends CoreContentLinksHandler
async isEnabled(siteId: string, url: string, params: Record<string, string>, courseId?: number): Promise<boolean> { async isEnabled(siteId: string, url: string, params: Record<string, string>, courseId?: number): Promise<boolean> {
courseId = parseInt(params.id, 10); courseId = parseInt(params.id, 10);
if (!courseId) { if (!courseId) {
return false; return url.includes('index.php');
} }
const site = await CoreSites.getSite(siteId); const site = await CoreSites.getSite(siteId);