mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-29 03:20:27 +00:00
Extend the fieldlist widget to retrieve all fields used across all tiddlers
This commit is contained in:
parent
9b7cee81f2
commit
0bda00ae71
@ -22,6 +22,7 @@ var FieldListWidget = function(renderer) {
|
||||
FieldListWidget.prototype.generate = function() {
|
||||
var self = this;
|
||||
// Get parameters from our attributes
|
||||
this.allTiddlers = this.renderer.hasAttribute("all");
|
||||
this.tiddlerTitle = this.renderer.getAttribute("tiddler",this.renderer.tiddlerTitle);
|
||||
this.exclude = this.renderer.getAttribute("exclude");
|
||||
// Get the exclusion list
|
||||
@ -85,7 +86,11 @@ FieldListWidget.prototype.removeListElement = function(index) {
|
||||
FieldListWidget.prototype.getFieldList = function() {
|
||||
var tiddler = this.renderer.renderTree.wiki.getTiddler(this.tiddlerTitle),
|
||||
fieldList = [];
|
||||
if(tiddler) {
|
||||
// If requested, return all fields used on all tiddlers
|
||||
if(this.allTiddlers) {
|
||||
fieldList = this.renderer.renderTree.wiki.getAllTiddlerFields();
|
||||
} else if(tiddler) {
|
||||
// Return the fields on the specified tiddler
|
||||
for(var fieldName in tiddler.fields) {
|
||||
if(this.excludeList.indexOf(fieldName) === -1) {
|
||||
fieldList.push(fieldName);
|
||||
|
@ -307,6 +307,17 @@ exports.forEachTiddler = function(/* [sortField,[excludeTag,]]callback */) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.getAllTiddlerFields = function() {
|
||||
var results = [];
|
||||
for(var title in this.tiddlers) {
|
||||
$tw.utils.each(this.tiddlers[title].fields,function(field,fieldName) {
|
||||
$tw.utils.pushTop(results,fieldName);
|
||||
});
|
||||
}
|
||||
results.sort();
|
||||
return results;
|
||||
};
|
||||
|
||||
/*
|
||||
Return an array of tiddler titles that are directly linked from the specified tiddler
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user