aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets_src/js')
-rw-r--r--assets_src/js/lib/ajax.js3
-rw-r--r--assets_src/js/list.js13
2 files changed, 15 insertions, 1 deletions
diff --git a/assets_src/js/lib/ajax.js b/assets_src/js/lib/ajax.js
index 048f516..b189a92 100644
--- a/assets_src/js/lib/ajax.js
+++ b/assets_src/js/lib/ajax.js
@@ -58,3 +58,6 @@ export async function get(url, options) {
58export async function post(url, body, options) { 58export async function post(url, body, options) {
59 return request('POST', url, body, options); 59 return request('POST', url, body, options);
60} 60}
61export async function del(url, body, options) {
62 return request('DELETE', url, body, options);
63}
diff --git a/assets_src/js/list.js b/assets_src/js/list.js
index be7f007..7a4f69e 100644
--- a/assets_src/js/list.js
+++ b/assets_src/js/list.js
@@ -68,8 +68,19 @@ async function listButtonHandler(e) {
68 } 68 }
69 break; 69 break;
70 case 'gril-delete': 70 case 'gril-delete':
71 //TODO: backend 71 let liFilter = x => x.tagName && x.tagName.toLowerCase() === 'li';
72 let item = dom.closest(e.target, liFilter);
73 try {
74 await ajax.del(
75 `${window.location}/order`,
76 `gril=${item.id}`,
77 { headers: {
78 'Content-Type': 'application/x-www-form-urlencoded',
79 } });
72 item.parentNode.removeChild(item); 80 item.parentNode.removeChild(item);
81 } catch(e) {
82 alert(e.message);
83 }
73 break; 84 break;
74 } 85 }
75} 86}