Extend list filter operator to take a text reference

Instead of just a title. Means that we can apply the list operator to
fields other than the list field.
This commit is contained in:
Jermolene 2014-01-25 18:14:30 +00:00
parent e6843aabff
commit 0b3efe179e
2 changed files with 9 additions and 4 deletions

View File

@ -17,7 +17,8 @@ Export our filter function
*/
exports.list = function(source,operator,options) {
var results = [],
list = options.wiki.getTiddlerList(operator.operand);
tr = $tw.utils.parseTextReference(operator.operand),
list = $tw.wiki.getTiddlerList(tr.title,tr.field,tr.index);
function checkTiddler(title) {
var match = list.indexOf(title) !== -1;
if(operator.prefix === "!") {

View File

@ -611,10 +611,14 @@ exports.setTiddlerData = function(title,data) {
/*
Return the content of a tiddler as an array containing each line
*/
exports.getTiddlerList = function(title) {
exports.getTiddlerList = function(title,field,index) {
if(index) {
return $tw.utils.parseStringArray(this.extractTiddlerDataItem(title,index,""));
}
field = field || "list";
var tiddler = this.getTiddler(title);
if(tiddler && $tw.utils.isArray(tiddler.fields.list)) {
return tiddler.fields.list.slice(0);
if(tiddler) {
return ($tw.utils.parseStringArray(tiddler.fields[field]) || []).slice(0);
}
return [];
};