1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

wip toc testcase make new child button work

This commit is contained in:
pmario 2024-07-31 06:50:59 +02:00
parent f8954965ec
commit 4d66f95857
4 changed files with 98 additions and 75 deletions

View File

@ -3,6 +3,7 @@ code-body: yes
\whitespace trim
\procedure linkcatcherActions()
<$action-log/>
<%if [<navigateTo>has[title]] %>
<$qualify title=<<state>> name="qualifiedState">
<$action-setfield $tiddler=<<qualifiedState>> text=<<navigateTo>>/>
@ -10,83 +11,85 @@ code-body: yes
<%endif%>
\end
<$navigator story={{{ [<qualify $:/StoryList/>] }}} history={{{ [<qualify $:/HistoryList/>] }}}>
<$let
state={{{ [<qualify "$:/state/testcase">] }}}
>
<div class="tc-test-case-wrapper">
<div class="tc-test-case-header">
<h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} to=<<testcaseTiddler>>>
<%if [<testResult>!match[]] %>
<span class={{{ tc-test-case-result-icon [<testResult>!match[fail]then[tc-test-case-result-icon-pass]] [<testResult>match[fail]then[tc-test-case-result-icon-fail]] +[join[ ]] }}}>
<%if [<testResult>!match[fail]] %>
{{$:/core/images/done-button}}
<%else%>
{{$:/core/images/close-button}}
<%endif%>
</span>
<$linkcatcher actions=<<linkcatcherActions>>>
<div class="tc-test-case-wrapper">
<div class="tc-test-case-header">
<h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} to=<<testcaseTiddler>>>
<%if [<testResult>!match[]] %>
<span class={{{ tc-test-case-result-icon [<testResult>!match[fail]then[tc-test-case-result-icon-pass]] [<testResult>match[fail]then[tc-test-case-result-icon-fail]] +[join[ ]] }}}>
<%if [<testResult>!match[fail]] %>
{{$:/core/images/done-button}}
<%else%>
{{$:/core/images/close-button}}
<%endif%>
</span>
<%endif%>
<$view tiddler="Description" mode="inline"/>
</$genesis>
<span class="tc-test-case-toolbar">
<$button popup=`$(state)$-more`
tooltip={{$:/language/Buttons/More/Hint}}
aria-label={{$:/language/Buttons/More/Caption}}
class="tc-btn-invisible"
selectedClass="tc-selected"
>
{{$:/core/images/down-arrow}}
</$button>
<$let
tv-config-toolbar-icons="yes"
tv-config-toolbar-text="yes"
tv-config-toolbar-class="tc-btn-invisible"
>
<$reveal state=`$(state)$-more` type="popup" position="belowleft" animate="yes">
<div class="tc-drop-down">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]"
variable="listItem"
>
<$transclude $tiddler=<<listItem>> $mode="inline"/>
</$list>
</div>
</$reveal>
</$let>
</span>
</h2>
</div>
<%if [[Narrative]is[tiddler]] %>
<div class="tc-test-case-narrative">
<$transclude $tiddler="Narrative" $mode="block"/>
</div>
<%endif%>
<%if [<testResult>match[fail]] %>
<div class="tc-test-case-result-fail">
<div class="tc-test-case-result-fail-header">
TEST FAILED
</div>
<div class="tc-test-case-result-fail-body">
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
</div>
</div>
<%endif%>
<div class="tc-test-case-panes">
<div class="tc-test-case-source">
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -[prefix[$:/HistoryList/]] -[prefix[$:/StoryList/]] -Description -Narrative -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/>
</div>
<div class="tc-test-case-divider">
</div>
<div class="tc-test-case-output">
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
<%else%>
<$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/>
</$tiddler>
<%endif%>
<$view tiddler="Description" mode="inline"/>
</$genesis>
<span class="tc-test-case-toolbar">
<$button popup=`$(state)$-more`
tooltip={{$:/language/Buttons/More/Hint}}
aria-label={{$:/language/Buttons/More/Caption}}
class="tc-btn-invisible"
selectedClass="tc-selected"
>
{{$:/core/images/down-arrow}}
</$button>
<$let
tv-config-toolbar-icons="yes"
tv-config-toolbar-text="yes"
tv-config-toolbar-class="tc-btn-invisible"
>
<$reveal state=`$(state)$-more` type="popup" position="belowleft" animate="yes">
<div class="tc-drop-down">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]"
variable="listItem"
>
<$transclude $tiddler=<<listItem>> $mode="inline"/>
</$list>
</div>
</$reveal>
</$let>
</span>
</h2>
</div>
<%if [[Narrative]is[tiddler]] %>
<div class="tc-test-case-narrative">
<$transclude $tiddler="Narrative" $mode="block"/>
</div>
<%endif%>
<%if [<testResult>match[fail]] %>
<div class="tc-test-case-result-fail">
<div class="tc-test-case-result-fail-header">
TEST FAILED
</div>
<div class="tc-test-case-result-fail-body">
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
</div>
</div>
<%endif%>
<div class="tc-test-case-panes">
<div class="tc-test-case-source">
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -Description -Narrative -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/>
</div>
<div class="tc-test-case-divider">
</div>
<div class="tc-test-case-output">
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
<%else%>
<$linkcatcher actions=<<linkcatcherActions>>>
<$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/>
</$tiddler>
</$linkcatcher>
<%endif%>
</div>
</div>
</div>
</$linkcatcher>
</$let>
</$navigator>

View File

@ -1,6 +1,19 @@
title: $:/core/ui/testcases/DefaultTemplate/SourceTabs
\whitespace trim
\procedure saveActions()
<$action-log/>
<$action-sendmessage $message="tm-save-tiddler" $param=<<title>> />
<$action-navigate $to=<<navTitle>> $scroll="no"/>
\end
\procedure saveButton(title, navTitle)
<$button class="tc-btn-invisible tc-test-case-save-button tc-small-gap-left" actions=<<saveActions>> >
{{$:/core/images/done-button}}
</$button>
\end
\procedure body()
<$list filter="[<currentTab>fields[]] -text +[limit[1]]" variable="ignore">
<table class="tc-field-table">
@ -11,7 +24,12 @@ title: $:/core/ui/testcases/DefaultTemplate/SourceTabs
<$text text=<<fieldName>>/>
</td>
<td>
<$view tiddler=<<currentTab>> field=<<fieldName>>/>
<%if [<fieldName>match[draft.title]] :filter[<currentTab>has[draft.of]] %>
<$edit class="tc-edit-texteditor tc-max-width-80" tiddler=<<currentTab>> field=<<fieldName>>/>
<$macrocall $name="saveButton" navTitle={{{ [<currentTab>get[draft.title]] }}} title=<<currentTab>>/>
<%else%>
<$view tiddler=<<currentTab>> field=<<fieldName>>/>
<%endif%>
</td>
</tr>
</$list>

View File

@ -54,6 +54,8 @@ The very first toc macro is _not_ reused. So it can be used as a simple referenc
<$action-sendmessage $message="tm-new-tiddler" $name=<<field>> $value={{{[<currentTiddler>format:titlelist[]]}}}/>
{{$:/core/images/new-here-button}}
<% endif %>
<!-- Allows the toc macros to navigate in test-case tiddlers -->
<$action-navigate $to={{{ [<tv-history-list>get[current-tiddler]] }}}/>
</$button>
\end _newChild
<% if [<tv-toc-show-new-child>match[yes]] %>

View File

@ -1,6 +1,6 @@
created: 20240730081443212
description: Simple TOC - parentField parameter
modified: 20240730090835300
modified: 20240730115536164
tags: $:/tags/wiki-test-spec
title: Examples/TOC/SimpleToc/parentField
type: text/vnd.tiddlywiki-multiple
@ -44,7 +44,7 @@ title: Output
This variable set to yes allows you to show a New-Child button.
This button will create a "real" tiddler, which will _not_ be listed here
-->
\define tv-toc-show-new-child() no
\define tv-toc-show-new-child() yes
<div class="tc-table-of-contents">
<<toc tag:"root" parentField:"parent">>