mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added edited notes ribbon widget
This commit is contained in:
parent
3c8e267aad
commit
e2819109e9
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
|||||||
- new icon
|
- new icon
|
||||||
- polish becca entities API
|
- polish becca entities API
|
||||||
- separate private and public APIs in becca entities
|
- 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 RightPaneContainer from "../widgets/containers/right_pane_container.js";
|
||||||
import EditButton from "../widgets/buttons/edit_button.js";
|
import EditButton from "../widgets/buttons/edit_button.js";
|
||||||
import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js";
|
import CalendarMenuWidget from "../widgets/buttons/calendar_menu.js";
|
||||||
|
import EditedNotesWidget from "../widgets/ribbon_widgets/edited_notes.js";
|
||||||
|
|
||||||
export default class DesktopLayout {
|
export default class DesktopLayout {
|
||||||
constructor(customWidgets) {
|
constructor(customWidgets) {
|
||||||
@ -120,6 +121,7 @@ export default class DesktopLayout {
|
|||||||
new RibbonContainer()
|
new RibbonContainer()
|
||||||
.ribbon(new SearchDefinitionWidget())
|
.ribbon(new SearchDefinitionWidget())
|
||||||
.ribbon(new BasicPropertiesWidget())
|
.ribbon(new BasicPropertiesWidget())
|
||||||
|
.ribbon(new EditedNotesWidget())
|
||||||
.ribbon(new BookPropertiesWidget())
|
.ribbon(new BookPropertiesWidget())
|
||||||
.ribbon(new NotePropertiesWidget())
|
.ribbon(new NotePropertiesWidget())
|
||||||
.ribbon(new FilePropertiesWidget())
|
.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,10 +6,11 @@ import froca from "../../services/froca.js";
|
|||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="edited-notes-widget">
|
<div class="edited-notes-widget">
|
||||||
<style>
|
<style>
|
||||||
.edited-notes-widget .edited-note-line {
|
.edited-notes-widget {
|
||||||
white-space: nowrap;
|
padding: 12px;
|
||||||
overflow-x: hidden;
|
max-height: 200px;
|
||||||
text-overflow: ellipsis;
|
width: 100%;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -20,12 +21,8 @@ const TPL = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default class EditedNotesWidget extends CollapsibleWidget {
|
export default class EditedNotesWidget extends CollapsibleWidget {
|
||||||
get widgetTitle() { return "Edited notes on this day"; }
|
get name() {
|
||||||
|
return "editedNotes";
|
||||||
get help() {
|
|
||||||
return {
|
|
||||||
title: "This contains a list of notes created or updated on this day."
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
@ -33,10 +30,20 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||||||
&& this.note.hasOwnedLabel("dateNote");
|
&& this.note.hasOwnedLabel("dateNote");
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRenderBody() {
|
getTitle() {
|
||||||
this.$body.html(TPL);
|
return {
|
||||||
this.$list = this.$body.find('.edited-notes-list');
|
show: this.isEnabled(),
|
||||||
this.$noneFound = this.$body.find('.no-edited-notes-found');
|
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) {
|
async refreshWithNote(note) {
|
||||||
@ -56,8 +63,9 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||||||
|
|
||||||
await froca.getNotes(noteIds, true); // preload all at once
|
await froca.getNotes(noteIds, true); // preload all at once
|
||||||
|
|
||||||
for (const editedNote of editedNotes) {
|
for (let i = 0; i < editedNotes.length; i++) {
|
||||||
const $item = $('<div class="edited-note-line">');
|
const editedNote = editedNotes[i];
|
||||||
|
const $item = $('<span class="edited-note-line">');
|
||||||
|
|
||||||
if (editedNote.isDeleted) {
|
if (editedNote.isDeleted) {
|
||||||
const title = editedNote.title + " (deleted)";
|
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);
|
$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);
|
this.$list.append($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user