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