forked from EVOgeek/Vmeda.Online
		
	MOBILE-3341 book: Apply numbering setting
This commit is contained in:
		
							parent
							
								
									6d06a7e41c
								
							
						
					
					
						commit
						f662013b47
					
				| @ -17,7 +17,7 @@ import { Content, ModalController } from 'ionic-angular'; | |||||||
| import { CoreAppProvider } from '@providers/app'; | import { CoreAppProvider } from '@providers/app'; | ||||||
| import { CoreCourseProvider } from '@core/course/providers/course'; | import { CoreCourseProvider } from '@core/course/providers/course'; | ||||||
| import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component'; | import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component'; | ||||||
| import { AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter } from '../../providers/book'; | import { AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter, AddonModBookBook } from '../../providers/book'; | ||||||
| import { AddonModBookPrefetchHandler } from '../../providers/prefetch-handler'; | import { AddonModBookPrefetchHandler } from '../../providers/prefetch-handler'; | ||||||
| import { CoreTagProvider } from '@core/tag/providers/tag'; | import { CoreTagProvider } from '@core/tag/providers/tag'; | ||||||
| 
 | 
 | ||||||
| @ -40,6 +40,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|     protected chapters: AddonModBookTocChapter[]; |     protected chapters: AddonModBookTocChapter[]; | ||||||
|     protected currentChapter: string; |     protected currentChapter: string; | ||||||
|     protected contentsMap: AddonModBookContentsMap; |     protected contentsMap: AddonModBookContentsMap; | ||||||
|  |     protected book: AddonModBookBook; | ||||||
| 
 | 
 | ||||||
|     constructor(injector: Injector, private bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider, |     constructor(injector: Injector, private bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider, | ||||||
|             private appProvider: CoreAppProvider, private prefetchDelegate: AddonModBookPrefetchHandler, |             private appProvider: CoreAppProvider, private prefetchDelegate: AddonModBookPrefetchHandler, | ||||||
| @ -69,7 +70,8 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
|             moduleId: this.module.id, |             moduleId: this.module.id, | ||||||
|             chapters: this.chapters, |             chapters: this.chapters, | ||||||
|             selected: this.currentChapter, |             selected: this.currentChapter, | ||||||
|             courseId: this.courseId |             courseId: this.courseId, | ||||||
|  |             book: this.book, | ||||||
|         }, { cssClass: 'core-modal-lateral', |         }, { cssClass: 'core-modal-lateral', | ||||||
|             showBackdrop: true, |             showBackdrop: true, | ||||||
|             enableBackdropDismiss: true, |             enableBackdropDismiss: true, | ||||||
| @ -123,6 +125,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | |||||||
| 
 | 
 | ||||||
|         // Try to get the book data.
 |         // Try to get the book data.
 | ||||||
|         promises.push(this.bookProvider.getBook(this.courseId, this.module.id).then((book) => { |         promises.push(this.bookProvider.getBook(this.courseId, this.module.id).then((book) => { | ||||||
|  |             this.book = book; | ||||||
|             this.dataRetrieved.emit(book); |             this.dataRetrieved.emit(book); | ||||||
|             this.description = book.intro; |             this.description = book.intro; | ||||||
|         }).catch(() => { |         }).catch(() => { | ||||||
|  | |||||||
| @ -12,7 +12,11 @@ | |||||||
|     <nav> |     <nav> | ||||||
|         <ion-list> |         <ion-list> | ||||||
|             <a ion-item text-wrap *ngFor="let chapter of chapters" (click)="loadChapter(chapter.id)" [class.core-nav-item-selected]="selected == chapter.id" [class.item-dimmed]="chapter.hidden"> |             <a ion-item text-wrap *ngFor="let chapter of chapters" (click)="loadChapter(chapter.id)" [class.core-nav-item-selected]="selected == chapter.id" [class.item-dimmed]="chapter.hidden"> | ||||||
|                 <p [attr.padding-left]="chapter.level == 1 ? true : null">{{chapter.number}} <core-format-text [text]="chapter.title" contextLevel="module" [contextInstanceId]="moduleId" [courseId]="courseId"></core-format-text></p> |                 <p [attr.padding-left]="addPadding && chapter.level == 1 ? true : null"> | ||||||
|  |                     <span *ngIf="showNumbers" class="addon-mod-book-number">{{chapter.number}}</span> | ||||||
|  |                     <span *ngIf="showBullets" class="addon-mod-book-bullet">•</span> | ||||||
|  |                     <core-format-text [text]="chapter.title" contextLevel="module" [contextInstanceId]="moduleId" [courseId]="courseId"></core-format-text> | ||||||
|  |                 </p> | ||||||
|             </a> |             </a> | ||||||
|         </ion-list> |         </ion-list> | ||||||
|     </nav> |     </nav> | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								src/addon/mod/book/pages/toc/toc.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/addon/mod/book/pages/toc/toc.scss
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | ion-app.app-root page-addon-mod-book-toc { | ||||||
|  |     .addon-mod-book-bullet { | ||||||
|  |         font-weight: bold; | ||||||
|  |         font-size: 1.5em; | ||||||
|  |         margin-right: 3px; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Component } from '@angular/core'; | import { Component } from '@angular/core'; | ||||||
| import { IonicPage, NavParams, ViewController } from 'ionic-angular'; | import { IonicPage, NavParams, ViewController } from 'ionic-angular'; | ||||||
| import { AddonModBookTocChapter } from '../../providers/book'; | import { AddonModBookTocChapter, AddonModBookBook, AddonModBookNumbering } from '../../providers/book'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Modal to display the TOC of a book. |  * Modal to display the TOC of a book. | ||||||
| @ -29,12 +29,24 @@ export class AddonModBookTocPage { | |||||||
|     chapters: AddonModBookTocChapter[]; |     chapters: AddonModBookTocChapter[]; | ||||||
|     selected: number; |     selected: number; | ||||||
|     courseId: number; |     courseId: number; | ||||||
|  |     showNumbers = true; | ||||||
|  |     addPadding = true; | ||||||
|  |     showBullets = false; | ||||||
|  | 
 | ||||||
|  |     protected book: AddonModBookBook; | ||||||
| 
 | 
 | ||||||
|     constructor(navParams: NavParams, private viewCtrl: ViewController) { |     constructor(navParams: NavParams, private viewCtrl: ViewController) { | ||||||
|         this.moduleId = navParams.get('moduleId'); |         this.moduleId = navParams.get('moduleId'); | ||||||
|         this.chapters = navParams.get('chapters') || []; |         this.chapters = navParams.get('chapters') || []; | ||||||
|         this.selected = navParams.get('selected'); |         this.selected = navParams.get('selected'); | ||||||
|         this.courseId = navParams.get('courseId'); |         this.courseId = navParams.get('courseId'); | ||||||
|  |         this.book = navParams.get('book'); | ||||||
|  | 
 | ||||||
|  |         if (this.book) { | ||||||
|  |             this.showNumbers = this.book.numbering == AddonModBookNumbering.NUMBERS; | ||||||
|  |             this.showBullets = this.book.numbering == AddonModBookNumbering.BULLETS; | ||||||
|  |             this.addPadding = this.book.numbering != AddonModBookNumbering.NONE; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -27,6 +27,16 @@ import { CoreSite } from '@classes/site'; | |||||||
| import { CoreTagItem } from '@core/tag/providers/tag'; | import { CoreTagItem } from '@core/tag/providers/tag'; | ||||||
| import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws'; | import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws'; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Constants to define how the chapters and subchapters of a book should be displayed in that table of contents. | ||||||
|  |  */ | ||||||
|  | export const enum AddonModBookNumbering { | ||||||
|  |     NONE = 0, | ||||||
|  |     NUMBERS = 1, | ||||||
|  |     BULLETS = 2, | ||||||
|  |     INDENTED = 3, | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Service that provides some features for books. |  * Service that provides some features for books. | ||||||
|  */ |  */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user