1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-30 16:00:46 +00:00

Rename the action-setfield widget to action-setfields

It makes more sense, and allows us to add a widget: `<$action-setfield
$tiddler=“title” $name=“fieldname” $value=“fieldvalue”/>`
This commit is contained in:
Jermolene 2014-11-06 17:45:03 +00:00
parent 0a986ccd99
commit a18af9b760
2 changed files with 19 additions and 19 deletions

View File

@ -1,9 +1,9 @@
/*\ /*\
title: $:/core/modules/widgets/action-setfield.js title: $:/core/modules/widgets/action-setfields.js
type: application/javascript type: application/javascript
module-type: widget module-type: widget
Action widget to set fields on a tiddler. Action widget to set multiple fields on a tiddler.
\*/ \*/
(function(){ (function(){
@ -14,19 +14,19 @@ Action widget to set fields on a tiddler.
var Widget = require("$:/core/modules/widgets/widget.js").widget; var Widget = require("$:/core/modules/widgets/widget.js").widget;
var SetFieldWidget = function(parseTreeNode,options) { var SetFieldsWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options); this.initialise(parseTreeNode,options);
}; };
/* /*
Inherit from the base widget class Inherit from the base widget class
*/ */
SetFieldWidget.prototype = new Widget(); SetFieldsWidget.prototype = new Widget();
/* /*
Render this widget into the DOM Render this widget into the DOM
*/ */
SetFieldWidget.prototype.render = function(parent,nextSibling) { SetFieldsWidget.prototype.render = function(parent,nextSibling) {
this.computeAttributes(); this.computeAttributes();
this.execute(); this.execute();
}; };
@ -34,14 +34,14 @@ SetFieldWidget.prototype.render = function(parent,nextSibling) {
/* /*
Compute the internal state of the widget Compute the internal state of the widget
*/ */
SetFieldWidget.prototype.execute = function() { SetFieldsWidget.prototype.execute = function() {
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler")); this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
}; };
/* /*
Refresh the widget by ensuring our attributes are up to date Refresh the widget by ensuring our attributes are up to date
*/ */
SetFieldWidget.prototype.refresh = function(changedTiddlers) { SetFieldsWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
if(changedAttributes["$tiddler"]) { if(changedAttributes["$tiddler"]) {
this.refreshSelf(); this.refreshSelf();
@ -53,7 +53,7 @@ SetFieldWidget.prototype.refresh = function(changedTiddlers) {
/* /*
Invoke the action associated with this widget Invoke the action associated with this widget
*/ */
SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) { SetFieldsWidget.prototype.invokeAction = function(triggeringWidget,event) {
var self = this; var self = this;
$tw.utils.each(this.attributes,function(attribute,name) { $tw.utils.each(this.attributes,function(attribute,name) {
if(name.charAt(0) !== "$") { if(name.charAt(0) !== "$") {
@ -63,6 +63,6 @@ SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
return true; // Action was invoked return true; // Action was invoked
}; };
exports["action-setfield"] = SetFieldWidget; exports["action-setfields"] = SetFieldsWidget;
})(); })();

View File

@ -2,16 +2,16 @@ caption: action-setfield
created: 20141025120850184 created: 20141025120850184
modified: 20141025120850184 modified: 20141025120850184
tags: Widgets ActionWidgets tags: Widgets ActionWidgets
title: ActionSetFieldWidget title: ActionSetFieldsWidget
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
! Introduction ! Introduction
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. 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.
! Content and Attributes ! Content and Attributes
The ''action-setfield'' widget is invisible. Any content within it is ignored. The ''action-setfields'' widget is invisible. Any content within it is ignored.
|!Attribute |!Description | |!Attribute |!Description |
|$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[WidgetVariable: currentTiddler]] | |$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[WidgetVariable: currentTiddler]] |
@ -19,17 +19,17 @@ The ''action-setfield'' widget is invisible. Any content within it is ignored.
! Examples ! 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. 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' <$macrocall $name='wikitext-example-without-html'
src='<$button> src='<$button>
<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Appearance"/> <$action-setfields $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Appearance"/>
<$action-navigate $to="$:/ControlPanel"/> <$action-navigate $to="$:/ControlPanel"/>
Go to Control Panel "Appearance" tab Go to Control Panel "Appearance" tab
</$button> </$button>
<$button> <$button>
<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/> <$action-setfields $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/>
<$action-navigate $to="$:/ControlPanel"/> <$action-navigate $to="$:/ControlPanel"/>
Go to Control Panel "Settings" tab Go to Control Panel "Settings" tab
</$button>'/> </$button>'/>
@ -38,9 +38,9 @@ Here is an example of a button that assigns tags and fields to the tiddler Hello
<$macrocall $name='wikitext-example-without-html' <$macrocall $name='wikitext-example-without-html'
src='<$button> src='<$button>
<$action-setfield $tiddler="HelloThere" tags="NewTag [[Another New Tag]]" color="red"/> <$action-setfields $tiddler="HelloThere" tags="NewTag [[Another New Tag]]" color="red"/>
<$action-setfield $tiddler="$:/state/popup/tiddler-info--1779055697" text="(568,1443,33,39)"/> <$action-setfields $tiddler="$:/state/popup/tiddler-info--1779055697" text="(568,1443,33,39)"/>
<$action-setfield $tiddler="$:/state/tab--1890574033" text="$:/core/ui/TiddlerInfo/Fields"/> <$action-setfields $tiddler="$:/state/tab--1890574033" text="$:/core/ui/TiddlerInfo/Fields"/>
<$action-navigate $to="HelloThere"/> <$action-navigate $to="HelloThere"/>
Modify ~HelloThere Modify ~HelloThere
</$button>'/> </$button>'/>
@ -49,7 +49,7 @@ Here is an example of a button that assigns tags and fields to the tiddler Hello
<$macrocall $name='wikitext-example-without-html' <$macrocall $name='wikitext-example-without-html'
src='<$button> src='<$button>
<$action-setfield $tiddler="HelloThere" tags="MoreTag [[Further More Tags]]" color="green"/> <$action-setfields $tiddler="HelloThere" tags="MoreTag [[Further More Tags]]" color="green"/>
<$action-sendmessage $message="tm-edit-tiddler" $param="HelloThere"/> <$action-sendmessage $message="tm-edit-tiddler" $param="HelloThere"/>
Edit ~HelloThere Edit ~HelloThere
</$button>'/> </$button>'/>