1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Add has:index (#4540)

* has:index

* has:index

* has:index docs

* has op examples

* has op examples

* operator macros typo missing </div>

* possible mistake
This commit is contained in:
Joshua Fontany 2020-04-14 08:52:56 -07:00 committed by GitHub
parent dc82365956
commit 69c8058b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View File

@ -3,7 +3,7 @@ title: $:/core/modules/filters/has.js
type: application/javascript
module-type: filteroperator
Filter operator for checking if a tiddler has the specified field
Filter operator for checking if a tiddler has the specified field or index
\*/
(function(){
@ -33,7 +33,23 @@ exports.has = function(source,operator,options) {
}
});
}
} else {
}
else if(operator.suffix === "index") {
if(invert) {
source(function(tiddler,title) {
if(!tiddler || (tiddler && (!$tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)))) {
results.push(title);
}
});
} else {
source(function(tiddler,title) {
if(tiddler && $tw.utils.hop($tw.wiki.getTiddlerDataCached(tiddler,Object.create(null)),operator.operand)) {
results.push(title);
}
});
}
}
else {
if(invert) {
source(function(tiddler,title) {
if(!tiddler || !$tw.utils.hop(tiddler.fields,operator.operand) || (tiddler.fields[operator.operand] === "")) {

View File

@ -8,4 +8,6 @@ type: text/vnd.tiddlywiki
<<.operator-example 1 "[has[color]]">>
<<.operator-example 2 "[tag[Concepts]!has[modified]]">>
<<.operator-example 3 "[has:field[emptyfield]]">>
<<.operator-example 4 "[all[current]!has:field[doesntexist]]">>
<<.operator-example 4 "[all[current]!has:field[doesntexist]]">>
<<.operator-example 5 "[all[tiddlers+shadows]has:index[foreground]]">>
<<.operator-example 6 "[all[current]!has:index[doesntexist]]">>

View File

@ -2,12 +2,13 @@ caption: has
created: 20140410103123179
modified: 20190518145446047
op-input: a [[selection of titles|Title Selection]]
op-neg-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist
op-neg-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> does <<.em not>> exist<br>''suffix `index`''<br>&raquo; those input tiddlers in which index <<.place F>> does <<.em not>> exist
op-output: ''without suffix''<br>&raquo; those input tiddlers in which field <<.place F>> has a non-empty value<br>''suffix `field`''<br>&raquo; those input tiddlers in which field <<.place F>> exists
op-parameter: the name of a [[field|TiddlerFields]]
op-parameter: the name of a [[field|TiddlerFields]]<br>''suffix `index`''<br>&raquo; those input tiddlers in which index <<.place F>> exists
op-parameter: the name of a [[field|TiddlerFields]] or, optionally an [[index|TextReference]]
op-parameter-name: F
op-purpose: filter the input by field existence
op-suffix: <<.from-version "5.1.14">> optionally, the keyword `field`
op-suffix: <<.from-version "5.1.14">> optionally, the keyword `field` or <<.from-version "5.1.22">> optionally, the keyword `index`
op-suffix-name: S
tags: [[Filter Operators]] [[Common Operators]] [[Field Operators]] [[Negatable Operators]]
title: has Operator