Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
disabled note-level actions based on note type, fixes #218
azivnerbfc09187e3e4
diff --git a/docs/backend_api/Link.html b/docs/backend_api/Link.htmlnew file mode 100644index 0000000000..d5456947ef--- /dev/null+++ b/docs/backend_api/Link.html@@ -0,0 +1,367 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <title>JSDoc: Class: Link</title>++ <script src="scripts/prettify/prettify.js"> </script>+ <script src="scripts/prettify/lang-css.js"> </script>+ <!--[if lt IE 9]>+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>+ <![endif]-->+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">+</head>++<body>++<div id="main">++ <h1 class="page-title">Class: Link</h1>+++++++<section>++<header>++ <h2><span class="attribs"><span class="type-signature"></span></span>Link<span class="signature">(linkId, noteId, targetNoteId, type, isDeleted, dateModified, dateCreated)</span><span class="type-signature"></span></h2>++ <div class="class-description">This class represents link from one note to another in the form of hyperlink or image reference. Note that+this is different concept than attribute/relation.</div>+++</header>++<article>+ <div class="container-overview">+++++ <h2>Constructor</h2>++++ <h4 class="name" id="Link"><span class="type-signature"></span>new Link<span class="signature">(linkId, noteId, targetNoteId, type, isDeleted, dateModified, dateCreated)</span><span class="type-signature"></span></h4>+++++++++++++++ <h5>Parameters:</h5>+++<table class="params">+ <thead>+ <tr>++ <th>Name</th>+++ <th>Type</th>++++++ <th class="last">Description</th>+ </tr>+ </thead>++ <tbody>+++ <tr>++ <td class="name"><code>linkId</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>noteId</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>targetNoteId</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>type</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>isDeleted</code></td>+++ <td class="type">+++<span class="param-type">boolean</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>dateModified</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>dateCreated</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>+++ </tbody>+</table>+++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="entities_link.js.html">entities/link.js</a>, <a href="entities_link.js.html#line21">line 21</a>+ </li></ul></dd>++++++++</dl>++++++++++++++++++++ </div>+++ <h3 class="subsection-title">Extends</h3>+++++ <ul>+ <li><a href="Entity.html">Entity</a></li>+ </ul>++++++++++++++++++++++</article>++</section>+++++</div>++<nav>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="Entity.html">Entity</a></li><li><a href="Link.html">Link</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>+</nav>++<br class="clear">++<footer>+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 08 2018 23:49:19 GMT+0100 (Central European Standard Time)+</footer>++<script> prettyPrint(); </script>+<script src="scripts/linenumber.js"> </script>+</body>+</html>\ No newline at end of filediff --git a/docs/backend_api/entities_link.js.html b/docs/backend_api/entities_link.js.htmlnew file mode 100644index 0000000000..856b63da59--- /dev/null+++ b/docs/backend_api/entities_link.js.html@@ -0,0 +1,101 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <title>JSDoc: Source: entities/link.js</title>++ <script src="scripts/prettify/prettify.js"> </script>+ <script src="scripts/prettify/lang-css.js"> </script>+ <!--[if lt IE 9]>+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>+ <![endif]-->+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">+</head>++<body>++<div id="main">++ <h1 class="page-title">Source: entities/link.js</h1>+++++++ <section>+ <article>+ <pre class="prettyprint source linenums"><code>"use strict";++const Entity = require('./entity');+const repository = require('../services/repository');+const dateUtils = require('../services/date_utils');++/**+ * This class represents link from one note to another in the form of hyperlink or image reference. Note that+ * this is different concept than attribute/relation.+ *+ * @param {string} linkId+ * @param {string} noteId+ * @param {string} targetNoteId+ * @param {string} type+ * @param {boolean} isDeleted+ * @param {string} dateModified+ * @param {string} dateCreated+ *+ * @extends Entity+ */+class Link extends Entity {+ static get entityName() { return "links"; }+ static get primaryKeyName() { return "linkId"; }+ static get hashedProperties() { return ["linkId", "noteId", "targetNoteId", "type", "isDeleted", "dateCreated", "dateModified"]; }++ async getNote() {+ return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]);+ }++ async getTargetNote() {+ return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.targetNoteId]);+ }++ beforeSaving() {+ if (!this.isDeleted) {+ this.isDeleted = false;+ }++ if (!this.dateCreated) {+ this.dateCreated = dateUtils.nowDate();+ }++ super.beforeSaving();++ if (this.isChanged) {+ this.dateModified = dateUtils.nowDate();+ }+ }+}++module.exports = Link;</code></pre>+ </article>+ </section>+++++</div>++<nav>+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="Entity.html">Entity</a></li><li><a href="Link.html">Link</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>+</nav>++<br class="clear">++<footer>+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Nov 08 2018 23:49:19 GMT+0100 (Central European Standard Time)+</footer>++<script> prettyPrint(); </script>+<script src="scripts/linenumber.js"> </script>+</body>+</html>diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.jsindex d629c457ee..97e1d1e5e5 100644--- a/src/public/javascripts/services/note_type.js+++ b/src/public/javascripts/services/note_type.js@@ -153,7 +153,7 @@ function NoteTypeModel() {}}-ko.applyBindings(noteTypeModel, document.getElementById('note-type'));+ko.applyBindings(noteTypeModel, document.getElementById('note-type-wrapper'));export default {getNoteType: () => noteTypeModel.type(),diff --git a/src/views/index.ejs b/src/views/index.ejsindex 866b1e0aee..9fdbdc7fa9 100644--- a/src/views/index.ejs+++ b/src/views/index.ejs@@ -87,11 +87,7 @@<div id="search-results"><strong>Search results:</strong>- <ul id="search-results-inner">- <li>aaa</li>- <li>bbb</li>- <li>ccc</li>- </ul>+ <ul id="search-results-inner"></ul></div><div id="tree"></div>@@ -142,36 +138,38 @@ - <div class="dropdown" id="note-type">- <button data-bind="disable: isDisabled()" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">- Type: <span data-bind="text: typeString()"></span>- <span class="caret"></span>- </button>- <div id="note-type-dropdown" class="dropdown-menu dropdown-menu-right">- <a class="dropdown-item" data-bind="click: selectText, css: { selected: type() == 'text' }"><span class="check">✓</span> <strong>Text</strong></a>- <div class="dropdown-divider"></div>- <a class="dropdown-item" data-bind="click: selectRelationMap, css: { selected: type() == 'relation-map' && mime() == '' }"><span class="check">✓</span> <strong>Relation Map</strong></a>- <div class="dropdown-divider"></div>- <a class="dropdown-item" data-bind="click: selectRender, css: { selected: type() == 'render' && mime() == '' }"><span class="check">✓</span> <strong>Render HTML note</strong></a>- <div class="dropdown-divider"></div>- <a class="dropdown-item" data-bind="click: selectCode, css: { selected: type() == 'code' && mime() == '' }"><span class="check">✓</span> <strong>Code</strong></a>- <!-- ko foreach: codeMimeTypes -->- <a class="dropdown-item" data-bind="click: $parent.selectCodeMime, css: { selected: $parent.type() == 'code' && $parent.mime() == mime }"><span class="check">✓</span> <span data-bind="text: title"></span></a>- <!-- /ko -->+ <div id="note-type-wrapper" style="display: flex;">+ <div class="dropdown" id="note-type">+ <button data-bind="disable: isDisabled()" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">+ Type: <span data-bind="text: typeString()"></span>+ <span class="caret"></span>+ </button>+ <div id="note-type-dropdown" class="dropdown-menu dropdown-menu-right">+ <a class="dropdown-item" data-bind="click: selectText, css: { selected: type() == 'text' }"><span class="check">✓</span> <strong>Text</strong></a>+ <div class="dropdown-divider"></div>+ <a class="dropdown-item" data-bind="click: selectRelationMap, css: { selected: type() == 'relation-map' && mime() == '' }"><span class="check">✓</span> <strong>Relation Map</strong></a>+ <div class="dropdown-divider"></div>+ <a class="dropdown-item" data-bind="click: selectRender, css: { selected: type() == 'render' && mime() == '' }"><span class="check">✓</span> <strong>Render HTML note</strong></a>+ <div class="dropdown-divider"></div>+ <a class="dropdown-item" data-bind="click: selectCode, css: { selected: type() == 'code' && mime() == '' }"><span class="check">✓</span> <strong>Code</strong></a>+ <!-- ko foreach: codeMimeTypes -->+ <a class="dropdown-item" data-bind="click: $parent.selectCodeMime, css: { selected: $parent.type() == 'code' && $parent.mime() == mime }"><span class="check">✓</span> <span data-bind="text: title"></span></a>+ <!-- /ko -->+ </div></div>- </div>- <div class="dropdown" id="note-actions">- <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">- Note actions- <span class="caret"></span>- </button>- <div class="dropdown-menu dropdown-menu-right">- <a class="dropdown-item" id="show-note-revisions-button">Revisions</a>- <a class="dropdown-item show-attributes-button"><kbd>Alt+A</kbd> Attributes</a>- <a class="dropdown-item" id="show-source-button">HTML source</a>- <a class="dropdown-item" id="upload-file-button">Upload file</a>- <a class="dropdown-item" id="export-note-to-markdown-button">Export as markdown</a>+ <div class="dropdown" id="note-actions">+ <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle">+ Note actions+ <span class="caret"></span>+ </button>+ <div class="dropdown-menu dropdown-menu-right">+ <a class="dropdown-item" id="show-note-revisions-button" data-bind="css: { disabled: type() == 'file' || type() == 'image' }">Revisions</a>+ <a class="dropdown-item show-attributes-button"><kbd>Alt+A</kbd> Attributes</a>+ <a class="dropdown-item" id="show-source-button" data-bind="css: { disabled: type() != 'text' }">HTML source</a>+ <a class="dropdown-item" id="upload-file-button">Upload file</a>+ <a class="dropdown-item" id="export-note-to-markdown-button" data-bind="css: { disabled: type() != 'text' }">Export as markdown</a>+ </div></div></div></div>