[TW5] How can I get $radio buttons under some fields in tiddler edit mode?

134 views
Skip to first unread message

sini-Kit

unread,
Aug 27, 2016, 4:53:28 PM8/27/16
to TiddlyWiki
 Hi! I want to make simple select by $radio buttons to fields with names shop_color shop_size and some other.

I have put my little macros to $:/core/ui/EditTemplate/fields

\define lingo-base() $:/language/EditTemplate/
\define config-title()
$:/config/EditTemplateFields/Visibility/$(currentField)$
\end
\define config-filter()
[[hide]] -[title{$(config-title)$}]
\end
\define thisListf(myfield)
<tr>
<td>
</td>
<td>
<$radio field=$myfield$ value="$(TestVariable)$"> $(TestVariable)$ </$radio>
</td>
<td>
</td>
</tr>
\end
\define thisListf2(myfield)
<$list filter="[tag[$:/Note]each[$myfield$]get[$myfield$]]" variable="nazvanie">
   <$set name=TestVariable value=<<nazvanie>> >
   <<thisListf $myfield$>>
   </$set>
   </$list>
\end

\define new-field-inner()
<$reveal type="nomatch" text="" default=<<name>>>
<$button>
<$action-sendmessage $message="tm-add-field" $name=<<name>> $value=<<value>>/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<<lingo Fields/Add/Button>>
</$button>
</$reveal>
<$reveal type="match" text="" default=<<name>>>
<$button>
<<lingo Fields/Add/Button>>
</$button>
</$reveal>
\end
\define new-field()
<$set name="name" value={{$:/temp/newfieldname}}>
<$set name="value" value={{$:/temp/newfieldvalue}}>
<<new-field-inner>>
</$set>
</$set>
\end
<div class="tc-edit-fields">
<table class="tc-edit-fields">
<tbody>
<$list filter="[all[current]fields[]] +[sort[title]]" variable="currentField">
<$list filter=<<config-filter>> variable="temp">
<tr class="tc-edit-field">
<td class="tc-edit-field-name">
<$text text=<<currentField>>/>:</td>
<td class="tc-edit-field-value">
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
</td>
<td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
<$action-deletefield $field=<<currentField>>/>
{{$:/core/images/delete-button}}
</$button>
</td>
</tr>
<<thisListf2 $(currentField)$>>  
</$list>
</$list>
</tbody>
</table>
</div>
<$fieldmangler>
<div class="tc-edit-field-add">
<em class="tc-edit">
<<lingo Fields/Add/Prompt>>
</em>
<span class="tc-edit-field-add-name">
<$edit-text tiddler="$:/temp/newfieldname" tag="input" default="" placeholder={{$:/language/EditTemplate/Fields/Add/Name/Placeholder}} focusPopup=<<qualify "$:/state/popup/field-dropdown">> class="tc-edit-texteditor tc-popup-handle"/>
</span>
<$button popup=<<qualify "$:/state/popup/field-dropdown">> class="tc-btn-invisible tc-btn-dropdown" tooltip={{$:/language/EditTemplate/Field/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Field/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button>
<$reveal state=<<qualify "$:/state/popup/field-dropdown">> type="nomatch" text="" default="">
<div class="tc-block-dropdown tc-edit-type-dropdown">
<$linkcatcher to="$:/temp/newfieldname">
<div class="tc-dropdown-item">
<<lingo Fields/Add/Dropdown/User>>
</div>
<$list filter="[!is[shadow]!is[system]fields[]sort[]] -created -creator -draft.of -draft.title -modified -modifier -tags -text -title -type"  variable="currentField">
<$link to=<<currentField>>>
<<currentField>>
</$link>
</$list>
<div class="tc-dropdown-item">
<<lingo Fields/Add/Dropdown/System>>
</div>
<$list filter="[fields[]sort[]] -[!is[shadow]!is[system]fields[]]" variable="currentField">
<$link to=<<currentField>>>
<<currentField>>
</$link>
</$list>
</$linkcatcher>
</div>
</$reveal>
<span class="tc-edit-field-add-value">
<$edit-text tiddler="$:/temp/newfieldvalue" tag="input" default="" placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}} class="tc-edit-texteditor"/>
</span>
<span class="tc-edit-field-add-button">
<$macrocall $name="new-field"/>
</span>
</div>
</$fieldmangler>


AND my radio buttons appear in edit mode BUT under ALL fields.
I want to show this buttons only under several fields with names  shop_color shop_size and so on. I want to put this fields to external list and make filter before my macros? but it don't work.....


Mat

unread,
Aug 28, 2016, 11:11:18 AM8/28/16
to TiddlyWiki
Hi sini-Kit - the most amazing TW shop maker ever!

Does this suffice?

in $:/core/ui/EditTemplate/fields


[...all macros...]

<div class="tc-edit-fields">
<table class="tc-edit-fields">
<tbody>
<$list filter="[all[current]fields[]] +[sort[title]]" variable="currentField">
<$list filter=<<config-filter>> variable="temp">
<tr class="tc-edit-field">
<td class="tc-edit-field-name">
<$text text=<<currentField>>/>:</td>
<td class="tc-edit-field-value">
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
</td>
<td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
<$action-deletefield $field=<<currentField>>/>
{{$:/core/images/delete-button}}
</$button>
<$list filter="[<currentField>prefix[shop_]]" emptyMessage="nothing">
mybutton
</$list>
</td>
</tr>
</$list>
</$list>
</tbody>
</table>
</div>

<$fieldmangler>
[...etc]


<:-)

sini-Kit

unread,
Aug 29, 2016, 1:37:50 AM8/29/16
to tiddl...@googlegroups.com
Thank you, Mat! your variant is good and radio buttons appear only  under fields with prefix, but in in this variant this buttons stop working (I don't know why) 

<$list filter="[<currentField>prefix[shop_]]" emptyMessage="">
<
<thisListf2 $(currentField)$>>
 </$list>


I make another very long variant. we store fields names to show in tiddlers  $:/config/EditTemplateFields/Visibility/radio/$(currentField)$
 this variant is not beautiful, but it works. Demo soon...

\define lingo-base() $:/language/EditTemplate/
\define config-title()
$:/config/EditTemplateFields/Visibility/$(currentField)$
\end
\define config-title2()
$:/config/EditTemplateFields/Visibility/radio/$(currentField)$
\end

\define config-filter()
[[hide]] -[title{$(config-title)$}]
\end
\define config-filter2()
[[]] -[title{$(config-title2)$}]
\end

\define thisListf(myfield)
<tr>
<td>
</td>
<td>
<$radio field=$myfield$ value="$(TestVariable)$"> $(TestVariable)$ </$radio>
</td>
<td>
</td>
</tr>
\end
\define thisListf2(myfield)
<$list filter="[all[tiddlers]tag[$:/Note]each[$myfield$]get[$myfield$]]" variable="nazvanie">
<div class="tc-edit-fields">
<table class="tc-edit-fields">
<tbody>
<$list filter="[all[current]fields[]] +[sort[title]]" variable="currentField">
<$list filter=<<config-filter>> variable="temp">
<tr class="tc-edit-field">
<td class="tc-edit-field-name">
<$text text=<<currentField>>/>:</td>
<td class="tc-edit-field-value">
<$edit-text tiddler=<<currentTiddler>> field=<<currentField>> placeholder={{$:/language/EditTemplate/Fields/Add/Value/Placeholder}}/>
</td>
<td class="tc-edit-field-remove">
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
<$action-deletefield $field=<<currentField>>/>
{{$:/core/images/delete-button}}
</$button>
</td>
</tr>
<$list filter=<<config-filter2>> variable="temp2">
<<thisListf2 $(currentField)$>>  
</$list>

</$list>
</$list>
</tbody>
</table>
</div>
<$fieldmangler>






воскресенье, 28 августа 2016 г., 18:11:18 UTC+3 пользователь Mat написал:

Mat

unread,
Aug 29, 2016, 5:56:49 AM8/29/16
to TiddlyWiki
Could it be as simple as that you have

<$list filter=<<config-filter2>> variable="temp2">
<
<thisListf2 $(currentField)$>>
</$list>

...but it should(?) be 

<$list filter=<<config-filter2>> variable="temp2">
<$macrocall $name="thisListf2" myfield=<
<currentField>>/>
</$list>


<:-)

Reply all
Reply to author
Forward
0 new messages