diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 2e39fdd20..efdbba83f 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -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 = []; diff --git a/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/CustomTitle.tid b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/CustomTitle.tid new file mode 100644 index 000000000..2c7b8ba05 --- /dev/null +++ b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/CustomTitle.tid @@ -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/> + + ++ +title: ExpectedResult + +

text: { + "tiddlers": { + "Elephants": { + "title": "Elephants" + }, + "Eagles": { + "title": "Eagles" + } + } +} +plugin-type: import +$:/StoryList: MyCustomTitle

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpen.tid b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpen.tid new file mode 100644 index 000000000..cc2c3673a --- /dev/null +++ b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpen.tid @@ -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/> + + ++ +title: ExpectedResult + +

text: { + "tiddlers": { + "Elephants": { + "title": "Elephants" + }, + "Eagles": { + "title": "Eagles" + } + } +} +plugin-type: import +$:/StoryList:

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpenViaVar.tid b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpenViaVar.tid new file mode 100644 index 000000000..6970131f1 --- /dev/null +++ b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/NoAutoOpenViaVar.tid @@ -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"}]'/> + + + ++ +title: ExpectedResult + +

text: { + "tiddlers": { + "Elephants": { + "title": "Elephants" + }, + "Eagles": { + "title": "Eagles" + } + } +} +plugin-type: import +$:/StoryList:

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/default.tid b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/default.tid new file mode 100644 index 000000000..715a763f4 --- /dev/null +++ b/editions/test/tiddlers/tests/data/messages/tm-import-tiddler/default.tid @@ -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"}]'/> + + ++ +title: ExpectedResult + +

text: { + "tiddlers": { + "Elephants": { + "title": "Elephants" + }, + "Eagles": { + "title": "Eagles" + } + } +} +plugin-type: import +$:/StoryList: $:/Import

\ No newline at end of file