calendar widget setup

This commit is contained in:
zadam 2019-09-08 13:08:01 +02:00
parent f3955bcbdc
commit d3f2b71803
10 changed files with 83 additions and 16 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View 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);

View File

@ -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,

View 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;

View File

@ -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);
}
}

View File

@ -31,6 +31,7 @@ const ALLOWED_OPTIONS = [
'whatLinksHereWidget',
'similarNotesWidget',
'editedNotesWidget',
'calendarWidget',
'codeNotesMimeTypes'
];

View File

@ -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";

View File

@ -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);
}