aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js
diff options
context:
space:
mode:
authorJan C <jan@ruken.pw>2016-02-15 08:48:44 (UTC)
committerJan C <jan@ruken.pw>2016-02-15 08:48:44 (UTC)
commit0d76691705dbbaa8b3972e09ed8df1e590b38da5 (patch)
treedf9c8ddcf95523eb90824f47669f529034914e13 /assets_src/js
parentf01703339943c432c4f47113983d90e118b7ff2c (diff)
grils können nun gelöscht werden.
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}