2018-03-28 09:36:01 +08:00
|
|
|
import noteDetailService from "./note_detail.js";
|
2019-03-30 07:12:32 +08:00
|
|
|
import searchNotesService from "./search_notes.js";
|
2018-03-28 09:36:01 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
class NoteDetailSearch {
|
|
|
|
/**
|
2019-05-09 01:55:24 +08:00
|
|
|
* @param {TabContext} ctx
|
2019-05-04 06:16:41 +08:00
|
|
|
*/
|
|
|
|
constructor(ctx) {
|
|
|
|
this.ctx = ctx;
|
2019-05-09 01:55:24 +08:00
|
|
|
this.$searchString = ctx.$tabContent.find(".search-string");
|
|
|
|
this.$component = ctx.$tabContent.find('.note-detail-search');
|
|
|
|
this.$help = ctx.$tabContent.find(".note-detail-search-help");
|
|
|
|
this.$refreshButton = ctx.$tabContent.find('.note-detail-search-refresh-results-button');
|
2019-05-04 06:16:41 +08:00
|
|
|
|
|
|
|
this.$refreshButton.click(async () => {
|
|
|
|
await noteDetailService.saveNotesIfChanged();
|
|
|
|
|
|
|
|
await searchNotesService.refreshSearch();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-12 18:58:55 +08:00
|
|
|
render() {
|
2019-05-04 06:16:41 +08:00
|
|
|
this.$help.html(searchNotesService.getHelpText());
|
2018-03-28 09:36:01 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
this.$component.show();
|
2019-04-01 03:19:10 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
try {
|
|
|
|
const json = JSON.parse(this.ctx.note.content);
|
2018-03-28 09:36:01 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
this.$searchString.val(json.searchString);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
this.$searchString.val('');
|
|
|
|
}
|
2018-03-28 09:36:01 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
this.$searchString.on('input', noteDetailService.noteChanged);
|
2018-03-28 09:36:01 +08:00
|
|
|
}
|
2019-05-04 06:16:41 +08:00
|
|
|
|
|
|
|
getContent() {
|
|
|
|
return JSON.stringify({
|
|
|
|
searchString: this.$searchString.val()
|
|
|
|
});
|
2018-03-28 09:36:01 +08:00
|
|
|
}
|
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
focus() {}
|
2018-03-28 09:36:01 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
onNoteChange() {}
|
2019-02-16 04:21:26 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
cleanup() {}
|
2019-01-10 02:54:32 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
scrollToTop() {}
|
|
|
|
}
|
2019-01-09 06:32:03 +08:00
|
|
|
|
2019-05-04 06:16:41 +08:00
|
|
|
export default NoteDetailSearch;
|