Query - Is there a Save AND CLOSE Button?

287 views
Skip to first unread message

@TiddlyTweeter

unread,
May 25, 2017, 8:25:17 AM5/25/17
to tiddl...@googlegroups.com
Q: Is there a Save AND CLOSE Button?

After editing or creating a Tiddler I am forever having to click the "X". In many use cases this is inefficient & creates visual clutter by persisting Tiddlers that don't need to be open.

For example, using Telmiger's ToDoNow plugin you get one consolidated Tiddler that has all the information needed. But when you add or edit a Tiddler from it you have to explicitly close it to bring back into focus the ToDoNow Tiddler.

In a more general sense, when one's TiddlyWiki works through some MAIN Tiddler, the rest are slaves to its Transclusions. The result of edits show relevantly IN those Transclusions, not in displaying fragments.

So, I am interested in having the option to "Save & Close" rather than having to "Tick" THEN "X".

Has anyone done that? I have to ask as I have no idea myself how to do it.

Please ask me to explain more if this is unclear.

Best wishes
Josiah

 

Ton Gerner

unread,
May 25, 2017, 9:42:52 AM5/25/17
to TiddlyWiki
Hi Josiah,

tags: $:/tags/EditToolbar
title
: Save & close button

<$fieldmangler><$button tooltip={{$:/language/Buttons/Save/Hint}} aria-label={{$:/language/Buttons/Save/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/
core/images/done-button}}{{$:/core/images/close-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/
language/Buttons/Save/Caption}}/></span>
</$list>
</
$button>
</$fieldmangler>


Cheers,

Ton

@TiddlyTweeter

unread,
May 25, 2017, 10:26:10 AM5/25/17
to tiddl...@googlegroups.com
Ciao Ton

Thankyou!

I put it in. The icon appears in edit mode. Clicking it saves, but in my 5.1.14 in Firefox it does not close the Tiddler :-(.

Josiah

Ton Gerner

unread,
May 25, 2017, 11:31:21 AM5/25/17
to TiddlyWiki
Hi Josiah,

Hmmm... I thought it worked when I tested it.
Don't know what is wrong with the code.
Anyhow I found an interesting discussion: https://groups.google.com/forum/#!msg/tiddlywiki/_76g9VsbTAM/w0sNd-i8BAAJ

Cheers,

Ton

@TiddlyTweeter

unread,
May 25, 2017, 12:04:11 PM5/25/17
to TiddlyWiki
Ciao Ton

I just double-checked it in a fresh empty TW. Sorry, its not closing the Tiddler.

Thanks for indicating its been discussed before.

Best wishes
Josiah

Eric Shulman

unread,
May 25, 2017, 1:34:39 PM5/25/17
to TiddlyWiki
On Thursday, May 25, 2017 at 9:04:11 AM UTC-7, @TiddlyTweeter wrote:
I just double-checked it in a fresh empty TW. Sorry, its not closing the Tiddler.

I don't have a solution (yet), but here's some details that might help:

This is the message being sent to close the tiddler
<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>

However, because this button is invoked while editing the tiddler, the value of <<currentTiddler>> includes the "Draft of" prefix (i.e, Draft of 'Foobar').

Fortunately, when a tiddler is being edited, the underlying title (i.e., without the "Draft of" prefix) is available in the "draft.title" field.  Thus, you can write:
<$action-sendmessage $message="tm-close-tiddler" $param={{!!draft.title}}/>

Unfortunately, after a quick test on TiddlyWiki.com, this also does not seem to work as desired and the underlying tiddler is still not being closed.

I think the problem may be a matter of timing.  At the moment that the button is pressed, only the "Draft of" tiddler is displayed and the underlying tiddler is not. Thus, while you can issue a tm-close-tiddler to close the currently visible draft tiddler, the message to close the underlying tiddler is ignored since that tiddler is not actually "open" at the time. 

-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

@TiddlyTweeter

unread,
May 25, 2017, 3:46:30 PM5/25/17
to TiddlyWiki
Thank you very much Eric

I really don't have the tech competence on this, to actually do it, but I think other people are interested too and would be great if we could solve this issue.

I'm coming at it in terms of functional design. There are many kinds of applications where creating & editing should never lead to displaying the "fragment" created, since the "fragment" would only make sense when embedded into its intended context. If you get what I mean?

Best wishes
Josiah

RichardWilliamSmith

unread,
May 25, 2017, 6:51:14 PM5/25/17
to TiddlyWiki
This seems to work (title:$:/core/ui/Buttons/save_and_close , tags:$:/tags/EditToolbar)

<$set name="ogtiddler" value={{!!draft.of}}>

<$fieldmangler><$button tooltip={{$:/language/Buttons/Save/Hint}} aria-label={{$:/language/Buttons/Save/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$action-sendmessage $message="tm-close-tiddler" $param=<<ogtiddler>>/>

<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
OK

</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Save/Caption}}/></span>
</$list>
</$button>
</$fieldmangler>
</$set>

The mechanism is <$set name="ogtiddler" value={{!!draft.of}}> to grab the name of the tiddler and <$action-sendmessage $message="tm-close-tiddler" $param=<<ogtiddler>>/> to close it. 

Change 'OK' to whatever you'd like the button to look like.

Regards,
Richard
 

@TiddlyTweeter

unread,
May 25, 2017, 7:34:21 PM5/25/17
to TiddlyWiki
Thanks RichardWS

Excellent! I will try it tomorrow.

Best wishes
Josiah

RichardWilliamSmith wrote:
This seems to work ...

@TiddlyTweeter

unread,
May 26, 2017, 8:20:10 AM5/26/17
to TiddlyWiki
Ciao RichardWS

I been testing this in an empty TW. So far so good.

Many thanks,

Julian Kniephoff

unread,
May 29, 2017, 3:09:13 AM5/29/17
to TiddlyWiki
Shouldn't {{!!draft.of}} rather be {{!!draft.title}}, like Eric originally suggested? Otherwise, this technique doesn't work for me when I change the title of the tiddler; it just stays open, which makes sense, because the (potentially) new/edited title is saved in the draft.title field, not draft.of, which contains the title of the original tiddler unchanged.

But apart from that: Thanks, Richard and Eric, I've been looking for something like this! :D

Ton Gerner

unread,
May 29, 2017, 6:08:13 AM5/29/17
to tiddl...@googlegroups.com
Just some observations.

My proposal used a modified Save tiddler with


<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>

inserted after

<$action-sendmessage $message="tm-save-tiddler"/>

I thought saving of the tiddler occurs *before* closing of the tiddler, so no draft situation when you close it.
 
But neither `$param=<<currentTiddler>>` nor `$param={{!!title}}` does work, although a hardcoded parameter `$param="New Tiddler"` does save & close New Tiddler!!!

Maybe I tested my hardcoded version when I proposed my Save & close button ;-)

Eric tried `param={{!!draft.title}}` which did not work either.

RichardWilliamSmith used a separate variable for the draft status:


<$set name="ogtiddler" value={{!!draft.of}}>

and

$param=<<ogtiddler>>

which works. Thanks Richard.

Conclusion: With a hardcoded `$param` you do not need the draft status, but with a softcoded `$param` you do need the draft status.
So a hardcoded $param acts not the same as a software coded $param. But why?

@Julian

Create a tiddler which contains:

{{!!title}}

{{!!draft.of}}

{{!!draft.title}}

In edit mode with preview mode enabled you see that `{{!!draft.of}}` and `{{!!draft.title}}` behave the same.

But - still in edit mode - change the title of that tiddler. Only `{{!!draft.title}}` follows the change! Why?

As I said: Just some observations. Maybe somebody can explain my observations.

Cheers,

Ton

Julian Kniephoff

unread,
May 29, 2017, 7:33:16 AM5/29/17
to TiddlyWiki
On Monday, May 29, 2017 at 12:08:13 PM UTC+2, Ton Gerner wrote:
@Julian

Create a tiddler which contains:

{{!!title}}

{{!!draft.of}}

{{!!draft.title}}

In edit mode with preview mode enabled you see that `{{!!draft.of}}` and `{{!!draft.title}}` behave the same.

But - still in edit mode - change the title of that tiddler. Only `{{!!draft.title}}` follows the change! Why?

That is exactly what I meant. draft.of contains the original title of the tiddler that is being edited; i.e. the name the tiddler had when you click the edit button, even if you change the title during editing. draft.title contains the title that the tiddler should get after editing. When you just pressed the edit button, this coincides with draft.of, because you haven't changed the title yet, but when you do, draft.title updates.

Now I am not that familiar with TiddlyWikis editing lifecycle internals, yet, but I presume that both are needed at the moment you save the tiddler. You want to be able to reference the original tiddler, for example to potentially delete it when you changed the title, or to write the new values of the draft tiddler back to it if you didn't. Also, if you changed the title, you of course need to be able to reference that, to actually create the new tiddler.

PMario

unread,
May 29, 2017, 8:02:27 AM5/29/17
to TiddlyWiki
On Monday, May 29, 2017 at 1:33:16 PM UTC+2, Julian Kniephoff wrote:
On Monday, May 29, 2017 at 12:08:13 PM UTC+2, Ton Gerner wrote:
@Julian

Create a tiddler which contains:

{{!!title}}

{{!!draft.of}}

{{!!draft.title}}

In edit mode with preview mode enabled you see that `{{!!draft.of}}` and `{{!!draft.title}}` behave the same.

But - still in edit mode - change the title of that tiddler. Only `{{!!draft.title}}` follows the change! Why?

That is exactly what I meant. draft.of contains the original title of the tiddler that is being edited; i.e. the name the tiddler had when you click the edit button, even if you change the title during editing. draft.title contains the title that the tiddler should get after editing. When you just pressed the edit button, this coincides with draft.of, because you haven't changed the title yet, but when you do, draft.title updates.

You are exactly right!
 
Now I am not that familiar with TiddlyWikis editing lifecycle internals, yet, but I presume that both are needed at the moment you save the tiddler.

right. .. Internally the tidders are immutable. That means eg: plugin authors have to use the core function $tw.wiki.addTiddler() or $tw.wiki.deleteTiddler() and so on.  Using those functions is necessary, because changing tiddlers also needs to trigger a UI refresh, if the edited tiddler is visible at the moment.

So as soon as you change the content of a tiddler it will be refreshed. That's the main reason, why $edit-widget in view mode causes problems. Since as soon as you change a single character it will be refreshed and the "edit-widget" looses focus. ... That's a famous newbee trap!
 
You want to be able to reference the original tiddler, for example to potentially delete it when you changed the title,

exactly
 
or to write the new values of the draft tiddler back to it if you didn't.

If tiddler content is overwritten, you actually create a new one with the same name which overwrites the old one in the internal memory. ... But directly editing the internal memory with eg: plugins is not possible since tiddlers are immutable there.
 
Also, if you changed the title, you of course need to be able to reference that, to actually create the new tiddler.

right. you also need to send a "delete request" with the old name, and a "create request" with the new name, to a server, if you run in client - server mode.

have fun!
mario
Reply all
Reply to author
Forward
0 new messages