mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-10 07:43:49 +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:
parent
da1f9f7d22
commit
92f69d44bf
@ -36,6 +36,7 @@ Compute the internal state of the widget
|
|||||||
*/
|
*/
|
||||||
DeleteFieldWidget.prototype.execute = function() {
|
DeleteFieldWidget.prototype.execute = function() {
|
||||||
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
|
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,
|
var self = this,
|
||||||
tiddler = this.wiki.getTiddler(self.actionTiddler),
|
tiddler = this.wiki.getTiddler(self.actionTiddler),
|
||||||
removeFields = {};
|
removeFields = {};
|
||||||
|
if(this.actionField) {
|
||||||
|
removeFields[this.actionField] = undefined;
|
||||||
|
}
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
$tw.utils.each(this.attributes,function(attribute,name) {
|
$tw.utils.each(this.attributes,function(attribute,name) {
|
||||||
if(name.charAt(0) !== "$" && name !== "title") {
|
if(name.charAt(0) !== "$" && name !== "title") {
|
||||||
|
@ -8,7 +8,6 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
|||||||
\define config-filter()
|
\define config-filter()
|
||||||
[[hide]] -[title{$(config-title)$}]
|
[[hide]] -[title{$(config-title)$}]
|
||||||
\end
|
\end
|
||||||
<$fieldmangler>
|
|
||||||
<div class="tc-edit-fields">
|
<div class="tc-edit-fields">
|
||||||
<table class="tc-edit-fields">
|
<table class="tc-edit-fields">
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -21,7 +20,10 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
|||||||
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
|
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
|
||||||
</td>
|
</td>
|
||||||
<td class="tc-edit-field-remove">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</$list>
|
</$list>
|
||||||
@ -49,5 +51,3 @@ $:/config/EditTemplateFields/Visibility/$(currentField)$
|
|||||||
</$button>
|
</$button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</$fieldmangler>
|
|
||||||
|
@ -15,6 +15,7 @@ The ''action-deletefield'' 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]] |
|
||||||
|
|$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 |
|
|//{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
|
! Examples
|
||||||
@ -34,3 +35,11 @@ src='<$button>
|
|||||||
<$action-deletefield $tiddler="HelloThere" modified tags/>
|
<$action-deletefield $tiddler="HelloThere" modified tags/>
|
||||||
Delete "modified" and "tags" from ~HelloThere
|
Delete "modified" and "tags" from ~HelloThere
|
||||||
</$button>'/>
|
</$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>'/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user