2014-09-11 14:52:47 +00:00
|
|
|
title: $:/core/macros/list
|
|
|
|
tags: $:/tags/Macro
|
|
|
|
|
2018-01-09 17:13:45 +00:00
|
|
|
\define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage)
|
2014-09-28 08:32:54 +00:00
|
|
|
<$type$ class="$class$">
|
2018-01-09 17:13:45 +00:00
|
|
|
<$list filter="$filter$" emptyMessage=<<__emptyMessage__>>>
|
2014-09-17 11:13:24 +00:00
|
|
|
<$subtype$>
|
2014-09-11 14:52:47 +00:00
|
|
|
<$link to={{!!title}}>
|
2014-09-28 19:11:58 +00:00
|
|
|
<$transclude field="caption">
|
2014-09-11 14:52:47 +00:00
|
|
|
<$view field="title"/>
|
2014-09-28 19:11:58 +00:00
|
|
|
</$transclude>
|
2014-09-11 14:52:47 +00:00
|
|
|
</$link>
|
2014-09-17 11:13:24 +00:00
|
|
|
</$subtype$>
|
2014-09-11 14:52:47 +00:00
|
|
|
</$list>
|
2014-09-17 11:13:24 +00:00
|
|
|
</$type$>
|
2014-09-11 14:52:47 +00:00
|
|
|
\end
|
2017-03-20 22:11:06 +00:00
|
|
|
|
|
|
|
\define list-links-draggable-drop-actions()
|
|
|
|
<$action-listops $tiddler=<<targetTiddler>> $field=<<targetField>> $subfilter="+[insertbefore:currentTiddler<actionTiddler>]"/>
|
|
|
|
\end
|
|
|
|
|
|
|
|
\define list-links-draggable(tiddler,field:"list",type:"ul",subtype:"li",class:"",itemTemplate)
|
2019-03-10 20:05:18 +00:00
|
|
|
\whitespace trim
|
|
|
|
<span class="tc-links-draggable-list">
|
2017-03-20 22:11:06 +00:00
|
|
|
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
|
|
|
<$type$ class="$class$">
|
|
|
|
<$list filter="[list[$tiddler$!!$field$]]">
|
|
|
|
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""">
|
2019-03-10 20:05:18 +00:00
|
|
|
<div class="tc-droppable-placeholder"/>
|
2017-03-20 22:11:06 +00:00
|
|
|
<div>
|
|
|
|
<$transclude tiddler="""$itemTemplate$""">
|
2018-03-06 13:29:27 +00:00
|
|
|
<$link to={{!!title}}>
|
2017-03-20 22:11:06 +00:00
|
|
|
<$transclude field="caption">
|
|
|
|
<$view field="title"/>
|
|
|
|
</$transclude>
|
|
|
|
</$link>
|
2018-03-06 13:29:27 +00:00
|
|
|
</$transclude>
|
2017-03-20 22:11:06 +00:00
|
|
|
</div>
|
|
|
|
</$droppable>
|
|
|
|
</$list>
|
2018-03-06 13:29:27 +00:00
|
|
|
</$type$>
|
2017-03-20 22:11:06 +00:00
|
|
|
<$tiddler tiddler="">
|
2018-03-06 13:29:27 +00:00
|
|
|
<$droppable actions=<<list-links-draggable-drop-actions>> tag="div">
|
2017-03-20 22:11:06 +00:00
|
|
|
<div class="tc-droppable-placeholder">
|
|
|
|
|
|
|
|
</div>
|
2018-03-06 13:29:27 +00:00
|
|
|
<div style="height:0.5em;"/>
|
2017-03-20 22:11:06 +00:00
|
|
|
</$droppable>
|
|
|
|
</$tiddler>
|
|
|
|
</$vars>
|
2019-03-10 20:05:18 +00:00
|
|
|
</span>
|
2017-03-20 22:11:06 +00:00
|
|
|
\end
|
|
|
|
|
2018-11-20 11:43:15 +00:00
|
|
|
\define list-tagged-draggable-drop-actions(tag)
|
2017-03-20 22:11:06 +00:00
|
|
|
<!-- Save the current ordering of the tiddlers with this tag -->
|
2018-11-20 11:43:15 +00:00
|
|
|
<$set name="order" filter="[<__tag__>tagging[]]">
|
2017-03-20 22:11:06 +00:00
|
|
|
<!-- Remove any list-after or list-before fields from the tiddlers with this tag -->
|
2018-11-20 11:43:15 +00:00
|
|
|
<$list filter="[<__tag__>tagging[]]">
|
2017-03-20 22:11:06 +00:00
|
|
|
<$action-deletefield $field="list-before"/>
|
|
|
|
<$action-deletefield $field="list-after"/>
|
|
|
|
</$list>
|
2018-11-20 11:43:15 +00:00
|
|
|
<!-- Save the new order to the Tag Tiddler -->
|
|
|
|
<$action-listops $tiddler=<<__tag__>> $field="list" $filter="+[enlist<order>] +[insertbefore:currentTiddler<actionTiddler>]"/>
|
2017-03-20 22:11:06 +00:00
|
|
|
<!-- Make sure the newly added item has the right tag -->
|
2018-11-20 11:43:15 +00:00
|
|
|
<!-- Removing this line makes dragging tags within the dropdown work as intended -->
|
|
|
|
<!--<$action-listops $tiddler=<<actionTiddler>> $tags=<<__tag__>>/>-->
|
|
|
|
<!-- Using the following 5 lines as replacement makes dragging titles from outside into the dropdown apply the tag -->
|
|
|
|
<$list filter="[<actionTiddler>!contains:tags<__tag__>]">
|
|
|
|
<$fieldmangler tiddler=<<actionTiddler>>>
|
|
|
|
<$action-sendmessage $message="tm-add-tag" $param=<<__tag__>>/>
|
|
|
|
</$fieldmangler>
|
|
|
|
</$list>
|
2017-03-20 22:11:06 +00:00
|
|
|
</$set>
|
|
|
|
\end
|
|
|
|
|
2018-03-07 15:52:58 +00:00
|
|
|
\define list-tagged-draggable(tag,subFilter,emptyMessage,itemTemplate,elementTag:"div")
|
2019-03-10 20:05:18 +00:00
|
|
|
\whitespace trim
|
|
|
|
<span class="tc-tagged-draggable-list">
|
2018-11-20 11:43:15 +00:00
|
|
|
<$set name="tag" value=<<__tag__>>>
|
|
|
|
<$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>>>
|
2017-04-17 15:51:12 +00:00
|
|
|
<$elementTag$ class="tc-menu-list-item">
|
2018-11-20 11:43:15 +00:00
|
|
|
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""">
|
2019-03-10 20:05:18 +00:00
|
|
|
<$elementTag$ class="tc-droppable-placeholder"/>
|
2017-04-17 15:51:12 +00:00
|
|
|
<$elementTag$>
|
2017-03-20 22:11:06 +00:00
|
|
|
<$transclude tiddler="""$itemTemplate$""">
|
|
|
|
<$link to={{!!title}}>
|
|
|
|
<$view field="title"/>
|
|
|
|
</$link>
|
|
|
|
</$transclude>
|
2017-04-17 15:51:12 +00:00
|
|
|
</$elementTag$>
|
2017-03-20 22:11:06 +00:00
|
|
|
</$droppable>
|
2017-04-17 15:51:12 +00:00
|
|
|
</$elementTag$>
|
2017-03-20 22:11:06 +00:00
|
|
|
</$list>
|
|
|
|
<$tiddler tiddler="">
|
2018-11-20 11:43:15 +00:00
|
|
|
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""">
|
2019-03-10 20:05:18 +00:00
|
|
|
<$elementTag$ class="tc-droppable-placeholder"/>
|
2017-04-17 15:51:12 +00:00
|
|
|
<$elementTag$ style="height:0.5em;">
|
|
|
|
</$elementTag$>
|
2017-03-20 22:11:06 +00:00
|
|
|
</$droppable>
|
|
|
|
</$tiddler>
|
|
|
|
</$set>
|
2019-03-10 20:05:18 +00:00
|
|
|
</span>
|
2017-03-20 22:11:06 +00:00
|
|
|
\end
|