1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Use action-deletefield widget in edit template fields editor

On the way to deprecating the field mangler widget
This commit is contained in:
Jermolene 2014-11-06 18:32:11 +00:00
parent da1f9f7d22
commit 92f69d44bf
3 changed files with 17 additions and 4 deletions

View File

@ -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") {

View File

@ -8,7 +8,6 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
\define config-filter()
[[hide]] -[title{$(config-title)$}]
\end
<$fieldmangler>
<div class="tc-edit-fields">
<table class="tc-edit-fields">
<tbody>
@ -21,7 +20,10 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
</td>
<td class="tc-edit-field-remove">
<$button message="tm-remove-field" param=<<currentField>> class="tc-btn-invisible">{{$:/core/images/delete-button}}</$button>
<$button class="tc-btn-invisible">
<$action-deletefield $field=<<currentField>>/>
{{$:/core/images/delete-button}}
</$button>
</td>
</tr>
</$list>
@ -49,5 +51,3 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
</$button>
</span>
</div>
</$fieldmangler>

View File

@ -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
</$button>'/>
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>'/>