From b26aea96f408f2d0033f94e68b189b17b9e6d70d Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 29 Mar 2021 15:11:54 -0500 Subject: [PATCH] delete bookmarklet on import --- cookbook/templates/url_import.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html index e2617c59..83d95222 100644 --- a/cookbook/templates/url_import.html +++ b/cookbook/templates/url_import.html @@ -756,6 +756,15 @@ this.makeToast(gettext('Error'), gettext('There was an error loading bookmarklet!') + err.bodyText, 'danger') }) }, + deleteBookmarklet: function(id_bkmk) { + this.error = undefined + this.$http.delete("{% url 'api:bookmarkletimport-list' %}" + id_bkmk +"/").then((response) => { + }).catch((err) => { + this.error = err.data + console.log(err) + this.makeToast(gettext('Error'), gettext('There was an error deleting bookmarklet!') + err.bodyText, 'danger') + }) + }, loadRecipeManual: function () { this.error = undefined this.preview = false @@ -789,6 +798,12 @@ this.importing_recipe = true this.$set(this.recipe_data, 'all_keywords', this.all_keywords) this.$http.post(`{% url 'data_import_url' %}`, this.recipe_data).then((response) => { + let uri = window.location.search.substring(1); + let params = new URLSearchParams(uri); + q = params.get("id") + if (q) { + this.deleteBookmarklet(q) + } window.location.href = response.data }).catch((err) => { console.log(err);