-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathColumnTables.tid
175 lines (156 loc) · 4.33 KB
/
ColumnTables.tid
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
title: $:/plugins/OokTech/DynamicTables/ColumnTables
tags: $:/tags/Macro
\define ColumnTable(filter fields titleLinks wikify)
<$vars
ColumnList="""$filter$"""
FieldsUsed="""$fields$"""
TitleLinks="""$titleLinks$"""
WikifyContent="""$wikify$"""
>
<<TableMacrosInnerColumnTable>>
</$vars>
\end
\define TableMacrosMakeTableSortState() {{$:/state/tables/Sort/$(RowOrColumn)$/$(FieldsList)$}}
\define TableMacrosMakeTableSortStateTiddler() $:/state/tables/Sort/$(RowOrColumn)$/$(FieldsList)$
\define TableMacrosInlineEditButton()
<$reveal
type='nomatch'
state="""$:/temp/edit/$(ThisTiddler)$/$(ThisField)$"""
text='edit'
>
<$button
set="""$:/temp/edit/$(ThisTiddler)$/$(ThisField)$"""
setTo=edit
class='tc-btn-invisible'
style='width:100%;hegiht:100%'
>
<$list
filter="""[<WikifyContent>prefix[true]]"""
variable=unused
emptyMessage="""<$view
tiddler=<<ThisTiddler>>
field=<<ThisField>>
>
--
</$view>"""
>
<$transclude
tiddler=<<ThisTiddler>>
field=<<ThisField>>
>
--
</$transclude>
</$list>
</$button>
</$reveal>
<$reveal
type='match'
state="""$:/temp/edit/$(ThisTiddler)$/$(ThisField)$"""
text='edit'
>
<$button
set="""$:/temp/edit/$(ThisTiddler)$/$(ThisField)$"""
setTo=noedit
>
{{$:/core/images/done-button}}
</$button>
<$edit-text
tiddler=<<ThisTiddler>>
field=<<ThisField>>
size=1
/>
</$reveal>
\end
\define TableMacrosInnerColumnTable()
<$set
name=FieldsList1
filter='$(ColumnList)$+[fields[]]-[[text]]-[[title]]-[[modified]]-[[created]]-[[tags]]'
>
<$set
name=FieldsList
filter='[is[system]!is[system]]$(FieldsUsed)$'
emptyValue=<<FieldsList1>>
>
<$vars
RowOrColumn=Column
TableSortState=<<TableMacrosMakeTableSortState>>
>
<table>
<<TableMacrosColumnInnerInnerRows>>
</table>
</$vars>
</$set>
</$set>
\end
\define TableMacrosColumnInnerInnerRows()
<tr>
<th>
</th>
<$list
filter='$(ColumnList)$+[sort{$(TableMacrosMakeTableSortStateTiddler)$}]'
>
<th>
<$list
filter='[[$(TitleLinks)$]prefix[true]]'
variable=unused
emptyMessage=<<currentTiddler>>
>
<$link>
<<currentTiddler>>
</$link>
</$list>
</th>
</$list>
</tr>
<$list
filter=<<FieldsList>>
variable=ThisField
>
<tr>
<th>
<$button
class='tc-btn-invisible'
set=<<TableMacrosMakeTableSortStateTiddler>>
setTo=<<ThisField>>
>
<<ThisField>>
</$button>
</th>
<$list
filter='$(ColumnList)$+[sort{$(TableMacrosMakeTableSortStateTiddler)$}]'
variable=ThisTiddler
>
<td>
<<TableMacrosInlineEditButton>>
</td>
</$list>
</tr>
</$list>
\end
!Simple Column Tables
Column table:
```
<<ColumnTable "row tiddler filter" "field filter" titleLinks wikify>>
```
|!Parameter |!Description |
|`filter` |A filter that defines which tiddlers are used to make the table rows |
|`fields` |A filter that defines which fields are listed to make the table columns |
|`titleLinks` |If this is set to `true` than the tiddler title in the row headers are links. (Default: `false`) |
|`wikify` |If this is set to `true` than the cell contents are wikified before being displayed. (Default: `false`) |
The `ColumnTable` macro takes a filter listing tiddlers as input, with an
optional second filter listing fields.
The tiddler filter defines which tiddlers are the columns for the
`ColumnTable`.
If the second filter is left out the rows for the`ColumnTable` macro are
defined by the fields in the returned tiddlers. Otherwise the second filter
defines the rows used. Each row is a field, if a tiddler doesn't have the
field listed than `--` is displayed.
Clicking on a table cell lets you edit that field for the tiddler.
If titleLinks is true than the tiddler name in the row header is a link to the
tiddler.
If `wikify` is true than the cell contents are wikified, so title lists and
other wikitext will display the rendered result, not the raw text.
You can click on a row header and sort the table by that row. Unfortunately
sorting row tables by the row or column tables by the columns is
probably going to take some javascript that I don't feel like dealing with
right now. It requires sorting the fields of a tiddler by their contents.