mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-28 08:13:14 +00:00
added list suffix for each filter
implements #1369 when the suffix is `list`, interprets the field as a list of individual tiddler titles and returns all titles referenced in the list field of the source list, existing or not
This commit is contained in:
parent
8a763e9d83
commit
baca2703f1
|
@ -3,7 +3,8 @@ title: $:/core/modules/filters/each.js
|
||||||
type: application/javascript
|
type: application/javascript
|
||||||
module-type: filteroperator
|
module-type: filteroperator
|
||||||
|
|
||||||
Filter operator that selects one tiddler for each unique value of the specified field
|
Filter operator that selects one tiddler for each unique value of the specified field.
|
||||||
|
With suffix "list", selects all tiddlers that are values in a specified list field.
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
(function(){
|
(function(){
|
||||||
|
@ -17,19 +18,23 @@ Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.each = function(source,operator,options) {
|
exports.each = function(source,operator,options) {
|
||||||
var results = [],
|
var results = [],
|
||||||
values = {};
|
values = {},
|
||||||
|
list = "list" === operator.suffix;
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
var value;
|
var value,
|
||||||
if((operator.operand === "") || (operator.operand === "title")) {
|
field = operator.operand || "title";
|
||||||
value = title;
|
$tw.utils.each(
|
||||||
} else {
|
list ?
|
||||||
value = tiddler.getFieldString(operator.operand);
|
options.wiki.getTiddlerList(title,field) :
|
||||||
}
|
[ "title" === field ? title : tiddler.getFieldString(operator.operand)],
|
||||||
if(!$tw.utils.hop(values,value)) {
|
function(value){
|
||||||
values[value] = true;
|
if(!$tw.utils.hop(values,value)) {
|
||||||
results.push(title);
|
values[value] = true;
|
||||||
}
|
results.push(list ? value : title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user