mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Fix importTitle and autoOpenOnImport in the tm-import-tiddler message (#7243)
* Add initial tm-import-tiddler test * Add failing test for tm-import-tiddlers importTitle #7234 * Add failing test for tm-import-tiddlers autoOpenOnImport #7234 * Use event.paramObject instead of event to access tm-import-tiddlers options. Fixes #7234. * Added a clarifying comment * Allow mixing tm-import-tiddler params in both event and event.paramObject * Added import test using tv-auto-open-on-import variable * Removed stray punctuation
This commit is contained in:
parent
77b418004a
commit
95dc56d850
@ -499,7 +499,8 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
// Get the tiddlers
|
||||
var tiddlers = $tw.utils.parseJSONSafe(event.param,[]);
|
||||
// Get the current $:/Import tiddler
|
||||
var importTitle = event.importTitle ? event.importTitle : IMPORT_TITLE,
|
||||
var paramObject = event.paramObject || {},
|
||||
importTitle = event.importTitle || paramObject.importTitle || IMPORT_TITLE,
|
||||
importTiddler = this.wiki.getTiddler(importTitle),
|
||||
importData = this.wiki.getTiddlerData(importTitle,{}),
|
||||
newFields = new Object({
|
||||
@ -540,7 +541,7 @@ NavigatorWidget.prototype.handleImportTiddlersEvent = function(event) {
|
||||
newFields.text = JSON.stringify(importData,null,$tw.config.preferences.jsonSpaces);
|
||||
this.wiki.addTiddler(new $tw.Tiddler(importTiddler,newFields));
|
||||
// Update the story and history details
|
||||
var autoOpenOnImport = event.autoOpenOnImport ? event.autoOpenOnImport : this.getVariable("tv-auto-open-on-import");
|
||||
var autoOpenOnImport = event.autoOpenOnImport || paramObject.autoOpenOnImport || this.getVariable("tv-auto-open-on-import");
|
||||
if(autoOpenOnImport !== "no") {
|
||||
var storyList = this.getStoryList(),
|
||||
history = [];
|
||||
|
@ -0,0 +1,35 @@
|
||||
title: Message/tm-import-tiddlers/CustomTitle
|
||||
description: tm-import-tiddlers message can import to a tiddler with a custom title
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{MyCustomTitle}}/>
|
||||
plugin-type: <$text text={{MyCustomTitle!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'
|
||||
importTitle=MyCustomTitle/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: MyCustomTitle</p>
|
@ -0,0 +1,35 @@
|
||||
title: Message/tm-import-tiddlers/NoAutoOpen
|
||||
description: tm-import-tiddlers can import without automatically opening the import tiddler
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'
|
||||
autoOpenOnImport=no/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: </p>
|
@ -0,0 +1,36 @@
|
||||
title: Message/tm-import-tiddlers/NoAutoOpenViaVar
|
||||
description: tm-import-tiddlers can import and open based on tv-auto-open-on-import
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$let tv-auto-open-on-import="no">
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'/>
|
||||
</$navigator>
|
||||
</$let>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: </p>
|
@ -0,0 +1,34 @@
|
||||
title: Message/tm-import-tiddlers/default
|
||||
description: tm-import-tiddlers message by default should import to $:/Import and open the tiddler
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
tags: [[$:/tags/wiki-test-spec]]
|
||||
|
||||
title: Output
|
||||
|
||||
text: <$text text={{$:/Import}}/>
|
||||
plugin-type: <$text text={{$:/Import!!plugin-type}}/>
|
||||
~$:/StoryList: <$text text={{$:/StoryList!!list}}/>
|
||||
+
|
||||
title: Actions
|
||||
|
||||
<$navigator story="$:/StoryList">
|
||||
<$action-sendmessage
|
||||
$message="tm-import-tiddlers"
|
||||
$param='[{"title": "Elephants"}, {"title": "Eagles"}]'/>
|
||||
</$navigator>
|
||||
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p>text: {
|
||||
"tiddlers": {
|
||||
"Elephants": {
|
||||
"title": "Elephants"
|
||||
},
|
||||
"Eagles": {
|
||||
"title": "Eagles"
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin-type: import
|
||||
$:/StoryList: $:/Import</p>
|
Loading…
Reference in New Issue
Block a user