1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 20:10:03 +00:00

Fix problem with cloning tiddlers

We were ignoring the tags on the template tiddler.

Fixes #1097
This commit is contained in:
Jermolene 2014-11-18 14:13:34 +00:00
parent 002d47b4d9
commit 931d47e50c

View File

@ -376,7 +376,7 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
// Get the story details
var storyList = this.getStoryList(),
templateTiddler, additionalFields, title, draftTitle, existingTiddler, mergedTags;
templateTiddler, additionalFields, title, draftTitle, existingTiddler;
// Get the template tiddler (if any)
if(typeof event.param === "string") {
// Get the template tiddler
@ -406,13 +406,17 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
existingTiddler = this.wiki.getTiddler(title);
}
// Merge the tags
if(existingTiddler && existingTiddler.fields.tags && additionalFields && additionalFields.tags) {
var mergedTags = [];
if(existingTiddler && existingTiddler.fields.tags) {
$tw.utils.pushTop(mergedTags,existingTiddler.fields.tags)
}
if(additionalFields && additionalFields.tags) {
// Merge tags
mergedTags = $tw.utils.pushTop($tw.utils.parseStringArray(additionalFields.tags),existingTiddler.fields.tags);
} else if(existingTiddler && existingTiddler.fields.tags) {
mergedTags = existingTiddler.fields.tags;
} else if(additionalFields && additionalFields.tags) {
mergedTags = additionalFields.tags;
mergedTags = $tw.utils.pushTop(mergedTags,$tw.utils.parseStringArray(additionalFields.tags));
}
if(templateTiddler && templateTiddler.fields.tags) {
// Merge tags
mergedTags = $tw.utils.pushTop(mergedTags,templateTiddler.fields.tags);
}
// Save the draft tiddler
var draftTiddler = new $tw.Tiddler({