mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-22 14:00:03 +00:00
Extend listed filter operator to use any field
This commit is contained in:
parent
f54f0d1c3e
commit
4238af2a40
@ -16,9 +16,10 @@ Filter operator returning all tiddlers that have the selected tiddlers in a list
|
|||||||
Export our filter function
|
Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.listed = function(source,operator,options) {
|
exports.listed = function(source,operator,options) {
|
||||||
var results = [];
|
var field = operator.operand || "list",
|
||||||
|
results = [];
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
$tw.utils.pushTop(results,options.wiki.findListingsOfTiddler(title));
|
$tw.utils.pushTop(results,options.wiki.findListingsOfTiddler(title,field));
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
@ -480,13 +480,14 @@ exports.getTagMap = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Lookup a given tiddler and return a list of all the tiddlers that include it in their list
|
Lookup a given tiddler and return a list of all the tiddlers that include it in the specified list field
|
||||||
*/
|
*/
|
||||||
exports.findListingsOfTiddler = function(targetTitle) {
|
exports.findListingsOfTiddler = function(targetTitle,fieldName) {
|
||||||
// Get the list associated with the tag
|
fieldName = fieldName || "list";
|
||||||
var titles = [];
|
var titles = [];
|
||||||
this.each(function(tiddler,title) {
|
this.each(function(tiddler,title) {
|
||||||
if($tw.utils.isArray(tiddler.fields.list) && tiddler.fields.list.indexOf(targetTitle) !== -1) {
|
var list = $tw.utils.parseStringArray(tiddler.fields[fieldName]);
|
||||||
|
if(list && list.indexOf(targetTitle) !== -1) {
|
||||||
titles.push(title);
|
titles.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,7 @@ See [[Notes for upgrading to 5.0.13-beta]] for more details of these changes:
|
|||||||
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/d2796d0c9c7ed7a971ae6b0752d7418384072bb5]] new SetFieldCommand
|
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/d2796d0c9c7ed7a971ae6b0752d7418384072bb5]] new SetFieldCommand
|
||||||
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/305617b632fd6ecf25cd4be85f4dfb5a5a65dfef]] new SaveTiddlersCommand
|
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/305617b632fd6ecf25cd4be85f4dfb5a5a65dfef]] new SaveTiddlersCommand
|
||||||
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/f14ecf4eb8965f2e407ccac51d4277330221efe3]] support for system tag [[$:/tags/RawMarkup]]
|
* [[Added|https://github.com/Jermolene/TiddlyWiki5/commit/f14ecf4eb8965f2e407ccac51d4277330221efe3]] support for system tag [[$:/tags/RawMarkup]]
|
||||||
|
* Extended [[FilterOperator: listed]] to work with any list field
|
||||||
|
|
||||||
!! Bug Fixes
|
!! Bug Fixes
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
created: 20140410103123179
|
created: 20140410103123179
|
||||||
modified: 20140410103123179
|
modified: 20140613103123179
|
||||||
tags: filters
|
tags: filters
|
||||||
title: FilterOperator: listed
|
title: FilterOperator: listed
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
The ''listed'' filter operator returns the titles of the tiddlers that have `list` fields that contain any members of the current list.
|
The ''listed'' filter operator returns the titles of the tiddlers that have `list` fields that contain any members of the current list. The optional operand can be used to specify a different field.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|!Filter String |!Description |
|
|!Filter String |!Description |
|
||||||
|`[[HelloThere]listed[]]` |Returns the titles of any tiddlers containing `HelloThere` in their `list` fields |
|
|`[[HelloThere]listed[]]` |Returns the titles of any tiddlers containing `HelloThere` in their `list` fields |
|
||||||
|`[all[current]listed[]]]` |Returns the titles of any tiddlers containing the current tiddler in their `list` fields |
|
|`[all[current]listed[my-special-list]]]` |Returns the titles of any tiddlers containing the current tiddler in their `my-special-list` fields |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user