1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-02 14:29:55 +00:00

Use the testcase widget for $action-createtiddler examples (#8232)

* Use the testcase widget for the $action-createtiddler widget examples

* Use procedure instead of macros for $action-createtiddler examples
This commit is contained in:
btheado 2024-09-10 06:49:04 -04:00 committed by GitHub
parent 3434884ea4
commit 6505e4610f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 65 additions and 131 deletions

View File

@ -1,26 +1,15 @@
created: 20200131142401129 created: 20200131142401129
modified: 20211113230406823 modified: 20240602154417754
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example 1 title: ActionCreateTiddlerWidget Example 1
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define testCreate() <$testcase>
<$action-createtiddler /> <$data title=Description text="Default widget with no attributes"/>
\end <$data title=Narrative text='The button in this example uses the $action-createtiddler widget to create "New Tiddler", "New Tiddler 1", " New Tiddler 2" and so on'/>
<$data title=Output text="""\procedure testCreate() <$action-createtiddler />
This example will create "New Tiddler", "New Tiddler 1", " New Tiddler 2" and so on
```
\define testCreate()
<$action-createtiddler />
\end
<$button actions=<<testCreate>> > <$button actions=<<testCreate>> >
Create Tiddler Create Tiddler
</$button> </$button>"""/>
``` </$testcase>
<$button actions=<<testCreate>> >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/core/ui/SideBar/Recent"/>
Create Tiddler
</$button> - Clicking this button, will also open the Right sidebar: Recent tab

View File

@ -1,28 +1,20 @@
created: 20200131144828713 created: 20200131144828713
modified: 20211113011036840 modified: 20240602160133371
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example 2 title: ActionCreateTiddlerWidget Example 2
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define testCreate() <$testcase>
<$action-createtiddler $basetitle={{$:/language/DefaultNewTiddlerTitle}} $overwrite="yes"/> <$data title=Description text="Transcluded base title"/>
\end <$data title=Narrative text="""The $action-createtiddler widget in this example uses the base title defined in [[$:/language/DefaultNewTiddlerTitle]].
This example will use the base title defined in [[$:/language/DefaultNewTiddlerTitle]]. It will overwrite the tiddler if the button is clicked several times."""/>
<$data $tiddler="$:/language/DefaultNewTiddlerTitle"/>
It will overwrite the tiddler, if the button is clicked several times. <$data title=Output text="""\procedure testCreate()
```
\define testCreate()
<$action-createtiddler $basetitle={{$:/language/DefaultNewTiddlerTitle}} $overwrite="yes"/> <$action-createtiddler $basetitle={{$:/language/DefaultNewTiddlerTitle}} $overwrite="yes"/>
\end \end
<$button actions=<<testCreate>> > <$button actions=<<testCreate>> >
Create Tiddler Create Tiddler
</$button> </$button>"""/>
``` </$testcase>
<$button actions=<<testCreate>> >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/core/ui/SideBar/Recent"/>
Create Tiddler
</$button> - Clicking this button, will also open the Right sidebar: Recent tab

View File

@ -1,28 +1,21 @@
created: 20200131145355658 created: 20200131145355658
modified: 20211113011111052 modified: 20240602155233116
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example 3 title: ActionCreateTiddlerWidget Example 3
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define testCreate() <$testcase>
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template"/> <$data title=Description text="Template and custom base title"/>
\end <$data title=Narrative text="""The $action-createtiddler widget in this example uses the basetitle attribute and template: [[ActionCreateTiddlerWidget Template]].
This example will uses a base-title and a template: [[ActionCreateTiddlerWidget Template]] Clicking the button will create: "base", "base 1", "base 2" and so on
"""/>
It will create: "base", "base 1", "base 2" and so on <$data $tiddler="ActionCreateTiddlerWidget Template"/>
<$data title=Output text="""\procedure testCreate()
```
\define testCreate()
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template"/> <$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template"/>
\end \end
<$button actions=<<testCreate>> > <$button actions=<<testCreate>> >
Create Tiddler Create Tiddler
</$button> </$button>"""/>
``` </$testcase>
<$button actions=<<testCreate>> >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/core/ui/SideBar/Recent"/>
Create Tiddler
</$button> - Clicking this button will also open the Right sidebar: Recent tab

View File

@ -1,28 +1,21 @@
created: 20200131150229551 created: 20200131150229551
modified: 20211113011129601 modified: 20240602154933113
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example 4 title: ActionCreateTiddlerWidget Example 4
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define testCreate() <$testcase>
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template" aa="new field aa" bb="new field bb" /> <$data title=Description text="Template with override fields and custom base title"/>
\end <$data title=Narrative text="""The $action-createtiddler widget in this example uses the basetitle attribute and template: [[ActionCreateTiddlerWidget Template]].
This example uses a base-title "base" and a template: [[ActionCreateTiddlerWidget Template]].
There will be new fields "aa" and "bb" which are added to the new tiddlers. There will be new fields "aa" and "bb" which are added to the new tiddlers.
"""/>
``` <$data $tiddler="ActionCreateTiddlerWidget Template"/>
\define testCreate() <$data title=Output text="""\procedure testCreate()
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template" aa="new field aa" bb="new field bb" /> <$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template" aa="new field aa" bb="new field bb" />
\end \end
<$button actions=<<testCreate>> > <$button actions=<<testCreate>> >
Create Tiddler Create Tiddler
</$button> </$button>"""/>
``` </$testcase>
<$button actions=<<testCreate>> >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/core/ui/SideBar/Recent"/>
Create Tiddler
</$button> - Clicking this button will also open the Right sidebar: Recent tab

View File

@ -1,32 +1,20 @@
created: 20200131144828713 created: 20200131144828713
modified: 20230111220933412 modified: 20240602155008453
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example 5 title: ActionCreateTiddlerWidget Example 5
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
\define testCreate() <$testcase>
<$data title=Description text="Child action widget uses the created tiddler title"/>
<$data title=Narrative text="""The $action-createtiddler widget in this example uses the <<.var createTiddler-title>> variable to navigate to the created tiddler"""/>
<$data $tiddler="ActionCreateTiddlerWidget Template"/>
<$data title=Output text="""\procedure testCreate()
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template"> <$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template">
<$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/> <$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
\end
This example will use the base title defined in [[ActionCreateTiddlerWidget Template]].
It will create: "base", "base 1", "base 2" and so on, and navigate to this tiddler in draft mode.
```
\define testCreate()
<$action-createtiddler $basetitle="base" $template="ActionCreateTiddlerWidget Template">
<$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/>
</$action-createtiddler> </$action-createtiddler>
\end \end
<$button actions=<<testCreate>> > <$button actions=<<testCreate>> >
Create Tiddler Create Tiddler
</$button> </$button>"""/>
``` </$testcase>
<$button actions=<<testCreate>> >
<$action-setfield $tiddler="$:/state/tab/sidebar--595412856" text="$:/core/ui/SideBar/Recent"/>
Create Tiddler
</$button> - Clicking this button, will also open the Right sidebar: Recent tab

View File

@ -1,6 +1,6 @@
caption: action-createtiddler caption: action-createtiddler
created: 20161020152745942 created: 20161020152745942
modified: 20230115084716196 modified: 20240602153213986
tags: Widgets ActionWidgets tags: Widgets ActionWidgets
title: ActionCreateTiddlerWidget title: ActionCreateTiddlerWidget
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -37,37 +37,6 @@ The ''action-createtiddler'' widget is invisible.
! Examples ! Examples
<<< <$list filter="[prefix[ActionCreateTiddlerWidget Example]]">
<$macrocall $name='wikitext-example-without-html' src={{ActionCreateTiddlerWidget Example}}/> <$transclude/>
<<< </$list>
---
<<<
<$transclude tiddler="ActionCreateTiddlerWidget Example 1" mode=block/>
<<<
---
<<<
{{ActionCreateTiddlerWidget Example 2}}
<<<
---
<<<
{{ActionCreateTiddlerWidget Example 3}}
<<<
---
<<<
{{ActionCreateTiddlerWidget Example 4}}
<<<
---
<<<
{{ActionCreateTiddlerWidget Example 5}}
<<<

View File

@ -1,14 +1,24 @@
created: 20161020153426686 created: 20161020153426686
modified: 20211113011019510 modified: 20240602160452171
tags: ActionCreateTiddlerWidget tags: ActionCreateTiddlerWidget
title: ActionCreateTiddlerWidget Example title: ActionCreateTiddlerWidget Example
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
<$testcase>
<$data title=Description text="Create a new page control button"/>
<$data title=Narrative text="""Use the $action-createtiddler widget to create and open a new, non-functional page control button tiddler"""/>
<$data title=Output text="""\procedure testCreate()
<$action-createtiddler $basetitle="Homemade Button" tags="$:/tags/PageControls" text={{$:/state/new-button-caption}}>
<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>
\end
{{$:/core/ui/SideBarSegments/page-controls}}
Caption for new button: <$edit-text tiddler="$:/state/new-button-caption" tag="input" default=""/> Caption for new button: <$edit-text tiddler="$:/state/new-button-caption" tag="input" default=""/>
<$button> <$button actions=<<testCreate>> >
<$action-createtiddler $basetitle="Homemade Button" tags="$:/tags/PageControls" text={{$:/state/new-button-caption}}> Create Tiddler
<$action-navigate $to=<<createTiddler-title>>/> </$button>"""/>
</$action-createtiddler> <$data title="$:/state/new-button-caption" text="button text "/>
Create a new non-functional page control button and open the tiddler </$testcase>
</$button>