From 0961b0426be2c56db39418a5d751319fa0afc8ad Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 21 Feb 2014 20:17:34 +0000 Subject: [PATCH] Use import report tiddler only if more than one tiddler is imported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there’s only one, just display the tiddler itself. --- core/modules/widgets/navigator.js | 33 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index d83131cde..13c7ec22a 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -382,21 +382,30 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) { var storyList = this.getStoryList(), history = []; // Create the import report tiddler - var tiddlerFields = { - title: this.wiki.generateNewTitle("$:/temp/Import Report"), - text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n" - }; - this.wiki.addTiddler(new $tw.Tiddler( - self.wiki.getCreationFields(), - tiddlerFields, - self.wiki.getModificationFields() - )); + if(importedTiddlers.length === 0) { + return false; + } + var title; + if(importedTiddlers.length > 1) { + title = this.wiki.generateNewTitle("$:/temp/ImportReport"); + var tiddlerFields = { + title: title, + text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n" + }; + this.wiki.addTiddler(new $tw.Tiddler( + self.wiki.getCreationFields(), + tiddlerFields, + self.wiki.getModificationFields() + )); + } else { + title = importedTiddlers[0]; + } // Add it to the story - if(storyList.indexOf(tiddlerFields.title) === -1) { - storyList.unshift(tiddlerFields.title); + if(storyList.indexOf(title) === -1) { + storyList.unshift(title); } // And to history - history.push(tiddlerFields.title); + history.push(title); // Save the updated story and history this.saveStoryList(storyList); this.addToHistory(history);