mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	note list rendering WIP
This commit is contained in:
		
							parent
							
								
									a3f4fc7762
								
							
						
					
					
						commit
						aeb6c34d27
					
				| @ -126,10 +126,10 @@ class NoteListRenderer { | |||||||
|         this.notes = notes; |         this.notes = notes; | ||||||
|         this.page = 1; |         this.page = 1; | ||||||
|         this.pageSize = 2; |         this.pageSize = 2; | ||||||
|  |         this.viewType = 'list'; | ||||||
| 
 | 
 | ||||||
|         this.$noteList.find('.grid-view-button').on('click', async () => { |         this.$noteList.find('.list-view-button').on('click', () => this.toggleViewType('list')); | ||||||
| 
 |         this.$noteList.find('.grid-view-button').on('click', () => this.toggleViewType('grid')); | ||||||
|         }); |  | ||||||
| 
 | 
 | ||||||
|         this.$noteList.find('.expand-children-button').on('click', async () => { |         this.$noteList.find('.expand-children-button').on('click', async () => { | ||||||
|             for (let i = 1; i < 30; i++) { // protection against infinite cycle
 |             for (let i = 1; i < 30; i++) { // protection against infinite cycle
 | ||||||
| @ -159,6 +159,21 @@ class NoteListRenderer { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     async toggleViewType(type) { | ||||||
|  |         if (type !== 'list' && type !== 'grid') { | ||||||
|  |             throw new Error(`Invalid view type ${type}`); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         this.viewType = type; | ||||||
|  | 
 | ||||||
|  |         this.$noteList | ||||||
|  |             .removeClass('grid-view') | ||||||
|  |             .removeClass('list-view') | ||||||
|  |             .addClass(this.viewType + '-view'); | ||||||
|  | 
 | ||||||
|  |         await this.renderList(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     async renderList() { |     async renderList() { | ||||||
|         const $container = this.$noteList.find('.note-list-container').empty(); |         const $container = this.$noteList.find('.note-list-container').empty(); | ||||||
| 
 | 
 | ||||||
| @ -186,7 +201,7 @@ class NoteListRenderer { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     renderPager() { |     renderPager() { | ||||||
|         const $pager = this.$noteList.find('.note-list-pager'); |         const $pager = this.$noteList.find('.note-list-pager').empty(); | ||||||
| 
 | 
 | ||||||
|         for (let i = 1; i <= Math.ceil(this.notes.length / this.pageSize); i++) { |         for (let i = 1; i <= Math.ceil(this.notes.length / this.pageSize); i++) { | ||||||
|             $pager.append( |             $pager.append( | ||||||
| @ -261,7 +276,7 @@ class NoteListRenderer { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async toggleContent($card, note, expand) { |     async toggleContent($card, note, expand) { | ||||||
|         if ((expand && $card.hasClass("expanded")) || (!expand && !$card.hasClass("expanded"))) { |         if (this.viewType === 'list' && ((expand && $card.hasClass("expanded")) || (!expand && !$card.hasClass("expanded")))) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -60,9 +60,6 @@ export default class BookTypeWidget extends TypeWidget { | |||||||
|                 .append(' if you want to add some text.')); |                 .append(' if you want to add some text.')); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // const zoomLevel = parseInt(note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
 |  | ||||||
|         // this.setZoom(zoomLevel);
 |  | ||||||
| 
 |  | ||||||
|         const noteListRenderer = new NoteListRenderer(note, await note.getChildNotes()); |         const noteListRenderer = new NoteListRenderer(note, await note.getChildNotes()); | ||||||
| 
 | 
 | ||||||
|         this.$content.append(await noteListRenderer.renderList()); |         this.$content.append(await noteListRenderer.renderList()); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam