tags:
title: $:/plugins/bimlas/locator/macros/filters
type: text/vnd.tiddlywiki

\define filter-history() [<__baseTitle__>] [title<contextState>each:list-item[history]] -[[]]
\define filter-selected-field-values() [title<intersectionState>] [title<differenceState>] +[locator-selected-field-values<currentField>]
\define filter-field-is-list() [addprefix[$:/config/bimlas/locator/fields/]field:field-type[list]]
\define filter-unfiltered-view-context-items() [subfilter<filter-history>last[]locator-enlist-children:$(currentField)$<contextState>!has[draft.of]]
\define filter-view-context() [subfilter<filter-history>last[]locator-enlist-children:$(currentField)$<contextState>!has[draft.of]locator-fields-filter<intersectionState>!locator-fields-filter<differenceState>]
\define filter-search-context() [!is[system]locator-fields-filter:recursive[$(intersectionState)$]!locator-fields-filter:recursive[$(differenceState)$]]
\define filter-field-of-relationship() [title<contextState>get[field-of-relationship]] [<defaultFieldOfRelationship>] +[first[]]

<!--
 I know that `filter-view-context` uses a code duplication of
 `filter-unfiltered-view-context-items`, but I have to do this way, becuse
  $(variable)$ works only with variables defined in direct parent macro, thus
  I cannot add another level to call chain
-->