1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00

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

If there’s only one, just display the tiddler itself.
This commit is contained in:
Jermolene 2014-02-21 20:17:34 +00:00
parent cf5fa875aa
commit 0961b0426b

View File

@ -382,21 +382,30 @@ 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
var tiddlerFields = { if(importedTiddlers.length === 0) {
title: this.wiki.generateNewTitle("$:/temp/Import Report"), return false;
text: "# [[" + importedTiddlers.join("]]\n# [[") + "]]\n" }
}; var title;
this.wiki.addTiddler(new $tw.Tiddler( if(importedTiddlers.length > 1) {
self.wiki.getCreationFields(), title = this.wiki.generateNewTitle("$:/temp/ImportReport");
tiddlerFields, var tiddlerFields = {
self.wiki.getModificationFields() 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 // 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);