From b8f7e560d4b3afeb38b8602a8760d1918f3f899d Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Tue, 10 Sep 2024 22:39:45 +0100 Subject: [PATCH] Add UI button to datatable selections for adding items to collections Fix button still clickable after deleting a sample Remove Optional inside AddToCollectionModal --- .../src/components/AddToCollectionModal.vue | 95 +++++++++++++++++++ webapp/src/components/SampleTablePrime.vue | 32 ++++++- webapp/src/server_fetch_utils.js | 19 ++++ 3 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 webapp/src/components/AddToCollectionModal.vue diff --git a/webapp/src/components/AddToCollectionModal.vue b/webapp/src/components/AddToCollectionModal.vue new file mode 100644 index 000000000..a7a88b96b --- /dev/null +++ b/webapp/src/components/AddToCollectionModal.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/webapp/src/components/SampleTablePrime.vue b/webapp/src/components/SampleTablePrime.vue index 5e9aa0f1a..9e9b66d30 100644 --- a/webapp/src/components/SampleTablePrime.vue +++ b/webapp/src/components/SampleTablePrime.vue @@ -32,18 +32,27 @@ @@ -244,7 +265,8 @@ export default { visibility: visible !important; } -.button-right { +.button-group > * { + display: flex; gap: 0.5em; } diff --git a/webapp/src/server_fetch_utils.js b/webapp/src/server_fetch_utils.js index ee98cd286..2ea5eae62 100644 --- a/webapp/src/server_fetch_utils.js +++ b/webapp/src/server_fetch_utils.js @@ -704,3 +704,22 @@ export function getBlocksInfos() { throw error; }); } + +export function addItemsToCollection(collectionId, refcodes) { + return fetch_post(`${API_URL}/collections/${collectionId}`, { + data: { refcodes }, + }) + .then(function (response_json) { + if (response_json.status === "success") { + console.log("Items added to collection successfully!"); + return response_json; + } else { + console.error("Failed to add items to collection."); + throw new Error("Failed to add items to collection."); + } + }) + .catch(function (error) { + alert("Error adding items to collection: ", error); + throw error; + }); +}