mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	calendar widget setup
This commit is contained in:
		| @@ -1,14 +1,14 @@ | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('noteInfoWidget', '{"enabled":true,"expanded":true,"position":10}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('noteInfoWidget', '{"enabled":true,"expanded":true,"position":100}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
|  | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('attributesWidget', '{"enabled":true,"expanded":true,"position":20}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('attributesWidget', '{"enabled":true,"expanded":true,"position":200}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
|  | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('linkMapWidget', '{"enabled":true,"expanded":true,"position":30}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('linkMapWidget', '{"enabled":true,"expanded":true,"position":300}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
|  | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":40}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":400}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
|  | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":50}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":500}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| @@ -1,2 +1,2 @@ | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('similarNotesWidget', '{"enabled":true,"expanded":true,"position":60}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('similarNotesWidget', '{"enabled":true,"expanded":true,"position":600}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| @@ -1,2 +1,2 @@ | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('editedNotesWidget', '{"enabled":true,"expanded":true,"position":5}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| VALUES ('editedNotesWidget', '{"enabled":true,"expanded":true,"position":50}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
							
								
								
									
										2
									
								
								db/migrations/0145__calendar_widget.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								db/migrations/0145__calendar_widget.sql
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| INSERT INTO options (name, value, utcDateCreated, utcDateModified, isSynced) | ||||
| VALUES ('calendarWidget', '{"enabled":true,"expanded":true,"position":20}', '2018-07-29T18:31:00.874Z', '2018-07-29T18:31:00.874Z', 0); | ||||
| @@ -53,7 +53,8 @@ export default class SidebarOptions { | ||||
|             {name: 'noteRevisions', title: 'Note revisions'}, | ||||
|             {name: 'whatLinksHere', title: 'What links here'}, | ||||
|             {name: 'similarNotes', title: 'Similar notes'}, | ||||
|             {name: 'editedNotes', title: 'Edited notes (only on day note)'} | ||||
|             {name: 'editedNotes', title: 'Edited notes (only on day note)'}, | ||||
|             {name: 'calendar', title: 'Calendar (only on day note)'} | ||||
|         ].map(widget => { | ||||
|             widget.option = this.parseJsonSafely(options[widget.name + 'Widget']) || { | ||||
|                 enabled: true, | ||||
|   | ||||
							
								
								
									
										54
									
								
								src/public/javascripts/widgets/calendar.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/public/javascripts/widgets/calendar.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| import StandardWidget from "./standard_widget.js"; | ||||
|  | ||||
| const TPL = ` | ||||
| <table class="note-info-table"> | ||||
|     <tr> | ||||
|         <th>Note ID:</th> | ||||
|         <td colspan="3" class="note-info-note-id"></td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <th>Created:</th> | ||||
|         <td colspan="3" class="note-info-date-created"></td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <th>Modified:</th> | ||||
|         <td colspan="3" class="note-info-date-modified"></td> | ||||
|     </tr> | ||||
|     <tr> | ||||
|         <th>Type:</th> | ||||
|         <td class="note-info-type"></td> | ||||
|          | ||||
|         <th>MIME:</th> | ||||
|         <td class="note-info-mime"></td> | ||||
|     </tr> | ||||
| </table> | ||||
| `; | ||||
|  | ||||
| class CalendarWidget extends StandardWidget { | ||||
|     getWidgetTitle() { return "Calendar"; } | ||||
|  | ||||
|     async isEnabled() { | ||||
|         return await super.isEnabled() | ||||
|             && await this.ctx.note.hasLabel("dateNote"); | ||||
|     } | ||||
|  | ||||
|     async doRenderBody() { | ||||
|         this.$body.html(TPL); | ||||
|  | ||||
|         const $noteId = this.$body.find(".note-info-note-id"); | ||||
|         const $dateCreated = this.$body.find(".note-info-date-created"); | ||||
|         const $dateModified = this.$body.find(".note-info-date-modified"); | ||||
|         const $type = this.$body.find(".note-info-type"); | ||||
|         const $mime = this.$body.find(".note-info-mime"); | ||||
|  | ||||
|         const note = this.ctx.note; | ||||
|  | ||||
|         $noteId.text(note.noteId); | ||||
|         $dateCreated.text(note.dateCreated); | ||||
|         $dateModified.text(note.dateModified); | ||||
|         $type.text(note.type); | ||||
|         $mime.text(note.mime).attr("title", note.mime); | ||||
|     } | ||||
| } | ||||
|  | ||||
| export default CalendarWidget; | ||||
| @@ -25,8 +25,11 @@ class WhatLinksHereWidget extends StandardWidget { | ||||
|         } | ||||
|  | ||||
|         const $list = $("<ul>"); | ||||
|         let i = 0; | ||||
|  | ||||
|         for (; i < targetRelations.length && i < 50; i++) { | ||||
|             const rel = targetRelations[i]; | ||||
|  | ||||
|         for (const rel of targetRelations) { | ||||
|             const $item = $("<li>") | ||||
|                 .append(await linkService.createNoteLink(rel.noteId)) | ||||
|                 .append($("<span>").text(" (" + rel.name + ")")); | ||||
| @@ -34,6 +37,10 @@ class WhatLinksHereWidget extends StandardWidget { | ||||
|             $list.append($item); | ||||
|         } | ||||
|  | ||||
|         if (i < targetRelations.length) { | ||||
|             $list.append($("<li>").text(`${targetRelations.length - i} more links ...`)) | ||||
|         } | ||||
|  | ||||
|         this.$body.empty().append($list); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -31,6 +31,7 @@ const ALLOWED_OPTIONS = [ | ||||
|     'whatLinksHereWidget', | ||||
|     'similarNotesWidget', | ||||
|     'editedNotesWidget', | ||||
|     'calendarWidget', | ||||
|     'codeNotesMimeTypes' | ||||
| ]; | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,7 @@ const build = require('./build'); | ||||
| const packageJson = require('../../package'); | ||||
| const {TRILIUM_DATA_DIR} = require('./data_dir'); | ||||
|  | ||||
| const APP_DB_VERSION = 144; | ||||
| const APP_DB_VERSION = 145; | ||||
| const SYNC_VERSION = 10; | ||||
| const CLIPPER_PROTOCOL_VERSION = "1.0"; | ||||
|  | ||||
|   | ||||
| @@ -69,12 +69,14 @@ async function initNotSyncedOptions(initialized, startNotePath = 'root', opts = | ||||
|  | ||||
|     await optionService.createOption('showSidebarInNewTab', 'true', false); | ||||
|  | ||||
|     await optionService.createOption('noteInfoWidget', '{"enabled":true,"expanded":true,"position":10}', false); | ||||
|     await optionService.createOption('attributesWidget', '{"enabled":true,"expanded":true,"position":20}', false); | ||||
|     await optionService.createOption('linkMapWidget', '{"enabled":true,"expanded":true,"position":30}', false); | ||||
|     await optionService.createOption('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":40}', false); | ||||
|     await optionService.createOption('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":50}', false); | ||||
|     await optionService.createOption('similarNotesWidget', '{"enabled":true,"expanded":true,"position":60}', false); | ||||
|     await optionService.createOption('calendarWidget', '{"enabled":true,"expanded":true,"position":20}', false); | ||||
|     await optionService.createOption('editedNotesWidget', '{"enabled":true,"expanded":true,"position":50}', false); | ||||
|     await optionService.createOption('noteInfoWidget', '{"enabled":true,"expanded":true,"position":100}', false); | ||||
|     await optionService.createOption('attributesWidget', '{"enabled":true,"expanded":true,"position":200}', false); | ||||
|     await optionService.createOption('linkMapWidget', '{"enabled":true,"expanded":true,"position":300}', false); | ||||
|     await optionService.createOption('noteRevisionsWidget', '{"enabled":true,"expanded":true,"position":400}', false); | ||||
|     await optionService.createOption('whatLinksHereWidget', '{"enabled":false,"expanded":true,"position":500}', false); | ||||
|     await optionService.createOption('similarNotesWidget', '{"enabled":true,"expanded":true,"position":600}', false); | ||||
|  | ||||
|     await optionService.createOption('initialized', initialized ? 'true' : 'false', false); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user