Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy {

@Input() contextLevel!: string;
@Input() instanceId!: number;
@Input() myDashboardPage?: string;

userTour: CoreUserTourDirectiveOptions = {
id: 'side-blocks-button',
Expand Down Expand Up @@ -69,6 +70,7 @@ export class CoreBlockSideBlocksButtonComponent implements OnInit, OnDestroy {
componentProps: {
contextLevel: this.contextLevel,
instanceId: this.instanceId,
myDashboardPage: this.myDashboardPage,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class CoreBlockSideBlocksComponent implements OnInit {

@Input() contextLevel!: string;
@Input() instanceId!: number;
@Input() myDashboardPage?: string;

@ViewChildren(CoreBlockComponent) blocksComponents?: QueryList<CoreBlockComponent>;

Expand Down Expand Up @@ -83,7 +84,7 @@ export class CoreBlockSideBlocksComponent implements OnInit {
if (this.contextLevel === 'course') {
this.blocks = await CoreBlockHelper.getCourseBlocks(this.instanceId);
} else {
const blocks = await CoreCoursesDashboard.getDashboardBlocks();
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myDashboardPage);

this.blocks = blocks.sideBlocks;
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/features/courses/pages/my/my.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ <h2 class="big">{{ 'core.courses.mycourses' | translate }}</h2>
<core-block *ngIf="loadedBlock?.visible" [block]="loadedBlock" contextLevel="user" [instanceId]="userId"></core-block>
</ion-list>

<core-block-side-blocks-button slot="fixed" *ngIf="hasSideBlocks" contextLevel="user" [instanceId]="userId"
[myDashboardPage]="myPageCourses">
</core-block-side-blocks-button>

<core-empty-box *ngIf="!loadedBlock" icon="fas-cubes" [message]="'core.course.nocontentavailable' | translate">
</core-empty-box>
</core-loading>
Expand Down
8 changes: 6 additions & 2 deletions src/core/features/courses/pages/my/my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
loadedBlock?: Partial<CoreCourseBlock>;
myOverviewBlock?: AddonBlockMyOverviewComponent;
loaded = false;
myPageCourses = CoreCoursesDashboardProvider.MY_PAGE_COURSES;
hasSideBlocks = false;

protected updateSiteObserver: CoreEventObserver;

Expand Down Expand Up @@ -79,9 +81,11 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {

if (available && !disabled) {
try {
const blocks = await CoreCoursesDashboard.getDashboardBlocksFromWS(CoreCoursesDashboardProvider.MY_PAGE_COURSES);
const blocks = await CoreCoursesDashboard.getDashboardBlocks(undefined, undefined, this.myPageCourses);

this.loadedBlock = blocks.find((block) => block.name == 'myoverview');
// My overview block should always be in main blocks, but check side blocks too just in case.
this.loadedBlock = blocks.mainBlocks.concat(blocks.sideBlocks).find((block) => block.name == 'myoverview');
this.hasSideBlocks = blocks.sideBlocks.length > 0;

await CoreUtils.nextTicks(2);

Expand Down
9 changes: 7 additions & 2 deletions src/core/features/courses/services/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ export class CoreCoursesDashboardProvider {
*
* @param userId User ID. Default, current user.
* @param siteId Site ID. If not defined, current site.
* @param myPage What my page to return blocks of. Default MY_PAGE_DEFAULT.
* @return Promise resolved with the list of blocks.
*/
async getDashboardBlocks(userId?: number, siteId?: string): Promise<CoreCoursesDashboardBlocks> {
const blocks = await this.getDashboardBlocksFromWS(CoreCoursesDashboardProvider.MY_PAGE_DEFAULT, userId, siteId);
async getDashboardBlocks(
userId?: number,
siteId?: string,
myPage = CoreCoursesDashboardProvider.MY_PAGE_DEFAULT,
): Promise<CoreCoursesDashboardBlocks> {
const blocks = await this.getDashboardBlocksFromWS(myPage, userId, siteId);

let mainBlocks: CoreCourseBlock[] = [];
let sideBlocks: CoreCourseBlock[] = [];
Expand Down