From 169fd4945d6ca1e62285612d00bce668a7f53366 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 20 Sep 2020 12:20:36 -0700 Subject: [PATCH] Fix drag-drop behavior when dropping onto root. --- .../etiquette_flask/templates/album.html | 23 +++++++++++++++---- .../etiquette_flask/templates/album_card.html | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index 6f14972..51661bb 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -424,14 +424,29 @@ function on_album_drag_drop(event) return; } - const child_title = child.querySelector('.album_card_title').textContent.trim(); - const parent_title = parent.querySelector('.album_card_title').textContent.trim(); - const prompt = `Move\n${child_title}\ninto\n${parent_title}?`; + let prompt; + if (parent_id === "root") + { + const child_title = child.querySelector('.album_card_title').textContent.trim(); + prompt = `Remove child\n${child_title}?`; + } + else + { + const child_title = child.querySelector('.album_card_title').textContent.trim(); + const parent_title = parent.querySelector('.album_card_title').textContent.trim(); + prompt = `Move\n${child_title}\ninto\n${parent_title}?`; + } + if (! confirm(prompt)) { return; } - if (ALBUM_ID) + + if (parent_id === "root") + { + api.albums.remove_child(ALBUM_ID, child_id, common.refresh); + } + else if (ALBUM_ID) { api.albums.add_child(parent_id, child_id, null); api.albums.remove_child(ALBUM_ID, child_id, common.refresh); diff --git a/frontends/etiquette_flask/templates/album_card.html b/frontends/etiquette_flask/templates/album_card.html index 06c402d..b1f8f52 100644 --- a/frontends/etiquette_flask/templates/album_card.html +++ b/frontends/etiquette_flask/templates/album_card.html @@ -5,7 +5,7 @@