1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-29 16:53:14 +00:00

Fixes to action-deletetiddler widget

This commit is contained in:
Jermolene 2014-11-09 16:45:14 +00:00
parent 23ca729805
commit 8c67e11365
2 changed files with 17 additions and 8 deletions

View File

@ -35,8 +35,8 @@ DeleteTiddlerWidget.prototype.render = function(parent,nextSibling) {
Compute the internal state of the widget
*/
DeleteTiddlerWidget.prototype.execute = function() {
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
this.actionConfirm = this.getAttribute("$confirm");
this.actionFilter = this.getAttribute("$filter");
this.actionTiddler = this.getAttribute("$tiddler");
};
/*
@ -44,7 +44,7 @@ Refresh the widget by ensuring our attributes are up to date
*/
DeleteTiddlerWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["$tiddler"] || changedAttributes["$confirm"]) {
if(changedAttributes["$filter"] || changedAttributes["$tiddler"]) {
this.refreshSelf();
return true;
}
@ -55,8 +55,16 @@ DeleteTiddlerWidget.prototype.refresh = function(changedTiddlers) {
Invoke the action associated with this widget
*/
DeleteTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) {
this.wiki.setText(this.actionTiddler,this.actionField,this.actionIndex,this.actionValue);
var tiddlers;
if(this.actionFilter) {
tiddlers = this.wiki.filterTiddlers(this.actionFilter,this);
}
if(this.actionTiddler) {
tiddlers.push(this.actionTiddler);
}
for(var t=0; t<tiddlers.length; t++) {
this.wiki.deleteTiddler(tiddlers[t]);
}
return true; // Action was invoked
};

View File

@ -7,7 +7,7 @@ type: text/vnd.tiddlywiki
! Introduction
The ''action-deletetiddler'' widget is an [[action widget|ActionWidgets]] that deletes a tiddler. ActionWidgets are used within triggering widgets such as the ButtonWidget.
The ''action-deletetiddler'' widget is an [[action widget|ActionWidgets]] that deletes tiddlers. ActionWidgets are used within triggering widgets such as the ButtonWidget.
There are several differences compared to the [[WidgetMessage: tm-delete-tiddler]]:
@ -20,7 +20,8 @@ There are several differences compared to the [[WidgetMessage: tm-delete-tiddler
The ''action-deletetiddler'' widget is invisible. Any content within it is ignored.
|!Attribute |!Description |
|$tiddler |The title of the tiddler to be deleted (if not provided defaults to the [[WidgetVariable: currentTiddler]] |
|$tiddler |Optional title of the tiddler to be deleted |
|$filter |Optional filter identifying tiddlers to be deleted |
! Examples
@ -29,5 +30,5 @@ Here is an example of a button that deletes the tiddler HelloThere. Note:
<$macrocall $name='wikitext-example-without-html'
src='<$button>
<$action-deletetiddler $tiddler="HelloThere"/>
Go to Control Panel "Appearance" tab
Delete "HelloThere"
</$button>'/>