Merge pull request #2531 from crazyserver/MOBILE-3469
MOBILE-3469 course: Hide blocks on single activitymain
commit
ac22f6945a
|
@ -2,7 +2,7 @@
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="blocks && blocks.length > 0" [class.core-hide-blocks]="hideBlocks" class="core-course-blocks-side">
|
<div *ngIf="blocks && blocks.length > 0 && !hideBlocks" [class.core-hide-blocks]="hideBottomBlocks" class="core-course-blocks-side">
|
||||||
<core-loading [hideUntil]="dataLoaded" class="core-loading-center">
|
<core-loading [hideUntil]="dataLoaded" class="core-loading-center">
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<!-- Course blocks. -->
|
<!-- Course blocks. -->
|
||||||
|
|
|
@ -30,6 +30,7 @@ export class CoreBlockCourseBlocksComponent implements OnInit {
|
||||||
|
|
||||||
@Input() courseId: number;
|
@Input() courseId: number;
|
||||||
@Input() hideBlocks = false;
|
@Input() hideBlocks = false;
|
||||||
|
@Input() hideBottomBlocks = false;
|
||||||
@Input() downloadEnabled: boolean;
|
@Input() downloadEnabled: boolean;
|
||||||
|
|
||||||
@ViewChildren(CoreBlockComponent) blocksComponents: QueryList<CoreBlockComponent>;
|
@ViewChildren(CoreBlockComponent) blocksComponents: QueryList<CoreBlockComponent>;
|
||||||
|
@ -49,6 +50,7 @@ export class CoreBlockCourseBlocksComponent implements OnInit {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.element.classList.add('core-no-blocks');
|
||||||
this.loadContent().finally(() => {
|
this.loadContent().finally(() => {
|
||||||
this.dataLoaded = true;
|
this.dataLoaded = true;
|
||||||
});
|
});
|
||||||
|
@ -89,7 +91,7 @@ export class CoreBlockCourseBlocksComponent implements OnInit {
|
||||||
|
|
||||||
this.blocks = [];
|
this.blocks = [];
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
if (this.blocks.length > 0) {
|
if (!this.hideBlocks && this.blocks.length > 0) {
|
||||||
this.element.classList.add('core-has-blocks');
|
this.element.classList.add('core-has-blocks');
|
||||||
this.element.classList.remove('core-no-blocks');
|
this.element.classList.remove('core-no-blocks');
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</core-context-menu>
|
</core-context-menu>
|
||||||
</core-navbar-buttons>
|
</core-navbar-buttons>
|
||||||
|
|
||||||
<core-block-course-blocks [courseId]="course.id" [hideBlocks]="selectedSection && selectedSection.id == allSectionsId && canLoadMore" [downloadEnabled]="downloadEnabled">
|
<core-block-course-blocks [courseId]="course.id" [hideBottomBlocks]="selectedSection && selectedSection.id == allSectionsId && canLoadMore" [hideBlocks]="!displayBlocks" [downloadEnabled]="downloadEnabled">
|
||||||
<!-- Default course format. -->
|
<!-- Default course format. -->
|
||||||
<core-dynamic-component [component]="courseFormatComponent" [data]="data">
|
<core-dynamic-component [component]="courseFormatComponent" [data]="data">
|
||||||
<core-loading [hideUntil]="loaded">
|
<core-loading [hideUntil]="loaded">
|
||||||
|
|
|
@ -69,6 +69,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
data: any = {};
|
data: any = {};
|
||||||
|
|
||||||
displaySectionSelector: boolean;
|
displaySectionSelector: boolean;
|
||||||
|
displayBlocks: boolean;
|
||||||
selectedSection: any;
|
selectedSection: any;
|
||||||
previousSection: any;
|
previousSection: any;
|
||||||
nextSection: any;
|
nextSection: any;
|
||||||
|
@ -158,6 +159,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.displaySectionSelector = this.cfDelegate.displaySectionSelector(this.course);
|
this.displaySectionSelector = this.cfDelegate.displaySectionSelector(this.course);
|
||||||
|
this.displayBlocks = this.cfDelegate.displayBlocks(this.course);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,6 +48,16 @@ export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the option blocks should be displayed. Defaults to true.
|
||||||
|
*
|
||||||
|
* @param course The course to check.
|
||||||
|
* @return Whether it can display blocks.
|
||||||
|
*/
|
||||||
|
displayBlocks(course: any): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the title to use in course page. If not defined, course displayname or fullname.
|
* Get the title to use in course page. If not defined, course displayname or fullname.
|
||||||
* This function will be called without sections first, and then call it again when the sections are retrieved.
|
* This function will be called without sections first, and then call it again when the sections are retrieved.
|
||||||
|
|
|
@ -65,6 +65,16 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the option blocks should be displayed. Defaults to true.
|
||||||
|
*
|
||||||
|
* @param course The course to check.
|
||||||
|
* @return Whether it can display blocks.
|
||||||
|
*/
|
||||||
|
displayBlocks(course: any): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
||||||
*
|
*
|
||||||
|
|
|
@ -47,6 +47,14 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
|
||||||
*/
|
*/
|
||||||
canViewAllSections?(course: any): boolean;
|
canViewAllSections?(course: any): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the option blocks should be displayed. Defaults to true.
|
||||||
|
*
|
||||||
|
* @param course The course to check.
|
||||||
|
* @return Whether it can display blocks.
|
||||||
|
*/
|
||||||
|
displayBlocks?(course: any): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
||||||
*
|
*
|
||||||
|
@ -191,6 +199,16 @@ export class CoreCourseFormatDelegate extends CoreDelegate {
|
||||||
return this.executeFunctionOnEnabled(course.format, 'canViewAllSections', [course]);
|
return this.executeFunctionOnEnabled(course.format, 'canViewAllSections', [course]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the option blocks should be displayed. Defaults to true.
|
||||||
|
*
|
||||||
|
* @param course The course to check.
|
||||||
|
* @return Whether it can display blocks.
|
||||||
|
*/
|
||||||
|
displayBlocks?(course: any): boolean {
|
||||||
|
return this.executeFunctionOnEnabled(course.format, 'displayBlocks', [course]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
* Whether the option to enable section/module download should be displayed. Defaults to true.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue