From 1e0ff0f9c2cd3ddbdb8c3d846730606fc0b0fd5c Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Wed, 3 Nov 2021 18:16:15 +0400 Subject: [PATCH] Fix #2045 ("fetch metadata" update appends to the existing tags instead or replacing them) --- cps/static/js/get_meta.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index f64be699..51ab740d 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -28,14 +28,17 @@ $(function () { function populateForm (book) { tinymce.get("description").setContent(book.description); - var uniqueTags = []; + var uniqueTags = $.map($("#tags").val().split(","), $.trim); + if ( uniqueTags.length == 1 && uniqueTags[0] == "") { + uniqueTags = []; + } $.each(book.tags, function(i, el) { if ($.inArray(el, uniqueTags) === -1) uniqueTags.push(el); }); var ampSeparatedAuthors = (book.authors || []).join(" & "); $("#bookAuthor").val(ampSeparatedAuthors); $("#book_title").val(book.title); - $("#tags").val(uniqueTags.join(",")); + $("#tags").val(uniqueTags.join(", ")); $("#rating").data("rating").setValue(Math.round(book.rating)); if(book.cover !== null){ $(".cover img").attr("src", book.cover);