From: Damyan Ivanov Date: Sun, 6 Mar 2022 11:33:29 +0000 (+0000) Subject: working list item updates, enter submits X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=446f81036c7082123098d6afe641c5a149deac25;p=lsl.git working list item updates, enter submits --- diff --git a/public/javascripts/lsl.js b/public/javascripts/lsl.js index 09f7144..3e66db6 100644 --- a/public/javascripts/lsl.js +++ b/public/javascripts/lsl.js @@ -281,6 +281,28 @@ function delete_list_item(dlg, li) { got_lists_version(resp.lists_version); }); } +function save_list_item(dlg,li) { + var new_description = dlg.find('input[type="text"]').val(); + + $.ajax( li.data('lsl-uri'), + { type: 'PUT', + data: JSON.stringify({ + description: new_description, + version: li.data('lsl-version')}) + } + ) + .done((d)=>{ + selected_list.data('lsl-version', selected_list.data('lsl-version') + 1); + + li.data('lsl-description', new_description); + li.data('lsl-version', d.version); + li.find('.description').text(new_description); + + dlg.dialog('destroy'); + got_list_version(d.list_version); + got_lists_version(d.lists_version); + }); +} function edit_list_item(li) { var d = $('
') .append( @@ -288,6 +310,14 @@ function edit_list_item(li) { .append( $('').text('Item name'), $('') + .on('keypress', (ev) => { + if (13 == ev.keyCode) { + save_list_item(d, li); + return false; + } + + return true; + }) .val(li.data('lsl-description')) ) );