mirror of
https://github.com/zadam/trilium.git
synced 2025-03-03 18:49:27 +08:00
added edited notes ribbon widget
This commit is contained in:
parent
3c8e267aad
commit
e2819109e9
4 changed files with 31 additions and 82 deletions
1
TODO
1
TODO
|
@ -1,4 +1,3 @@
|
|||
- new icon
|
||||
- polish becca entities API
|
||||
- separate private and public APIs in becca entities
|
||||
- what to do with calendar, edited_notes and what_links_here?
|
||||
|
|
|
@ -41,6 +41,7 @@ import SimilarNotesWidget from "../widgets/ribbon_widgets/similar_notes.js";
|
|||
import RightPaneContainer from "../widgets/containers/right_pane_container.js";
|
||||
import EditButton from "../widgets/buttons/edit_button.js";
|
||||
import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js";
|
||||
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
|
||||
|
||||
export default class DesktopLayout {
|
||||
constructor(customWidgets) {
|
||||
|
@ -120,6 +121,7 @@ export default class DesktopLayout {
|
|||
new RibbonContainer()
|
||||
.ribbon(new SearchDefinitionWidget())
|
||||
.ribbon(new BasicPropertiesWidget())
|
||||
.ribbon(new EditedNotesWidget())
|
||||
.ribbon(new BookPropertiesWidget())
|
||||
.ribbon(new NotePropertiesWidget())
|
||||
.ribbon(new FilePropertiesWidget())
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
import CollapsibleWidget from "../collapsible_widget.js";
|
||||
import linkService from "../../services/link.js";
|
||||
|
||||
export default class WhatLinksHereWidget extends CollapsibleWidget {
|
||||
isEnabled() {
|
||||
return super.isEnabled() && !this.note.hasLabel('whatLinksHereWidgetDisabled');
|
||||
}
|
||||
|
||||
get widgetTitle() { return "What links here"; }
|
||||
|
||||
get help() {
|
||||
return {
|
||||
title: "This list contains all notes which link to this note through links and relations."
|
||||
};
|
||||
}
|
||||
|
||||
get headerActions() {
|
||||
const $showFullButton = $("<a>")
|
||||
.addClass("bx bx-network-chart")
|
||||
.addClass('widget-header-action')
|
||||
.attr('title', 'Show full link map');
|
||||
|
||||
$showFullButton.on('click', async () => {
|
||||
const linkMapDialog = await import("../../dialogs/link_map.js");
|
||||
linkMapDialog.showDialog();
|
||||
});
|
||||
|
||||
return [$showFullButton];
|
||||
}
|
||||
|
||||
async refreshWithNote(note) {
|
||||
const targetRelations = note.getTargetRelations();
|
||||
|
||||
if (targetRelations.length === 0) {
|
||||
this.$body.text("Nothing links here yet ...");
|
||||
return;
|
||||
}
|
||||
|
||||
const $list = $("<ul>");
|
||||
let i = 0;
|
||||
|
||||
for (; i < targetRelations.length && i < 50; i++) {
|
||||
const rel = targetRelations[i];
|
||||
|
||||
const $item = $("<li>")
|
||||
.append(await linkService.createNoteLink(rel.noteId))
|
||||
.append($("<span>").text(" (" + rel.name + ")"));
|
||||
|
||||
$list.append($item);
|
||||
}
|
||||
|
||||
if (i < targetRelations.length) {
|
||||
$list.append($("<li>").text(`${targetRelations.length - i} more links ...`));
|
||||
}
|
||||
|
||||
this.$body.empty().append($list);
|
||||
}
|
||||
|
||||
entitiesReloadedEvent({loadResults}) {
|
||||
if (loadResults.getAttributes().find(attr => attr.type === 'relation' && attr.value === this.noteId)) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,12 @@ import froca from "../../services/froca.js";
|
|||
|
||||
const TPL = `
|
||||
<div class="edited-notes-widget">
|
||||
<style>
|
||||
.edited-notes-widget .edited-note-line {
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
text-overflow: ellipsis;
|
||||
<style>
|
||||
.edited-notes-widget {
|
||||
padding: 12px;
|
||||
max-height: 200px;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
@ -20,12 +21,8 @@ const TPL = `
|
|||
`;
|
||||
|
||||
export default class EditedNotesWidget extends CollapsibleWidget {
|
||||
get widgetTitle() { return "Edited notes on this day"; }
|
||||
|
||||
get help() {
|
||||
return {
|
||||
title: "This contains a list of notes created or updated on this day."
|
||||
};
|
||||
get name() {
|
||||
return "editedNotes";
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
|
@ -33,10 +30,20 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||
&& this.note.hasOwnedLabel("dateNote");
|
||||
}
|
||||
|
||||
async doRenderBody() {
|
||||
this.$body.html(TPL);
|
||||
this.$list = this.$body.find('.edited-notes-list');
|
||||
this.$noneFound = this.$body.find('.no-edited-notes-found');
|
||||
getTitle() {
|
||||
return {
|
||||
show: this.isEnabled(),
|
||||
activate: true,
|
||||
title: 'Edited Notes',
|
||||
icon: 'bx bx-calendar-edit'
|
||||
};
|
||||
}
|
||||
|
||||
async doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.contentSized();
|
||||
this.$list = this.$widget.find('.edited-notes-list');
|
||||
this.$noneFound = this.$widget.find('.no-edited-notes-found');
|
||||
}
|
||||
|
||||
async refreshWithNote(note) {
|
||||
|
@ -56,8 +63,9 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||
|
||||
await froca.getNotes(noteIds, true); // preload all at once
|
||||
|
||||
for (const editedNote of editedNotes) {
|
||||
const $item = $('<div class="edited-note-line">');
|
||||
for (let i = 0; i < editedNotes.length; i++) {
|
||||
const editedNote = editedNotes[i];
|
||||
const $item = $('<span class="edited-note-line">');
|
||||
|
||||
if (editedNote.isDeleted) {
|
||||
const title = editedNote.title + " (deleted)";
|
||||
|
@ -71,6 +79,10 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||
$item.append(editedNote.notePath ? await linkService.createNoteLink(editedNote.notePath.join("/"), {showNotePath: true}) : editedNote.title);
|
||||
}
|
||||
|
||||
if (i < editedNotes.length - 1) {
|
||||
$item.append(", ");
|
||||
}
|
||||
|
||||
this.$list.append($item);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue