diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index e4dc8c372..eec8511d8 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -396,7 +396,7 @@ the backend.
Source:
@@ -1533,7 +1533,7 @@ the backend.
Source:
@@ -4249,7 +4249,7 @@ if some action needs to happen on only one specific instance.
- setNoteToParent(noteId, prefix, parentNoteIdopt)
+ setNoteToParent(noteId, prefix, parentNoteId)
@@ -4284,8 +4284,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Type |
- Attributes |
-
@@ -4311,14 +4309,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
-
-
-
-
-
-
- |
-
@@ -4342,14 +4332,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
-
-
-
-
-
-
- |
-
@@ -4367,22 +4349,15 @@ This method looks similar to toggleNoteInParent() but differs because we're look
string
+|
+
+null
-
-
- <optional>
-
-
-
-
-
- |
-
@@ -4415,6 +4390,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look
+ Deprecated:- - this method is pretty confusing and serves specialized purpose only
+
@@ -4427,7 +4404,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -4935,7 +4912,7 @@ transactional by default.
Source:
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 52e7f3546..eb68860b6 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -310,9 +310,10 @@ function BackendScriptApi(currentNote, apiParams) {
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
*
* @method
+ * @deprecated - this method is pretty confusing and serves specialized purpose only
* @param {string} noteId
* @param {string} prefix
- * @param {string} [parentNoteId]
+ * @param {string|null} parentNoteId
*/
this.setNoteToParent = treeService.setNoteToParent;
diff --git a/docs/frontend_api/FrontendScriptApi.html b/docs/frontend_api/FrontendScriptApi.html
index 3fd3adc2b..dc8fc5a64 100644
--- a/docs/frontend_api/FrontendScriptApi.html
+++ b/docs/frontend_api/FrontendScriptApi.html
@@ -1366,7 +1366,7 @@
Source:
@@ -1546,7 +1546,7 @@
Source:
@@ -1785,7 +1785,7 @@
Source:
@@ -1891,7 +1891,7 @@
Source:
@@ -2050,7 +2050,7 @@
Source:
@@ -2312,7 +2312,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -2775,7 +2775,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -2930,7 +2930,7 @@ otherwise (by e.g. createNoteLink())
Source:
@@ -3039,7 +3039,7 @@ note.
Source:
@@ -3194,7 +3194,7 @@ note.
Source:
@@ -3433,7 +3433,7 @@ note.
Source:
@@ -3463,6 +3463,218 @@ note.
+
+
+
+
+
+
+ refreshActiveTab() → {Promise.<void>}
+
+
+
+
+
+
+
+ Refresh active tab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<void>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ refreshAllTabs() → {Promise.<void>}
+
+
+
+
+
+
+
+ Refresh current tab
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<void>
+
+
+
+
+
+
+
+
+
+
+
@@ -4308,7 +4520,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
@@ -4459,7 +4671,7 @@ Internally this serializes the anonymous function into string and sends it to ba
Source:
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 82a89d2ac..e97f6466a 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -293,6 +293,22 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
*/
this.refreshTree = treeService.reload;
+ /**
+ * Refresh active tab
+ *
+ * @method
+ * @returns {Promise<void>}
+ */
+ this.refreshActiveTab = noteDetailService.reload;
+
+ /**
+ * Refresh current tab
+ *
+ * @method
+ * @returns {Promise<void>}
+ */
+ this.refreshAllTabs = noteDetailService.reloadAllTabs;
+
/**
* Create note link (jQuery object) for given note.
*
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index 67c2d1a56..ea6d2dd01 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -265,6 +265,22 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
*/
this.refreshTree = treeService.reload;
+ /**
+ * Refresh active tab
+ *
+ * @method
+ * @returns {Promise}
+ */
+ this.refreshActiveTab = noteDetailService.reload;
+
+ /**
+ * Refresh current tab
+ *
+ * @method
+ * @returns {Promise}
+ */
+ this.refreshAllTabs = noteDetailService.reloadAllTabs;
+
/**
* Create note link (jQuery object) for given note.
*
diff --git a/src/public/javascripts/services/note_detail_render.js b/src/public/javascripts/services/note_detail_render.js
index a6f3cc9fa..cb6292a68 100644
--- a/src/public/javascripts/services/note_detail_render.js
+++ b/src/public/javascripts/services/note_detail_render.js
@@ -18,7 +18,11 @@ class NoteDetailRender {
this.$component.show();
this.$noteDetailRenderHelp.hide();
- await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);
+ const renderNotesFound = await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);
+
+ if (!renderNotesFound) {
+ this.$noteDetailRenderHelp.show();
+ }
}
getContent() {}
diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js
index 620f6480f..c430c9f88 100644
--- a/src/services/backend_script_api.js
+++ b/src/services/backend_script_api.js
@@ -282,9 +282,10 @@ function BackendScriptApi(currentNote, apiParams) {
* This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.
*
* @method
+ * @deprecated - this method is pretty confusing and serves specialized purpose only
* @param {string} noteId
* @param {string} prefix
- * @param {string} [parentNoteId]
+ * @param {string|null} parentNoteId
*/
this.setNoteToParent = treeService.setNoteToParent;
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index 3ca90fe9e..a6bdf0fd9 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -267,7 +267,7 @@ async function findExistencyIssues() {
FROM branches
WHERE noteId = ?
and parentNoteId = ?
- and isDeleted = 1`, [noteId, parentNoteId]);
+ and isDeleted = 0`, [noteId, parentNoteId]);
// it's not necessarily "original" branch, it's just the only one which will survive
const origBranch = branches[0];
diff --git a/src/services/tree.js b/src/services/tree.js
index ca2459ac7..5a38c97a9 100644
--- a/src/services/tree.js
+++ b/src/services/tree.js
@@ -36,7 +36,7 @@ async function validateParentChild(parentNoteId, childNoteId, branchId = null) {
}
async function getExistingBranch(parentNoteId, childNoteId) {
- return await sql.getRow('SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
+ return await repository.getEntity('SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0', [childNoteId, parentNoteId]);
}
/**
@@ -123,6 +123,9 @@ async function sortNotesAlphabetically(parentNoteId, directoriesFirst = false) {
});
}
+/**
+ * @deprecated - this will be removed in the future
+ */
async function setNoteToParent(noteId, prefix, parentNoteId) {
const parentNote = await repository.getNote(parentNoteId);
@@ -151,11 +154,19 @@ async function setNoteToParent(noteId, prefix, parentNoteId) {
throw new Error(`Cannot create a branch for ${noteId} which is deleted.`);
}
- await new Branch({
- noteId: noteId,
- parentNoteId: parentNoteId,
- prefix: prefix
- }).save();
+ const branch = await repository.getEntity('SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ? AND parentNoteId = ?', [noteId, parentNoteId]);
+
+ if (branch) {
+ branch.prefix = prefix;
+ await branch.save();
+ }
+ else {
+ await new Branch({
+ noteId: noteId,
+ parentNoteId: parentNoteId,
+ prefix: prefix
+ }).save();
+ }
}
}