1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-09 23:50:01 +00:00

allow radio-widget and checkbox-widget to be used for type-filter input

This commit is contained in:
pmario 2024-04-29 14:56:46 +02:00
parent 0da81d616d
commit 3dba698458

View File

@ -4,7 +4,7 @@ tags: $:/tags/Global
\whitespace trim \whitespace trim
<!-- CONST string definitions --> <!-- CONST string definitions -->
\procedure DV-VAR-FILTER-OPTIONS() fn var proc macro widget \procedure DV-VAR-FILTER-OPTIONS() all fn var proc macro widget
\procedure DV-FILTER-OPTIONS() $:/temp/varSearch/options \procedure DV-FILTER-OPTIONS() $:/temp/varSearch/options
\procedure DV-SORT-OPTIONS() $:/temp/varSearch/sort \procedure DV-SORT-OPTIONS() $:/temp/varSearch/sort
@ -16,22 +16,24 @@ tags: $:/tags/Global
\procedure DV-FOLDED() $:/temp/varFolded \procedure DV-FOLDED() $:/temp/varFolded
\procedure DV-SEARCH() $:/temp/varSearch \procedure DV-SEARCH() $:/temp/varSearch
\procedure DV-SEARCH-DETAILS() $:/temp/varSearch/details \procedure DV-SEARCH-DETAILS() $:/temp/varSearch/details
\procedure DV-SEARCH-STATE() $:/state/varSearch \procedure DV-SEARCH-STATE() $:/state/varSearch/name
\procedure DV-EXCLUDE() $:/state/varExclude \procedure DV-EXCLUDE() $:/state/varExclude
\procedure DV-TYPE-STATE() $:/state/typeState
<!-- Construct filter strings --> <!-- Construct filter strings -->
\function tf.dv-filterString() [<_tf.dv-sort>match[raw]then<DV-RAW-FILTER-STR>else<DV-FILTER-STR>] \function tf.dv-filterString() [<_tf.dv-sort>match[raw]then<DV-RAW-FILTER-STR>else<DV-FILTER-STR>]
\function tf.dv-formattedVar() [<varname>format:variable<_tf.dv-varFormat>] \function tf.dv-formattedVar() [<varname>format:variable<_tf.dv-varFormatStr>]
\function tf.dv-foldedState() [<DV-FOLDED>] [<qualify>] +[join[/]] \function tf.dv-foldedState() [<DV-FOLDED>] [<qualify>] +[join[/]]
<!-- =================== --> <!-- ============================ -->
<!-- dumpvariables main --> <!-- dumpvariables main procedure -->
<!-- =================== --> <!-- ============================ -->
\procedure dumpvariables(type sort subfilter:"[[]]" format) \procedure dumpvariables(type sort subfilter:"[[]]" format)
<!-- The following function is needed since the "format" string can contain closing brackets ")" --> <!-- The following function is needed since the "format" string can contain closing brackets ")" -->
\function _tf.dv-varFormat() [<format>!is[blank]then<format>else[$type$ $name$($params$)]] <!-- Be aware that the "format" filter operator uses $var-name$ for compatibility reasons -->
\function _tf.dv-varFormatStr() [<format>!is[blank]then<format>else[$type$ $name$($params$)]]
\function _tf.dv-type() [<type>] \function _tf.dv-type() [<type>]
\function _tf.dv-sort() [<sort>] \function _tf.dv-sort() [<sort>]
<ul> <ul>
@ -57,9 +59,12 @@ tags: $:/tags/Global
text={{{ [<tf.dv-toggleInfoState>get[text]] +[toggle[yes],[no]] }}} text={{{ [<tf.dv-toggleInfoState>get[text]] +[toggle[yes],[no]] }}}
/> />
<!-- Existing user modified "search text details" should be preserved. If empty use default formatted signature --> <!-- Existing user modified "search text details" should be preserved. If empty use default formatted signature -->
<!-- Be aware that the "format" filter operator uses $var-name$ for compatibility reasons -->
<$action-setfield $tiddler=<<tf.dv-detailsSearch>> <$action-setfield $tiddler=<<tf.dv-detailsSearch>>
text={{{ [<tf.dv-getDetailsSearchText>!is[blank]then<tf.dv-getDetailsSearchText>] :else[<varname>format:variable[$type$ $name$($params$)]] }}} text={{{ [<tf.dv-getDetailsSearchText>!is[blank]then<tf.dv-getDetailsSearchText>] :else[<varname>format:variable[$type$ $name$($params$)]] }}}
/> >
<$action-log $$filter="[prefix[tf.]]"/>
</$action-setfield>
\end \end
\procedure dv-clearStatesButton() \procedure dv-clearStatesButton()
@ -90,8 +95,8 @@ tags: $:/tags/Global
\end \end
\procedure dv-expandAllStatesButton() \procedure dv-expandAllStatesButton()
<span class="tc-small-gap">{{$:/language/Search/Variables/ExpandAll}}</span> <span class="tc-tiny-gap">{{$:/language/Search/Variables/ExpandAll}}</span>
<$button class="tc-btn-invisible tc-tiny-gap-left"> <$button class="tc-btn-invisible">
<$action-setfield $tiddler=<<DV-SEARCH-STATE>> <$action-setfield $tiddler=<<DV-SEARCH-STATE>>
text={{{ [<tf.dv-toggleInfoState>get[text]] +[toggle[yes],[no]] }}} text={{{ [<tf.dv-toggleInfoState>get[text]] +[toggle[yes],[no]] }}}
/> />
@ -122,7 +127,7 @@ tags: $:/tags/Global
</div> </div>
\end \end
\procedure dv-filterOptions() <!-- \procedure dv-filterOptions()
<style> <style>
.tc-dv-filterOptions [data-gap="right"] { .tc-dv-filterOptions [data-gap="right"] {
width: auto; width: auto;
@ -149,7 +154,7 @@ tags: $:/tags/Global
<option value="raw">raw</option> <option value="raw">raw</option>
</$select> </$select>
</span> </span>
\end \end -->
\function tf.dv-tmpTypeOptions() [<DV-FILTER-OPTIONS>] [<qualify>] +[join[/]] \function tf.dv-tmpTypeOptions() [<DV-FILTER-OPTIONS>] [<qualify>] +[join[/]]
\function tf.dv-tmpSortOptions() [<DV-SORT-OPTIONS>] [<qualify>] +[join[/]] \function tf.dv-tmpSortOptions() [<DV-SORT-OPTIONS>] [<qualify>] +[join[/]]
@ -166,13 +171,14 @@ tags: $:/tags/Global
\function tf.dv-varState() [<DV-SEARCH-STATE>] [<varname>] [<qualify>] +[join[/]] \function tf.dv-varState() [<DV-SEARCH-STATE>] [<varname>] [<qualify>] +[join[/]]
\function tf.dv-toggleInfoState() [<DV-SEARCH-STATE>] [<varname>] +[join[/]] \function tf.dv-toggleInfoState() [<DV-SEARCH-STATE>] [<varname>] +[join[/]]
<!-- ============================== --> <!-- =============================== -->
<!-- search-variables main function --> <!-- search-variables main procedure -->
<!-- ============================== --> <!-- =============================== -->
\procedure search-variables(type sort subfilter:"[[]]" format) \procedure search-variables(type sort subfilter:"[[]]" format)
<!-- The following function is needed since the "format" string can contain closing brackets ")" --> <!-- The following function is needed since the "format" string can contain closing brackets ")" -->
\function _tf.dv-varFormat() [<format>!is[blank]then<format>else[$type$ $name$($params$)]] <!-- Be aware that the "format" filter operator uses $var-name$ for compatibility reasons -->
\function _tf.dv-varFormatStr() [<format>!is[blank]then<format>else[$type$ $name$($params$)]]
\function _tf.dv-type() [<type>!is[blank]then<type>] :else[<tf.dv-tmpTypeOptions>get[text]] \function _tf.dv-type() [<type>!is[blank]then<type>] :else[<tf.dv-tmpTypeOptions>get[text]]
\function _tf.dv-sort() [<sort>!is[blank]then<sort>] :else[<tf.dv-tmpSortOptions>get[text]] :else[[alphabetical]] \function _tf.dv-sort() [<sort>!is[blank]then<sort>] :else[<tf.dv-tmpSortOptions>get[text]] :else[[alphabetical]]
@ -193,6 +199,7 @@ tags: $:/tags/Global
<% endif %> <% endif %>
<code class="tc-small-gap-right"><$text text=<<tf.dv-formattedVar>>/></code> <code class="tc-small-gap-right"><$text text=<<tf.dv-formattedVar>>/></code>
<% if [<tf.dv-formattedVar>prefix[\function]] %> <% if [<tf.dv-formattedVar>prefix[\function]] %>
<!-- Be aware that the "format" filter operator uses $var-name$ for compatibility reasons -->
<span class="tc-tiny-gap-right"><$text text={{{ [<varname>format:variable[$firstLine$]] }}}/></span> <span class="tc-tiny-gap-right"><$text text={{{ [<varname>format:variable[$firstLine$]] }}}/></span>
<% endif %> <% endif %>
</$button> </$button>
@ -226,6 +233,7 @@ tags: $:/tags/Global
<!-- ================================== --> <!-- ================================== -->
<!-- Grid Based Advanced Variables Form --> <!-- Grid Based Advanced Variables Form -->
<!-- ================================== -->
\procedure dv-search-input-box() \procedure dv-search-input-box()
<%if [<sort>!is[blank]] %> <%if [<sort>!is[blank]] %>
@ -238,7 +246,7 @@ tags: $:/tags/Global
<$edit-text tiddler=<<tf.dv-searchText>> <$edit-text tiddler=<<tf.dv-searchText>>
tag=input tag=input
class="txt-input x-inp" class="txt-input x-inp"
placeholder="filter variables by name" placeholder={{$:/language/Search/Variables/Filter/Hint}}
/> />
<<dv-clearSearchButton>> <<dv-clearSearchButton>>
\end \end
@ -248,6 +256,7 @@ tags: $:/tags/Global
<$edit-text tiddler=<<tf.dv-excludeText>> <$edit-text tiddler=<<tf.dv-excludeText>>
tag=input tag=input
class="txt-input y-inp" class="txt-input y-inp"
placeholder={{$:/language/Search/Variables/Exclude/Hint}}
/> />
<<moreVariablesPopup>> <<moreVariablesPopup>>
<% if [<tf.dv-getExcludeText>!is[blank]] %> <% if [<tf.dv-getExcludeText>!is[blank]] %>
@ -266,11 +275,26 @@ tags: $:/tags/Global
</style> </style>
<span class="t-txt">{{$:/language/Search/Variables/Option/Type}}</span> <span class="t-txt">{{$:/language/Search/Variables/Option/Type}}</span>
<$list filter="[enlist<DV-VAR-FILTER-OPTIONS>]" variable="option"> <$list filter="[enlist<DV-VAR-FILTER-OPTIONS>]" variable="option">
<$checkbox tiddler=<<tf.dv-tmpTypeOptions>> listField="text" checked=<<option>> <%if [<DV-TYPE-STATE>get[text]match[checkbox]] %>
class=<<tf.dv-opt-class>> data-gap="right" <$checkbox tiddler=<<tf.dv-tmpTypeOptions>>
> listField="text"
<<option>> checked=<<option>>
</$checkbox> default="all"
class=<<tf.dv-opt-class>>
data-gap="right"
>
<<option>>
</$checkbox>
<% else %>
<$radio tiddler=<<tf.dv-tmpTypeOptions>>
listField="text" value=<<option>>
default="all"
class=<<tf.dv-opt-class>>
data-gap="right"
>
<<option>>
</$radio>
<% endif %>
</$list> </$list>
\end \end
@ -297,6 +321,9 @@ tags: $:/tags/Global
</span> </span>
\end \end
<!-- ========================================== -->
<!-- Main -- Grid Based Advanced Variables Form -->
<!-- ========================================== -->
\procedure dv-searchForm() \procedure dv-searchForm()
<div class="tc-flexible-form"> <div class="tc-flexible-form">
<div class="tc-flexible-checkbox-container"> <div class="tc-flexible-checkbox-container">
@ -305,7 +332,7 @@ tags: $:/tags/Global
<div class="tc-flexible-input-container"> <div class="tc-flexible-input-container">
<$reveal stateTitle=<<tf.dv-foldedState>> <$reveal stateTitle=<<tf.dv-foldedState>>
tag="div" tag="div"
class="btn-fld" class=`btn-fld ${[<tf.dv-getExcludeText>!is[blank]then[btn-fld-has-exluded]]}$`
type="nomatch" type="nomatch"
text="show" text="show"
default="hide" default="hide"
@ -317,10 +344,11 @@ tags: $:/tags/Global
</$reveal> </$reveal>
<$reveal stateTitle=<<tf.dv-foldedState>> <$reveal stateTitle=<<tf.dv-foldedState>>
tag="div" tag="div"
class="btn-fld" class=`btn-fld ${[<tf.dv-getExcludeText>!is[blank]then[btn-fld-has-exluded]]}$`
type="nomatch" type="nomatch"
text="hide" text="hide"
default="hide" default="hide"
style="align-self: center;"
> >
<$button tooltip={{$:/language/Search/Variables/Exclude/Hide}} class="tc-dv-btn tc-btn-invisible"> <$button tooltip={{$:/language/Search/Variables/Exclude/Hide}} class="tc-dv-btn tc-btn-invisible">
<$action-setfield $tiddler=<<tf.dv-foldedState>> $field=text $value="hide"/> <$action-setfield $tiddler=<<tf.dv-foldedState>> $field=text $value="hide"/>
@ -351,7 +379,7 @@ tags: $:/tags/Global
<$action-setfield $tiddler=<<tf.dv-excludeText>> text=<<navigateTo>>/> <$action-setfield $tiddler=<<tf.dv-excludeText>> text=<<navigateTo>>/>
\end \end
\procedure addVariableFilter() \procedure dv-addNewVariableFilter-actions()
<$action-sendmessage <$action-sendmessage
$message="tm-new-tiddler" $message="tm-new-tiddler"
tags="$:/tags/Variables/Exclude/Snippet" tags="$:/tags/Variables/Exclude/Snippet"
@ -364,8 +392,8 @@ tags: $:/tags/Global
/> />
\end \end
\procedure addNewVariableFilter() \procedure dv-addNewVariableFilter()
<$button tag="a" actions=<<addVariableFilter>> class="tc-tiddlylink"> <$button tag="a" actions=<<dv-addNewVariableFilter-actions>> class="tc-tiddlylink">
<em> <em>
<$text text={{$:/language/Search/Variables/Exclude/Save}}/> <$text text={{$:/language/Search/Variables/Exclude/Save}}/>
</em> </em>
@ -395,7 +423,7 @@ tags: $:/tags/Global
</div> </div>
</$list> </$list>
<hr> <hr>
<<addNewVariableFilter>> <<dv-addNewVariableFilter>>
</div> </div>
</div> </div>
</$linkcatcher> </$linkcatcher>