~hokiegeek/tw5-location-crafts

ref: 0101ce70b04d55f8103165becacbc51f5218ad19 tw5-location-crafts/macros.tid -rw-r--r-- 6.9 KiB
0101ce70HokieGeek Loads caption of an element tiddler if found 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
modified: 20220217125223000
created: 20220214180052000
creator: hokiegeek
title: $:/plugins/hokiegeek/location-crafts/macros
tags: $:/tags/Macro
type: text/vnd.tiddlywiki

<!--
how to mark uniques?
and how to mark them off?
-->

<!--
\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)
\whitespace trim
<span class="tc-links-draggable-list">
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
<$type$ class="$class$">
<$list filter="[list[$tiddler$!!$field$]]">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""" enable=<<tv-enable-drag-and-drop>>>
<div class="tc-droppable-placeholder"/>
<div>
<$transclude tiddler="""$itemTemplate$""">
<$link to={{!!title}}>
<$transclude field="caption">
<$view field="title"/>
</$transclude>
</$link>
</$transclude>
</div>
</$droppable>
</$list>
<$tiddler tiddler="">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="div" enable=<<tv-enable-drag-and-drop>>>
<div class="tc-droppable-placeholder">
{{$:/core/images/blank}}
</div>
<div style="height:0.5em;"/>
</$droppable>
</$tiddler>
</$type$>
</$vars>
</span>
\end
-->

\define category-list(type)
<div class="category-list">
    <$let special-elements-default="expected none custom random special"
          special-elements-locations={{{ [<special-elements-default>addsuffix[ complete]] }}}
          special-elements-encounters=<<special-elements-default>>
          special-elements-objects=<<special-elements-default>>
          categoryState={{{ [{!!title}slugify[]addprefix[$:/state/location-crafts/]] }}}>
    <div class="header-button">
        <h1 style="text-transform: capitalize;">$type$</h1>
        <$button setTitle=<<categoryState>> setField=$type$ setTo="visible" tooltip="Add $type$" aria-label="Add $type$" class="tc-btn-invisible tc-btn-mini">
            {{$:/core/images/new-button}}
        </$button>
    </div>
    <div style="display: grid; width: fit-content;">
        <div style="grid-column-start: 1; font-size: .8rem; margin-right: .5rem;">
            Progress<span class="progress-points-label"> points</span>:
        </div>
        <div style="grid-column-start: 2">
            <$reveal type="gt" stateTitle=<<currentTiddler>> stateField="crafted-$type$-points" text="0">
            <$let next-points={{{ [<currentTiddler>get[crafted-$type$-points]subtract[1]] }}}>
            <$button setTitle=<<currentTiddler>> setField=crafted-$type$-points setTo=<<next-points>> tooltip="remove progress points" aria-label="remove progress points" class="tc-btn-invisible tc-btn-mini">
                {{$:/core/images/minus-button}}
            </$button>
            </$let>
            </$reveal>
            <$list filter="[<currentTiddler>get[crafted-$type$-points]else[0]compare:integer:lteq[0]]">
            <span class="btn-disabled">
                {{$:/core/images/minus-button}}
            </span>
            </$list>
        </div>
        <div style="grid-column-start: 3; padding-left: 0.5rem; padding-right: 0.5rem;">
        <$list filter="[<currentTiddler>get[crafted-$type$-points]else[0]]">
        <<currentTiddler>>
        </$list>
        </div>
        <div style="grid-column-start: 4">
            <$let next-points={{{ [<currentTiddler>get[crafted-$type$-points]else[0]add[1]] }}}>
            <$button setTitle=<<currentTiddler>> setField=crafted-$type$-points setTo=<<next-points>> tooltip="add progress points" aria-label="add progress points" class="tc-btn-invisible tc-btn-mini">
                {{$:/core/images/plus-button}}
            </$button>
            </$let>
        </div>
    </div>
    <ol>
        <$list filter="[<currentTiddler>get[crafted-$type$]enlist-input:raw[]]" variable="element" counter="counter" emptyMessage="no $type$ setup">
        <li>
            <$list filter="[<special-elements-$type$>enlist-input:raw[]match<element>]">
            <<element>>
            </$list>
            <$list filter="[<special-elements-$type$>enlist-input:raw[]match<element>then[found]else[]remove[found]]">
            <!--
            <$link to=<<element>>><<element>></$link>
            -->
            <$link to=<<element>>>
            <$transclude tiddler=<<element>> field="caption">
            <<element>>
            </$transclude>
            </$link>
            </$list>
            <!--
            <$let prev={{{ [<counter>subtract[1]] }}}
                  last={{{ [<currentTiddler>get[crafted-$type$]enlist-input:raw[]rest<counter>join[ ]] }}}
                  newlist={{{ [<currentTiddler>get[crafted-$type$]enlist-input:raw[]first<prev>append<last>join[ ]] }}}>
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="use unique" aria-label="use unique" class="tc-btn-invisible tc-btn-mini btn-close">
                <$action-setfield $tiddler=<<me>> $field="crafted-$type$" $value=<<newlist>> />
                {{$:/core/images/erase}}
            </$button>
            </$let>
            -->
        </li>
        </$list>
        <$reveal type="match" stateTitle=<<categoryState>> stateField=$type$ text="visible">
        <li>
        <div style="display: grid; width: fit-content;">
            <div style="grid-row-start: 1; grid-column-start: 1; padding-right: .3rem;">
            <$edit-text tiddler=<<categoryState>> field="custom-$type$" focus="true" />
            </div>
            <div style="grid-row-start: 1; grid-column-start: 2; padding-right: .2rem;">
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="submit" aria-label="submit" class="tc-btn-invisible tc-btn-mini">
                <$action-listops $field="crafted-$type$" $filter="[<currentTiddler>get[crafted-$type$]enlist-input:raw[]] =[<categoryState>get[custom-$type$]]" />
                <$action-setfield $tiddler=<<categoryState>> $field="custom-$type$" $value="" />
                {{$:/core/images/done-button}}
            </$button>
            </div>
            <div style="grid-row-start: 1; grid-column-start: 3;">
            <$button setTitle=<<categoryState>> setField=$type$ setTo="hidden" tooltip="cancel" aria-label="cancel" class="tc-btn-invisible tc-btn-mini">
                <$action-setfield $tiddler=<<categoryState>> $field="custom-$type$" $value="" />
                {{$:/core/images/close-button}}
            </$button>
            </div>
            <div style="grid-row-start: 2">
                <$list filter="[<special-elements-$type$>enlist-input[]]">
                <$button setTitle=<<categoryState>> setField="custom-$type$" setTo=<<currentTiddler>> class="tc-btn-invisible tc-tiddlylink">
                <<currentTiddler>>
                </$button>
                <br />
                </$list>
            </div>
        </div>
        </li>
        </$reveal>
    </ol>
    </$let>
</div>
\end