forked from CIT/Vmeda.Online
		
	MOBILE-3002 block: Support for pre rendered block type
This commit is contained in:
		
							parent
							
								
									f368333ca1
								
							
						
					
					
						commit
						34061ad5ab
					
				| @ -19,6 +19,7 @@ import { TranslateModule } from '@ngx-translate/core'; | ||||
| import { CoreDirectivesModule } from '@directives/directives.module'; | ||||
| import { CoreBlockComponent } from './block/block'; | ||||
| import { CoreBlockOnlyTitleComponent } from './only-title-block/only-title-block'; | ||||
| import { CoreBlockPreRenderedComponent } from './pre-rendered-block/pre-rendered-block'; | ||||
| import { CoreBlockCourseBlocksComponent } from './course-blocks/course-blocks'; | ||||
| import { CoreComponentsModule } from '@components/components.module'; | ||||
| 
 | ||||
| @ -26,6 +27,7 @@ import { CoreComponentsModule } from '@components/components.module'; | ||||
|     declarations: [ | ||||
|         CoreBlockComponent, | ||||
|         CoreBlockOnlyTitleComponent, | ||||
|         CoreBlockPreRenderedComponent, | ||||
|         CoreBlockCourseBlocksComponent | ||||
|     ], | ||||
|     imports: [ | ||||
| @ -40,10 +42,12 @@ import { CoreComponentsModule } from '@components/components.module'; | ||||
|     exports: [ | ||||
|         CoreBlockComponent, | ||||
|         CoreBlockOnlyTitleComponent, | ||||
|         CoreBlockPreRenderedComponent, | ||||
|         CoreBlockCourseBlocksComponent | ||||
|     ], | ||||
|     entryComponents: [ | ||||
|         CoreBlockOnlyTitleComponent, | ||||
|         CoreBlockPreRenderedComponent, | ||||
|         CoreBlockCourseBlocksComponent | ||||
|     ] | ||||
| }) | ||||
|  | ||||
| @ -0,0 +1,11 @@ | ||||
| <ion-item-divider text-wrap *ngIf="title"> | ||||
|     <h2><core-format-text [text]="title"></core-format-text></h2> | ||||
| </ion-item-divider> | ||||
| <core-loading [hideUntil]="loaded" class="core-loading-center"> | ||||
|     <ion-item *ngIf="block.contents.content" text-wrap class="core-block-content"> | ||||
|         <core-format-text [text]="block.contents.content"></core-format-text> | ||||
|     </ion-item> | ||||
|     <ion-item *ngIf="block.contents.footer" text-wrap class="core-block-footer"> | ||||
|         <core-format-text [text]="block.contents.footer"></core-format-text> | ||||
|     </ion-item> | ||||
| </core-loading> | ||||
| @ -0,0 +1,40 @@ | ||||
| // (C) Copyright 2015 Martin Dougiamas
 | ||||
| //
 | ||||
| // 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 { Injector, OnInit, Component } from '@angular/core'; | ||||
| import { CoreBlockBaseComponent } from '../../classes/base-block-component'; | ||||
| 
 | ||||
| /** | ||||
|  * Component to render blocks with pre-rendered HTML. | ||||
|  */ | ||||
| @Component({ | ||||
|     selector: 'core-block-pre-rendered', | ||||
|     templateUrl: 'core-block-pre-rendered.html' | ||||
| }) | ||||
| export class CoreBlockPreRenderedComponent  extends CoreBlockBaseComponent implements OnInit { | ||||
| 
 | ||||
|     constructor(injector: Injector) { | ||||
|         super(injector, 'CoreBlockPreRenderedComponent'); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Component being initialized. | ||||
|      */ | ||||
|     ngOnInit(): void { | ||||
|         super.ngOnInit(); | ||||
| 
 | ||||
|         this.fetchContentDefaultError = 'Error getting ' + this.block.contents.title + ' data.'; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -58,7 +58,9 @@ export class CoreBlockCourseBlocksCourseOptionHandler implements CoreCourseOptio | ||||
|      * @return {boolean|Promise<boolean>} True or promise resolved with true if enabled. | ||||
|      */ | ||||
|     isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise<boolean> { | ||||
|         return true; | ||||
|         return this.courseProvider.getCourseBlocks(courseId).then((blocks) => { | ||||
|             return blocks && blocks.length > 0; | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -255,7 +255,8 @@ export class CoreCourseProvider { | ||||
|     getCourseBlocks(courseId: number, siteId?: string): Promise<any[]> { | ||||
|         return this.sitesProvider.getSite(siteId).then((site) => { | ||||
|             const params = { | ||||
|                     courseid: courseId | ||||
|                     courseid: courseId, | ||||
|                     returncontents: 1 | ||||
|                 }, | ||||
|                 preSets: CoreSiteWSPreSets = { | ||||
|                     cacheKey: this.getCourseBlocksCacheKey(courseId), | ||||
|  | ||||
| @ -47,6 +47,7 @@ export class CoreCoursesDashboardProvider { | ||||
|     getDashboardBlocks(userId?: number, siteId?: string): Promise<any[]> { | ||||
|         return this.sitesProvider.getSite(siteId).then((site) => { | ||||
|             const params = { | ||||
|                     returncontents: 1 | ||||
|                 }, | ||||
|                 preSets = { | ||||
|                     cacheKey: this.getDashboardBlocksCacheKey(userId), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user