diff --git a/core/modules/widgets/action-setfield.js b/core/modules/widgets/action-setfield.js index 9638353e3..a9dec25bf 100644 --- a/core/modules/widgets/action-setfield.js +++ b/core/modules/widgets/action-setfield.js @@ -57,7 +57,14 @@ SetFieldWidget.prototype.refresh = function(changedTiddlers) { Invoke the action associated with this widget */ SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) { - this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue); + if(this.actionValue) { + this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue); + } + $tw.utils.each(this.attributes,function(attribute,name) { + if(name.charAt(0) !== "$") { + self.wiki.setText(self.actionTiddler,name,undefined,attribute); + } + }); return true; // Action was invoked }; diff --git a/core/modules/widgets/action-setfields.js b/core/modules/widgets/action-setfields.js deleted file mode 100644 index 23abb2a08..000000000 --- a/core/modules/widgets/action-setfields.js +++ /dev/null @@ -1,68 +0,0 @@ -/*\ -title: $:/core/modules/widgets/action-setfields.js -type: application/javascript -module-type: widget - -Action widget to set multiple fields on a tiddler. - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -var Widget = require("$:/core/modules/widgets/widget.js").widget; - -var SetFieldsWidget = function(parseTreeNode,options) { - this.initialise(parseTreeNode,options); -}; - -/* -Inherit from the base widget class -*/ -SetFieldsWidget.prototype = new Widget(); - -/* -Render this widget into the DOM -*/ -SetFieldsWidget.prototype.render = function(parent,nextSibling) { - this.computeAttributes(); - this.execute(); -}; - -/* -Compute the internal state of the widget -*/ -SetFieldsWidget.prototype.execute = function() { - this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler")); -}; - -/* -Refresh the widget by ensuring our attributes are up to date -*/ -SetFieldsWidget.prototype.refresh = function(changedTiddlers) { - var changedAttributes = this.computeAttributes(); - if(changedAttributes["$tiddler"]) { - this.refreshSelf(); - return true; - } - return this.refreshChildren(changedTiddlers); -}; - -/* -Invoke the action associated with this widget -*/ -SetFieldsWidget.prototype.invokeAction = function(triggeringWidget,event) { - var self = this; - $tw.utils.each(this.attributes,function(attribute,name) { - if(name.charAt(0) !== "$") { - self.wiki.setText(self.actionTiddler,name,undefined,attribute); - } - }); - return true; // Action was invoked -}; - -exports["action-setfields"] = SetFieldsWidget; - -})(); diff --git a/editions/prerelease/tiddlers/ActionSetFieldWidget.tid b/editions/prerelease/tiddlers/ActionSetFieldWidget.tid index ab8a0dc9b..7f387b8f7 100644 --- a/editions/prerelease/tiddlers/ActionSetFieldWidget.tid +++ b/editions/prerelease/tiddlers/ActionSetFieldWidget.tid @@ -7,9 +7,7 @@ type: text/vnd.tiddlywiki ! Introduction -The ''action-setfield'' widget is an [[action widget|ActionWidgets]] that assigns a value to a specified field of a tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget. - -See also the ActionSetFieldsWidget (note the extra "s") that provides a way to set the values of multiple fields in a single operation. +The ''action-setfield'' widget is an [[action widget|ActionWidgets]] that assigns values to the fields of a tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget. ! Content and Attributes @@ -17,12 +15,48 @@ The ''action-setfield'' widget is invisible. Any content within it is ignored. |!Attribute |!Description | |$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[WidgetVariable: currentTiddler]] | -|$field |The name of the field to be modified. If neither a field or index is specified, then the default field "text" is used | -|$index |If $field is not provided, specifies the index of a [[data tiddler|DataTiddlers]] to modify | -|$value |The value to be assigned to the field or index | +|$field |Optional name of a field to be assigned the $value attribute | +|$index |Optional index of a property in a [[data tiddler|DataTiddlers]] to be assigned the $value attribute| +|$value |The value to be assigned to the field or index identified by the $field or $index attribute. If neither is specified then the value is assigned to the text field | +|//{any attributes not starting with $}// |Each attribute name specifies a field to be modified with the attribute value providing the value to assign to the field | ! Examples +Here is an example of a pair of buttons that open the control panel directly to specified tabs. They work by using ''action-setfield'' to set the state tiddler for the control panel tabs. + +<$macrocall $name='wikitext-example-without-html' +src='<$button> +<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Appearance"/> +<$action-navigate $to="$:/ControlPanel"/> +Go to Control Panel "Appearance" tab + + +<$button> +<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/> +<$action-navigate $to="$:/ControlPanel"/> +Go to Control Panel "Settings" tab +'/> + +Here is an example of a button that assigns tags and fields to the tiddler HelloThere, and then navigates to it and opens the tiddler info panel on the "Fields" tab: + +<$macrocall $name='wikitext-example-without-html' +src='<$button> +<$action-setfield $tiddler="HelloThere" tags="NewTag [[Another New Tag]]" color="red"/> +<$action-setfield $tiddler="$:/state/popup/tiddler-info--1779055697" text="(568,1443,33,39)"/> +<$action-setfield $tiddler="$:/state/tab--1890574033" text="$:/core/ui/TiddlerInfo/Fields"/> +<$action-navigate $to="HelloThere"/> +Modify ~HelloThere +'/> + +Here is an example of a button that assigns tags and fields to the tiddler HelloThere, and then initiates editing it: + +<$macrocall $name='wikitext-example-without-html' +src='<$button> +<$action-setfield $tiddler="HelloThere" tags="MoreTag [[Further More Tags]]" color="green"/> +<$action-sendmessage $message="tm-edit-tiddler" $param="HelloThere"/> +Edit ~HelloThere +'/> + Here is an example of a button that opens the control panel directly to the "Appearance" tabs: <$macrocall $name='wikitext-example-without-html' diff --git a/editions/prerelease/tiddlers/ActionSetFieldsWidget.tid b/editions/prerelease/tiddlers/ActionSetFieldsWidget.tid deleted file mode 100644 index 3e0e5ede0..000000000 --- a/editions/prerelease/tiddlers/ActionSetFieldsWidget.tid +++ /dev/null @@ -1,57 +0,0 @@ -caption: action-setfields -created: 20141025120850184 -modified: 20141025120850184 -tags: Widgets ActionWidgets -title: ActionSetFieldsWidget -type: text/vnd.tiddlywiki - -! Introduction - -The ''action-setfields'' widget is an [[action widget|ActionWidgets]] that assigns values to the fields of a tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget. - -See also the ActionSetFieldWidget (note the lack of the "s") that provides a more flexible way to set the value of a single field. - -! Content and Attributes - -The ''action-setfields'' widget is invisible. Any content within it is ignored. - -|!Attribute |!Description | -|$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[WidgetVariable: currentTiddler]] | -|//{any attributes not starting with $}// |Each attribute name specifies a field to be modified with the attribute value providing the value to assign to the field | - -! Examples - -Here is an example of a pair of buttons that open the control panel directly to specified tabs. They work by using ''action-setfields'' to set the state tiddler for the control panel tabs. - -<$macrocall $name='wikitext-example-without-html' -src='<$button> -<$action-setfields $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Appearance"/> -<$action-navigate $to="$:/ControlPanel"/> -Go to Control Panel "Appearance" tab - - -<$button> -<$action-setfields $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/> -<$action-navigate $to="$:/ControlPanel"/> -Go to Control Panel "Settings" tab -'/> - -Here is an example of a button that assigns tags and fields to the tiddler HelloThere, and then navigates to it and opens the tiddler info panel on the "Fields" tab: - -<$macrocall $name='wikitext-example-without-html' -src='<$button> -<$action-setfields $tiddler="HelloThere" tags="NewTag [[Another New Tag]]" color="red"/> -<$action-setfields $tiddler="$:/state/popup/tiddler-info--1779055697" text="(568,1443,33,39)"/> -<$action-setfields $tiddler="$:/state/tab--1890574033" text="$:/core/ui/TiddlerInfo/Fields"/> -<$action-navigate $to="HelloThere"/> -Modify ~HelloThere -'/> - -Here is an example of a button that assigns tags and fields to the tiddler HelloThere, and then initiates editing it: - -<$macrocall $name='wikitext-example-without-html' -src='<$button> -<$action-setfields $tiddler="HelloThere" tags="MoreTag [[Further More Tags]]" color="green"/> -<$action-sendmessage $message="tm-edit-tiddler" $param="HelloThere"/> -Edit ~HelloThere -'/> diff --git a/editions/prerelease/tiddlers/Release 5.1.5.tid b/editions/prerelease/tiddlers/Release 5.1.5.tid index 527b03b97..d77e17ad9 100644 --- a/editions/prerelease/tiddlers/Release 5.1.5.tid +++ b/editions/prerelease/tiddlers/Release 5.1.5.tid @@ -21,7 +21,7 @@ type: text/vnd.tiddlywiki !! Hackability Improvements -* Introduced new ActionSetFieldWidget, ActionSetFieldsWidget, ActionDeleteFieldWidget and ActionDeleteTiddlerWidget for manipulating tiddler fields and values +* Introduced new ActionSetFieldWidget, ActionDeleteFieldWidget and ActionDeleteTiddlerWidget for manipulating tiddler fields and values * [[Enhanced|https://github.com/Jermolene/TiddlyWiki5/commit/4a172125768e3b33c30e725e8550454a9d26c5c4]] the EditTextWidget to allow more control over the sizing of textarea editors * [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/13726ef73157d9e9d65ae4027d9c32aaa7cdcc90]] new canned filter for recently modified system tiddlers in [[$:/AdvancedSearch]] * [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/c20c935faabbb63f679bc4720b52162c56b6af64]] new system image for videos: [[$:/core/images/video]]