mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-01 08:20:46 +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() {
|
FieldListWidget.prototype.generate = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
// Get parameters from our attributes
|
// Get parameters from our attributes
|
||||||
|
this.allTiddlers = this.renderer.hasAttribute("all");
|
||||||
this.tiddlerTitle = this.renderer.getAttribute("tiddler",this.renderer.tiddlerTitle);
|
this.tiddlerTitle = this.renderer.getAttribute("tiddler",this.renderer.tiddlerTitle);
|
||||||
this.exclude = this.renderer.getAttribute("exclude");
|
this.exclude = this.renderer.getAttribute("exclude");
|
||||||
// Get the exclusion list
|
// Get the exclusion list
|
||||||
@ -85,7 +86,11 @@ FieldListWidget.prototype.removeListElement = function(index) {
|
|||||||
FieldListWidget.prototype.getFieldList = function() {
|
FieldListWidget.prototype.getFieldList = function() {
|
||||||
var tiddler = this.renderer.renderTree.wiki.getTiddler(this.tiddlerTitle),
|
var tiddler = this.renderer.renderTree.wiki.getTiddler(this.tiddlerTitle),
|
||||||
fieldList = [];
|
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) {
|
for(var fieldName in tiddler.fields) {
|
||||||
if(this.excludeList.indexOf(fieldName) === -1) {
|
if(this.excludeList.indexOf(fieldName) === -1) {
|
||||||
fieldList.push(fieldName);
|
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
|
Return an array of tiddler titles that are directly linked from the specified tiddler
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user