Use import report tiddler only if more than one tiddler is imported

If there’s only one, just display the tiddler itself.
print-window-tiddler
Jermolene 2014-02-21 20:17:34 +00:00
rodzic cf5fa875aa
commit 0961b0426b
1 zmienionych plików z 21 dodań i 12 usunięć

Wyświetl plik

@ -382,8 +382,14 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
var storyList = this.getStoryList(), var storyList = this.getStoryList(),
history = []; history = [];
// Create the import report tiddler // Create the import report tiddler
if(importedTiddlers.length === 0) {
return false;
}
var title;
if(importedTiddlers.length > 1) {
title = this.wiki.generateNewTitle("$:/temp/ImportReport");
var tiddlerFields = { var tiddlerFields = {
title: this.wiki.generateNewTitle("$:/temp/Import Report"), title: title,
text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n" text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n"
}; };
this.wiki.addTiddler(new $tw.Tiddler( this.wiki.addTiddler(new $tw.Tiddler(
@ -391,12 +397,15 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
tiddlerFields, tiddlerFields,
self.wiki.getModificationFields() self.wiki.getModificationFields()
)); ));
} else {
title = importedTiddlers[0];
}
// Add it to the story // Add it to the story
if(storyList.indexOf(tiddlerFields.title) === -1) { if(storyList.indexOf(title) === -1) {
storyList.unshift(tiddlerFields.title); storyList.unshift(title);
} }
// And to history // And to history
history.push(tiddlerFields.title); history.push(title);
// Save the updated story and history // Save the updated story and history
this.saveStoryList(storyList); this.saveStoryList(storyList);
this.addToHistory(history); this.addToHistory(history);