From bfc09187e3e475ce9dde3fae982332433e52fecf Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 8 Nov 2018 23:59:25 +0100 Subject: [PATCH] disabled note-level actions based on note type, fixes #218 --- docs/backend_api/Link.html | 367 +++++++++++++++++++ docs/backend_api/entities_link.js.html | 101 +++++ src/public/javascripts/services/note_type.js | 2 +- src/views/index.ejs | 64 ++-- 4 files changed, 500 insertions(+), 34 deletions(-) create mode 100644 docs/backend_api/Link.html create mode 100644 docs/backend_api/entities_link.js.html diff --git a/docs/backend_api/Link.html b/docs/backend_api/Link.html new file mode 100644 index 000000000..d5456947e --- /dev/null +++ b/docs/backend_api/Link.html @@ -0,0 +1,367 @@ + + + + + JSDoc: Class: Link + + + + + + + + + + +
+ +

Class: Link

+ + + + + + +
+ +
+ +

Link(linkId, noteId, targetNoteId, type, isDeleted, dateModified, dateCreated)

+ +
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.
+ + +
+ +
+
+ + + + +

Constructor

+ + + + + + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
linkId + + +string + + + +
noteId + + +string + + + +
targetNoteId + + +string + + + +
type + + +string + + + +
isDeleted + + +boolean + + + +
dateModified + + +string + + + +
dateCreated + + +string + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/backend_api/entities_link.js.html b/docs/backend_api/entities_link.js.html new file mode 100644 index 000000000..856b63da5 --- /dev/null +++ b/docs/backend_api/entities_link.js.html @@ -0,0 +1,101 @@ + + + + + JSDoc: Source: entities/link.js + + + + + + + + + + +
+ +

Source: entities/link.js

+ + + + + + +
+
+
"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;
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/src/public/javascripts/services/note_type.js b/src/public/javascripts/services/note_type.js index d629c457e..97e1d1e5e 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.ejs index 866b1e0ae..9fdbdc7fa 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -87,11 +87,7 @@
Search results: - +
@@ -142,36 +138,38 @@     -