From b47ed7b5b44f3498c04bdfa4952c2819d35d35b9 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sun, 7 Feb 2016 17:51:01 +0800 Subject: [PATCH] don't ask about adding 0 topics --- app/assets/javascripts/src/Metamaps.Import.js.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.Import.js.erb b/app/assets/javascripts/src/Metamaps.Import.js.erb index d17077ae..14612247 100644 --- a/app/assets/javascripts/src/Metamaps.Import.js.erb +++ b/app/assets/javascripts/src/Metamaps.Import.js.erb @@ -22,7 +22,9 @@ Metamaps.Import = { var text = e.originalEvent.clipboardData.getData('text/plain'); var parsed = self.parseTabbedString(text); - if (confirm("Are you sure you want to create " + parsed.length + " new topics?")) { + if (parsed.length > 0 && + confirm("Are you sure you want to create " + parsed.length + + " new topics?")) { self.importTopics(parsed); }//if }); @@ -76,7 +78,8 @@ Metamaps.Import = { return results; }, - createTopicWithParameters: function(name, metacode_name, permission, desc, link, xloc, yloc) { + createTopicWithParameters: function(name, metacode_name, permission, desc, + link, xloc, yloc) { var self = Metamaps.Topic; var metacode = Metamaps.Metacodes.where({name: metacode_name})[0] || null; @@ -99,6 +102,7 @@ Metamaps.Import = { }); Metamaps.Mappings.add(mapping); - self.renderTopic(mapping, topic, true, true); // this function also includes the creation of the topic in the database + // this function also includes the creation of the topic in the database + self.renderTopic(mapping, topic, true, true); }, };