1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 02:27:19 +00:00

Merge pull request #1963 from tobibeer/action-setfield-remove-index-or-field

updated #1480 "undefined value removes field or index"
This commit is contained in:
Jeremy Ruston 2015-09-25 16:34:03 +01:00
commit fd997c4581
3 changed files with 7 additions and 5 deletions

View File

@ -61,9 +61,7 @@ SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) {
var self = this,
options = {};
options.suppressTimestamp = !this.actionTimestamp;
if(typeof this.actionValue === "string") {
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue,options);
}
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue,options);
$tw.utils.each(this.attributes,function(attribute,name) {
if(name.charAt(0) !== "$") {
self.wiki.setText(self.actionTiddler,name,undefined,attribute,options);

View File

@ -65,7 +65,11 @@ exports.setText = function(title,field,index,value,options) {
// Check if it is a reference to a tiddler field
if(index) {
var data = this.getTiddlerData(title,Object.create(null));
data[index] = value;
if(value !== undefined) {
data[index] = value;
} else {
delete data[index];
}
this.setTiddlerData(title,data,modificationFields);
} else {
var tiddler = this.getTiddler(title),

View File

@ -17,7 +17,7 @@ The ''action-setfield'' widget is invisible. Any content within it is ignored.
|$tiddler |The title of the tiddler whose fields are to be modified (if not provided defaults to the [[current tiddler|Current Tiddler]] |
|$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 |
|$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. If no value is specified, $field or $index will be deleted.|
|$timestamp |Specifies whether the timestamp(s) of the target tiddler will be updated (''modified'' and ''modifier'', plus ''created'' and ''creator'' for newly created tiddlers). Can be "yes" (the default) or "no" |
|//{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 |