mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-15 06:14:53 +00:00
eb9fb6635d
There were several places where tiddlers were being written without the creation/modification details being updated. See https://groups.google.com/d/msgid/tiddlywiki/17ef8ab0-0128-4467-8a9d-f17 bdbcf3618%40googlegroups.com
78 lines
1.9 KiB
JavaScript
78 lines
1.9 KiB
JavaScript
/*\
|
|
title: $:/core/modules/widgets/action-deletefield.js
|
|
type: application/javascript
|
|
module-type: widget
|
|
|
|
Action widget to delete fields of a tiddler.
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
|
|
|
var DeleteFieldWidget = function(parseTreeNode,options) {
|
|
this.initialise(parseTreeNode,options);
|
|
};
|
|
|
|
/*
|
|
Inherit from the base widget class
|
|
*/
|
|
DeleteFieldWidget.prototype = new Widget();
|
|
|
|
/*
|
|
Render this widget into the DOM
|
|
*/
|
|
DeleteFieldWidget.prototype.render = function(parent,nextSibling) {
|
|
this.computeAttributes();
|
|
this.execute();
|
|
};
|
|
|
|
/*
|
|
Compute the internal state of the widget
|
|
*/
|
|
DeleteFieldWidget.prototype.execute = function() {
|
|
this.actionTiddler = this.getAttribute("$tiddler",this.getVariable("currentTiddler"));
|
|
this.actionField = this.getAttribute("$field");
|
|
};
|
|
|
|
/*
|
|
Refresh the widget by ensuring our attributes are up to date
|
|
*/
|
|
DeleteFieldWidget.prototype.refresh = function(changedTiddlers) {
|
|
var changedAttributes = this.computeAttributes();
|
|
if(changedAttributes["$tiddler"]) {
|
|
this.refreshSelf();
|
|
return true;
|
|
}
|
|
return this.refreshChildren(changedTiddlers);
|
|
};
|
|
|
|
/*
|
|
Invoke the action associated with this widget
|
|
*/
|
|
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") {
|
|
removeFields[name] = undefined;
|
|
}
|
|
});
|
|
this.wiki.addTiddler(new $tw.Tiddler(this.wiki.getModificationFields(),tiddler,removeFields,this.wiki.getCreationFields()));
|
|
}
|
|
return true; // Action was invoked
|
|
};
|
|
|
|
exports["action-deletefield"] = DeleteFieldWidget;
|
|
|
|
})();
|