mirror of
https://github.com/zadam/trilium.git
synced 2025-02-20 21:13:11 +08:00
note info sidebar widget
This commit is contained in:
parent
5283b489dc
commit
eb28a3b0c9
5 changed files with 117 additions and 47 deletions
|
@ -1,3 +1,23 @@
|
|||
import NoteInfoWidget from "../widgets/note_info.js";
|
||||
|
||||
const WIDGET_TPL = `
|
||||
<div class="card widget">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-sm widget-title" data-toggle="collapse" data-target="#collapseOne">
|
||||
Collapsible Group Item
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div id="collapseOne" class="collapse show body-wrapper">
|
||||
<div class="card-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
let widgetIdCtr = 1;
|
||||
|
||||
class Sidebar {
|
||||
/**
|
||||
* @param {TabContext} ctx
|
||||
|
@ -5,6 +25,7 @@ class Sidebar {
|
|||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
this.$sidebar = ctx.$tabContent.find(".note-detail-sidebar");
|
||||
this.$widgets = this.$sidebar.find(".note-detail-widgets");
|
||||
this.$showSideBarButton = this.ctx.$tabContent.find(".show-sidebar-button");
|
||||
this.$showSideBarButton.hide();
|
||||
|
||||
|
@ -18,7 +39,35 @@ class Sidebar {
|
|||
this.$showSideBarButton.click(() => {
|
||||
this.$sidebar.show();
|
||||
this.$showSideBarButton.hide();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
async noteLoaded() {
|
||||
this.$widgets.empty();
|
||||
|
||||
this.addNoteInfoWidget();
|
||||
this.addNoteInfoWidget();
|
||||
}
|
||||
|
||||
async addNoteInfoWidget() {
|
||||
const $widget = this.createWidgetElement();
|
||||
|
||||
const noteInfoWidget = new NoteInfoWidget(this.ctx, $widget);
|
||||
await noteInfoWidget.renderBody();
|
||||
|
||||
console.log($widget);
|
||||
|
||||
this.$widgets.append($widget);
|
||||
}
|
||||
|
||||
createWidgetElement() {
|
||||
const widgetId = 'widget-' + widgetIdCtr++;
|
||||
|
||||
const $widget = $(WIDGET_TPL);
|
||||
$widget.find('[data-target]').attr('data-target', "#" + widgetId);
|
||||
$widget.find('.body-wrapper').attr('id', widgetId);
|
||||
|
||||
return $widget;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,9 +60,9 @@ class TabContext {
|
|||
this.noteChangeDisabled = false;
|
||||
this.isNoteChanged = false;
|
||||
this.attributes = new Attributes(this);
|
||||
this.sidebar = new Sidebar(this);
|
||||
|
||||
if (utils.isDesktop()) {
|
||||
this.sidebar = new Sidebar(this);
|
||||
this.noteType = new NoteTypeContext(this);
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,10 @@ class TabContext {
|
|||
|
||||
this.showPaths();
|
||||
|
||||
if (this.sidebar) {
|
||||
this.sidebar.noteLoaded();
|
||||
}
|
||||
|
||||
console.debug(`Switched tab ${this.tabId} to ${this.noteId}`);
|
||||
}
|
||||
|
||||
|
|
59
src/public/javascripts/widgets/note_info.js
Normal file
59
src/public/javascripts/widgets/note_info.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
const TPL = `
|
||||
<table class="note-info-table">
|
||||
<tr>
|
||||
<th>Note ID</th>
|
||||
<td class="note-info-note-id"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Created</th>
|
||||
<td class="note-info-date-created"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Modified</th>
|
||||
<td class="note-info-date-modified"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<td class="note-info-type"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>MIME</th>
|
||||
<td class="note-info-mime"></td>
|
||||
</tr>
|
||||
</table>
|
||||
`;
|
||||
|
||||
class NoteInfoWidget {
|
||||
/**
|
||||
* @param {TabContext} ctx
|
||||
* @param {jQuery} $widget
|
||||
*/
|
||||
constructor(ctx, $widget) {
|
||||
this.ctx = ctx;
|
||||
this.$widget = $widget;
|
||||
this.$title = this.$widget.find('.widget-title');
|
||||
this.$title.text("Note info");
|
||||
}
|
||||
|
||||
async renderBody() {
|
||||
const $body = this.$widget.find('.card-body');
|
||||
|
||||
$body.html(TPL);
|
||||
|
||||
const $noteId = $body.find(".note-info-note-id");
|
||||
const $dateCreated = $body.find(".note-info-date-created");
|
||||
const $dateModified = $body.find(".note-info-date-modified");
|
||||
const $type = $body.find(".note-info-type");
|
||||
const $mime = $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);
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteInfoWidget;
|
|
@ -152,8 +152,8 @@ body {
|
|||
background-color: inherit;
|
||||
}
|
||||
|
||||
#note-info-table td, #note-info-table th {
|
||||
padding: 15px;
|
||||
.widget .note-info-table td, .widget .note-info-table th {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
[data-toggle="tooltip"] span {
|
||||
|
|
|
@ -3,47 +3,5 @@
|
|||
<button class="hide-sidebar-button" style="background: none; border: none;">hide sidebar <span class="jam jam-chevron-right"></span></button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingOne">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-sm" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||
Collapsible Group Item #1
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne">
|
||||
<div class="card-body">
|
||||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingTwo">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-sm collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
|
||||
Collapsible Group Item #2
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo">
|
||||
<div class="card-body">
|
||||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingThree">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-sm collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
|
||||
Collapsible Group Item #3
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="collapseThree" class="collapse" aria-labelledby="headingThree">
|
||||
<div class="card-body">
|
||||
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note-detail-widgets"></div>
|
||||
</div>
|
Loading…
Reference in a new issue