Skip to content

Commit 6fc19b9

Browse files
committed
Toggle between edit and save buttons
1 parent 445a0ea commit 6fc19b9

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

tiddlers/$__supp-info_notes_view-template.tid

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
created: 20251107152410791
2-
modified: 20251111001809867
2+
modified: 20251112195543403
33
tags: $:/tags/ViewTemplate
44
title: $:/supp-info/notes/view-template
55
type: text/vnd.tiddlywiki
@@ -18,9 +18,24 @@ type: text/vnd.tiddlywiki
1818
$tiddler="$:/supp-info/notes/content"
1919
$value={{{ [{$:/supp-info/notes/content}jsondelete<currentTiddler>,<index>format:json[2]] }}}
2020
/>
21-
</$let>
2221
\end delete-note
2322

23+
\procedure edit-note(index)
24+
<$action-setfield
25+
$tiddler=`$:/temp/supp-info/notes/$(currentTiddler)$/$(index)$`
26+
$field=mode
27+
$value=save
28+
/>
29+
\end edit-note
30+
31+
\procedure save-note(index)
32+
<$action-setfield
33+
$tiddler=`$:/temp/supp-info/notes/$(currentTiddler)$/$(index)$`
34+
$field=mode
35+
$value=edit
36+
/>
37+
\end save-note
38+
2439
<% if [{$:/supp-info/notes/content}jsonget<currentTiddler>] %>
2540
<div class="supp-notes">
2641
<$let count={{{ [{$:/supp-info/notes/content}jsonindexes<currentTiddler>last[]add[1]] }}}>
@@ -35,11 +50,19 @@ type: text/vnd.tiddlywiki
3550
<div class="note-list">
3651
<$list filter="[{$:/supp-info/notes/content}jsonindexes<currentTiddler>]" variable="index">
3752
<div class="note-row">
38-
<$button actions=`<<delete-note $(index)$>>` ><span class="icon">{{$:/core/images/delete-button}}</span></$button>
39-
<$button actions=`<<>>` ><span class="icon">{{$:/core/images/edit-button}}</span></$button>
40-
<div class="note">
41-
<$wikify name="note" text={{{ [{$:/supp-info/notes/content}jsonget<currentTiddler>,<index>] }}} output="html"><<note>></$wikify>
42-
</div>
53+
<$let toggle=`$:/temp/supp-info/notes/$(currentTiddler)$/$(index)$` mode={{{ [<toggle>get[mode]] }}} >
54+
<$button actions=`<<delete-note $(index)$>>` ><span class="icon">{{$:/core/images/delete-button}}</span></$button>
55+
<% if [<mode>match[edit]] %>
56+
<$button actions=`<<edit-note $(index)$>>` ><span class="icon">{{$:/core/images/save-button}}</span></$button>
57+
<% else %>
58+
<$button actions=`<<save-note $(index)$>>` ><span class="icon">{{$:/core/images/edit-button}}</span></$button>
59+
<% endif %>
60+
<div class="note">
61+
<$wikify name="note" text={{{ [{$:/supp-info/notes/content}jsonget<currentTiddler>,<index>] }}} output="html">
62+
<<note>>
63+
</$wikify>
64+
</div>
65+
</$let>
4366
</div>
4467
</$list>
4568
</div>

0 commit comments

Comments
 (0)