#126, "show recent notes" now work in relations dialog

This commit is contained in:
azivner 2018-07-28 17:02:48 +02:00
parent 697eee2706
commit 6a50afd952
3 changed files with 18 additions and 16 deletions

View File

@ -167,9 +167,9 @@ async function showDialog() {
}); });
} }
ko.applyBindings(labelsModel, document.getElementById('labels-dialog')); ko.applyBindings(labelsModel, $dialog[0]);
$(document).on('focus', '.label-name', function (e) { $dialog.on('focus', '.label-name', function (e) {
if (!$(this).hasClass("ui-autocomplete-input")) { if (!$(this).hasClass("ui-autocomplete-input")) {
$(this).autocomplete({ $(this).autocomplete({
// shouldn't be required and autocomplete should just accept array of strings, but that fails // shouldn't be required and autocomplete should just accept array of strings, but that fails
@ -187,7 +187,7 @@ $(document).on('focus', '.label-name', function (e) {
$(this).autocomplete("search", $(this).val()); $(this).autocomplete("search", $(this).val());
}); });
$(document).on('focus', '.label-value', async function (e) { $dialog.on('focus', '.label-value', async function (e) {
if (!$(this).hasClass("ui-autocomplete-input")) { if (!$(this).hasClass("ui-autocomplete-input")) {
const labelName = $(this).parent().parent().find('.label-name').val(); const labelName = $(this).parent().parent().find('.label-name').val();

View File

@ -1,9 +1,6 @@
import noteDetailService from '../services/note_detail.js'; import noteDetailService from '../services/note_detail.js';
import server from '../services/server.js'; import server from '../services/server.js';
import infoService from "../services/info.js"; import infoService from "../services/info.js";
import treeService from "../services/tree.js";
import linkService from "../services/link.js";
import treeUtils from "../services/tree_utils.js";
const $dialog = $("#relations-dialog"); const $dialog = $("#relations-dialog");
const $saveRelationsButton = $("#save-relations-button"); const $saveRelationsButton = $("#save-relations-button");
@ -177,7 +174,7 @@ async function showDialog() {
ko.applyBindings(relationsModel, document.getElementById('relations-dialog')); ko.applyBindings(relationsModel, document.getElementById('relations-dialog'));
$(document).on('focus', '.relation-name', function (e) { $dialog.on('focus', '.relation-name', function (e) {
if (!$(this).hasClass("ui-autocomplete-input")) { if (!$(this).hasClass("ui-autocomplete-input")) {
$(this).autocomplete({ $(this).autocomplete({
// shouldn't be required and autocomplete should just accept array of strings, but that fails // shouldn't be required and autocomplete should just accept array of strings, but that fails
@ -195,10 +192,10 @@ $(document).on('focus', '.relation-name', function (e) {
$(this).autocomplete("search", $(this).val()); $(this).autocomplete("search", $(this).val());
}); });
$(document).on('focus', '.relation-target-note-id', async function (e) { async function initAutocomplete($el) {
if (!$(this).hasClass("ui-autocomplete-input")) { if (!$el.hasClass("ui-autocomplete-input")) {
await $(this).autocomplete({ await $el.autocomplete({
source: async function(request, response) { source: async function (request, response) {
const result = await server.get('autocomplete?query=' + encodeURIComponent(request.term)); const result = await server.get('autocomplete?query=' + encodeURIComponent(request.term));
if (result.length > 0) { if (result.length > 0) {
@ -224,15 +221,20 @@ $(document).on('focus', '.relation-target-note-id', async function (e) {
}, },
}); });
} }
}
$dialog.on('focus', '.relation-target-note-id', async function (e) {
await initAutocomplete($(this));
$(this).autocomplete("search", $(this).val()); $(this).autocomplete("search", $(this).val());
}); });
$(document).on('click', '.relations-show-recent-notes', function () { $dialog.on('click', '.relations-show-recent-notes', async function () {
alert("HI!"); const $autocomplete = $(this).parent().find('.relation-target-note-id');
alert($(this).parent().find('.relation-target-note-id').length);
$(this).parent().find('.relation-target-note-id').autocomplete("search", ""); await initAutocomplete($autocomplete);
$autocomplete.autocomplete("search", "");
}); });
export default { export default {

View File

@ -626,7 +626,7 @@
data-bind="value: targetNoteId, valueUpdate: 'blur', event: { blur: $parent.relationChanged }" data-bind="value: targetNoteId, valueUpdate: 'blur', event: { blur: $parent.relationChanged }"
style="width: 300px;"> style="width: 300px;">
<span class="input-group-addon" class="relations-show-recent-notes" title="Show recent notes" style="background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer;"></span> <span class="input-group-addon relations-show-recent-notes" title="Show recent notes" style="background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer;"></span>
</div> </div>
</td> </td>
<td title="Delete" style="padding: 13px;"> <td title="Delete" style="padding: 13px;">