mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-12 12:55:43 +00:00
Tag picker rewritten using new v5.3.x syntax (#7978)
* tag-picker add Examples * tag-picker - use new v5.3.x wikitext syntax * tag-picker - more inline docs * tag-picker - fix add button * rename local functions: tag, userInput to _tf.getTag and _tf.getUersName to make the code and variable scopes more understandable * tag-picker - move local variables definitions into one place: tag-picker macro * tag-picker - replace reveal-widget with conditional IF syntax * tag-picker - remove logs and test tag-picker - actions parameer -> OK * tag-picker - add tag-picker Macro docs * tag-picker docs - change \define -> \procedure * tag-picker -- fix problem with focus loss if elements selected by mouse click * tag-picker -- add tf. prefix only to new function definition names for backwards compatibility. * tag-picker -- update example docs * re-add tags: $:/tags/Macro
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
caption: tag-picker
|
||||
created: 20161128191316701
|
||||
modified: 20161128191435641
|
||||
modified: 20230616114543787
|
||||
tags: Macros [[Core Macros]]
|
||||
title: tag-picker Macro
|
||||
type: text/vnd.tiddlywiki
|
||||
@@ -9,9 +9,17 @@ The <<.def tag-picker>> [[macro|Macros]] generates a combination of a text box a
|
||||
|
||||
!! Parameters
|
||||
|
||||
;actions
|
||||
: Action widgets to be triggered when the pill is clicked. Within the text, the variable ''tag'' contains the title of the selected tag.
|
||||
;tagField
|
||||
: <<.from-version 5.1.23>> The ''field'' that gets updated with the selected tag. Defaults to ''tags''.
|
||||
; actions
|
||||
: Action widgets to be triggered when the pill is clicked. Within the text, the variable <<.var tag>> contains the title of the selected tag.
|
||||
|
||||
; tagField
|
||||
: <<.from-version 5.1.23>> The specified ''field'' that gets updated with the selected tag. Defaults to `tags`.
|
||||
|
||||
; tiddler
|
||||
: <<.from-version 5.3.4>> Defines the target tiddler, which should be manipulated. Defaults to: <<.var currentTiddler>>.
|
||||
|
||||
; tagListFilter
|
||||
: <<.from-version 5.3.4>> This parameter defaults to: `[tags[]]` which creates a list of all existing tags. If the tag list should come from a different source the filter should look similar to eg: `[<listSource>get[field-name]enlist-input[]]`.
|
||||
|
||||
|
||||
<<.macro-examples "tag-picker">>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
created: 20230616104546608
|
||||
modified: 20240214174032498
|
||||
tags: [[tag-picker Macro]] [[Macro Examples]]
|
||||
title: tag-picker Macro (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.warning """The first example will set the tag of the <<.tid currentTiddler>> so you should copy / paste it to a new tiddler for testing. Otherwise you'll change "this tiddler" """>>
|
||||
|
||||
<$macrocall $name=".example" n="1"
|
||||
eg="""Use all existing tags and set the ''tags'' field here: <<tag-picker>>
|
||||
"""/>
|
||||
|
||||
----
|
||||
|
||||
<$let transclusion=test>
|
||||
|
||||
<<.tip """The following examples use a temporary tiddler: $:/temp/test/tag-picker. So this tiddler will not be changed """>>
|
||||
|
||||
|
||||
<$macrocall $name=".example" n="2"
|
||||
eg="""$:/temp/test/tag-picker ''tags'': <$text text={{{ [[$:/temp/test/tag-picker]get[tags]enlist-input[]join[, ]else[n/a]] }}}/>
|
||||
|
||||
Use all existing tags and set the $:/temp/test/tag-picker ''tags'' field: <<tag-picker tiddler:"$:/temp/test/tag-picker">>
|
||||
"""/>
|
||||
|
||||
----
|
||||
|
||||
<<.tip """Use the following example to populate the $:/temp/test/tag-picker ''foo''-field, which are needed by some examples below """>>
|
||||
|
||||
<$macrocall $name=".example" n="3"
|
||||
eg="""$:/temp/test/tag-picker ''foo'': <$text text={{{ [[$:/temp/test/tag-picker]get[foo]enlist-input[]join[, ]else[n/a]] }}}/>
|
||||
|
||||
Use all existing tags and set the $:/temp/test/tag-picker ''foo'' field: <<tag-picker tagField:"foo" tiddler:"$:/temp/test/tag-picker">>
|
||||
"""/>
|
||||
|
||||
----
|
||||
|
||||
<<.tip """The following example expects some values in the "foo" field of the tiddler $:/temp/test/tag-picker, which can be created by the example above.""">>
|
||||
|
||||
<$macrocall $name=".example" n="4" eg="""\procedure listSource() $:/temp/test/tag-picker
|
||||
|
||||
$:/temp/test/tag-picker foo: <$text text={{{ [[$:/temp/test/tag-picker]get[foo]enlist-input[]join[, ]else[n/a]] }}}/><br>
|
||||
$:/temp/test/tag-picker bar: <$text text={{{ [[$:/temp/test/tag-picker]get[bar]enlist-input[]join[, ]else[n/a]] }}}/>
|
||||
|
||||
Use $:/temp/test/tag-picker ''foo'' field as source and set ''bar'': <<tag-picker tagField:"bar" tagListFilter:"[<listSource>get[foo]enlist-input[]]" tiddler:"$:/temp/test/tag-picker">>
|
||||
"""/>
|
||||
|
||||
----
|
||||
|
||||
<<.tip """The following example expects some values in the "foo" field of the tiddler $:/temp/test/tag-picker, which can be created by the example above.<br>
|
||||
It will also add completely new tags to the bar-field and the source tiddlers foo-field. New tags can be entered by typing into the tag-name input
|
||||
""">>
|
||||
|
||||
<$macrocall $name=".example" n="5" eg="""
|
||||
\procedure listSource() $:/temp/test/tag-picker
|
||||
\procedure listSourceField() foo
|
||||
|
||||
\procedure addNewTagToSource()
|
||||
<$action-listops $tiddler=<<listSource>> $field=<<listSourceField>> $subfilter='[<listSource>get<listSourceField>enlist-input[]] [<tag>trim[]]'/>
|
||||
\end
|
||||
|
||||
$:/temp/test/tag-picker foo: <$text text={{{ [[$:/temp/test/tag-picker]get[foo]enlist-input[]join[, ]else[n/a]] }}}/><br>
|
||||
$:/temp/test/tag-picker ''bar'': <$text text={{{ [[$:/temp/test/tag-picker]get[bar]enlist-input[]join[, ]else[n/a]] }}}/>
|
||||
|
||||
Use $:/temp/test/tag-picker ''foo'' field as source and set ''bar'': <$macrocall $name="tag-picker" tagField="bar" tagListFilter="[<listSource>get<listSourceField>enlist-input[]]" tiddler="$:/temp/test/tag-picker" actions=<<addNewTagToSource>>/>
|
||||
|
||||
"""/>
|
||||
|
||||
</$let>
|
||||
Reference in New Issue
Block a user