saved search note now has refresh button, closes #369

This commit is contained in:
zadam 2019-03-30 00:12:32 +01:00
parent f479c0e10e
commit 7bbf797caf
6 changed files with 29 additions and 6 deletions

View File

@ -107,6 +107,8 @@ $("#logout-button").click(() => {
$("#tree").on("click", ".unhoist-button", hoistedNoteService.unhoist); $("#tree").on("click", ".unhoist-button", hoistedNoteService.unhoist);
$("#tree").on("click", ".refresh-search-button", searchNotesService.refreshSearch);
$("body").on("click", "a.external", function () { $("body").on("click", "a.external", function () {
window.open($(this).attr("href"), '_blank'); window.open($(this).attr("href"), '_blank');
}); });

View File

@ -1,6 +1,5 @@
import noteDetailService from "./note_detail.js"; import noteDetailService from "./note_detail.js";
import treeService from "./tree.js"; import searchNotesService from "./search_notes.js";
import infoService from './info.js';
const $searchString = $("#search-string"); const $searchString = $("#search-string");
const $component = $('#note-detail-search'); const $component = $('#note-detail-search');
@ -31,9 +30,7 @@ function getContent() {
$refreshButton.click(async () => { $refreshButton.click(async () => {
await noteDetailService.saveNoteIfChanged(); await noteDetailService.saveNoteIfChanged();
treeService.reload(); await searchNotesService.refreshSearch();
infoService.showMessage('Tree has been refreshed.');
}); });
export default { export default {

View File

@ -96,6 +96,15 @@ async function saveSearch() {
resetSearch(); resetSearch();
} }
async function refreshSearch() {
const activeNode = treeService.getActiveNode();
activeNode.load(true);
activeNode.setExpanded(true);
infoService.showMessage("Saved search note refreshed.");
}
function init() { function init() {
const hashValue = treeService.getHashValueFromAddress(); const hashValue = treeService.getHashValueFromAddress();
@ -129,6 +138,7 @@ export default {
toggleSearch, toggleSearch,
resetSearch, resetSearch,
showSearch, showSearch,
refreshSearch,
doSearch, doSearch,
init init
}; };

View File

@ -453,6 +453,14 @@ function initFancyTree(tree) {
$span.append(unhoistButton); $span.append(unhoistButton);
} }
const note = await treeCache.getNote(node.data.noteId);
if (note.type === 'search' && $span.find('.refresh-search-button').length === 0) {
const refreshSearchButton = $('<span>&nbsp; <span class="refresh-search-button jam jam-refresh" title="Refresh saved search results"></span></span>');
$span.append(refreshSearchButton);
}
}, },
// this is done to automatically lazy load all expanded search notes after tree load // this is done to automatically lazy load all expanded search notes after tree load
loadChildren: function(event, data) { loadChildren: function(event, data) {

View File

@ -134,3 +134,9 @@ li.dropdown-submenu:hover > ul.dropdown-menu {
text-decoration: underline; text-decoration: underline;
transform: rotate(-90deg); transform: rotate(-90deg);
} }
.refresh-search-button {
cursor: pointer;
position: relative;
top: -1px;
}

View File

@ -5,7 +5,7 @@
<span> <span>
&nbsp; &nbsp; &nbsp; &nbsp;
<button type="button" class="btn btn-primary" id="note-detail-search-refresh-results-button">Refresh tree</button> <button type="button" class="btn btn-primary" id="note-detail-search-refresh-results-button">Refresh search results</button>
</span> </span>
</div> </div>