mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Merge action-setfield and action-setfields widgets
Less confusion, hopefully.
This commit is contained in:
parent
24956f036e
commit
12aec57086
@ -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
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
||||
})();
|
@ -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>
|
||||
|
||||
<$button>
|
||||
<$action-setfield $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/>
|
||||
<$action-navigate $to="$:/ControlPanel"/>
|
||||
Go to Control Panel "Settings" tab
|
||||
</$button>'/>
|
||||
|
||||
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
|
||||
</$button>'/>
|
||||
|
||||
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
|
||||
</$button>'/>
|
||||
|
||||
Here is an example of a button that opens the control panel directly to the "Appearance" tabs:
|
||||
|
||||
<$macrocall $name='wikitext-example-without-html'
|
||||
|
@ -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>
|
||||
|
||||
<$button>
|
||||
<$action-setfields $tiddler="$:/state/tab-1749438307" text="$:/core/ui/ControlPanel/Settings"/>
|
||||
<$action-navigate $to="$:/ControlPanel"/>
|
||||
Go to Control Panel "Settings" tab
|
||||
</$button>'/>
|
||||
|
||||
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
|
||||
</$button>'/>
|
||||
|
||||
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
|
||||
</$button>'/>
|
@ -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]]
|
||||
|
Loading…
Reference in New Issue
Block a user