From 92f69d44bf0e171006b9be03f7a93189a2edcf88 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 6 Nov 2014 18:32:11 +0000 Subject: [PATCH] Use action-deletefield widget in edit template fields editor On the way to deprecating the field mangler widget --- core/modules/widgets/action-deletefield.js | 4 ++++ core/ui/EditTemplate/fields.tid | 8 ++++---- editions/prerelease/tiddlers/ActionDeleteFieldWidget.tid | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/modules/widgets/action-deletefield.js b/core/modules/widgets/action-deletefield.js index 0669e97d4..ad05c331c 100644 --- a/core/modules/widgets/action-deletefield.js +++ b/core/modules/widgets/action-deletefield.js @@ -36,6 +36,7 @@ Compute the internal state of the widget */ DeleteFieldWidget.prototype.execute = function() { this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler")); + this.actionField = this.getAttribute("$field"); }; /* @@ -57,6 +58,9 @@ DeleteFieldWidget.prototype.invokeAction = function(triggeringWidget,event) { var self = this, tiddler = this.wiki.getTiddler(self.actionTiddler), removeFields = {}; + if(this.actionField) { + removeFields[this.actionField] = undefined; + } if(tiddler) { $tw.utils.each(this.attributes,function(attribute,name) { if(name.charAt(0) !== "$" && name !== "title") { diff --git a/core/ui/EditTemplate/fields.tid b/core/ui/EditTemplate/fields.tid index 2a4e21a58..0cc0b1189 100644 --- a/core/ui/EditTemplate/fields.tid +++ b/core/ui/EditTemplate/fields.tid @@ -8,7 +8,6 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$ \define config-filter() [[hide]] -[title{$(config-title)$}] \end -<$fieldmangler>
@@ -21,7 +20,10 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$ <$edit-text tiddler=<> field=<> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/> @@ -49,5 +51,3 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$ - - diff --git a/editions/prerelease/tiddlers/ActionDeleteFieldWidget.tid b/editions/prerelease/tiddlers/ActionDeleteFieldWidget.tid index d01703131..d0b1a8f05 100644 --- a/editions/prerelease/tiddlers/ActionDeleteFieldWidget.tid +++ b/editions/prerelease/tiddlers/ActionDeleteFieldWidget.tid @@ -15,6 +15,7 @@ The ''action-deletefield'' 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 |Optional name of a field to delete | |//{any attributes not starting with $}// |Each attribute name specifies a field to be deleted. The attribute value is ignored and need not be specified | ! Examples @@ -34,3 +35,11 @@ src='<$button> <$action-deletefield $tiddler="HelloThere" modified tags/> Delete "modified" and "tags" from ~HelloThere '/> + +Here is an example of a button that uses the optional $field attribute to delete the text field of the tiddler HelloThere: + +<$macrocall $name='wikitext-example-without-html' +src='<$button> +<$action-deletefield $tiddler="HelloThere" $field="text"/> +Delete text from ~HelloThere +'/>
-<$button message="tm-remove-field" param=<> class="tc-btn-invisible">{{$:/core/images/delete-button}} +<$button class="tc-btn-invisible"> +<$action-deletefield $field=<>/> +{{$:/core/images/delete-button}} +