Help needed with "It's About Time!" and adding data to an events tiddler

Hello all

I am using the impressive It’s About Time! created by @EricShulman. In particular I want to use it as a booking system for a holiday home. I have created a small routine in a tiddler, called TF Bookings Editor, to add any entry to an events tiddler called TF Bookings. See below:

Booking for: <br>
<$edit-text field=booking-by/>

<hr>
Start date: <$macrocall $name="edit-date" tiddler=<<currentTiddler>> field="start-date" type="button" format="YYYY0MM0DD" /> <$view field=start-date format=date template="0DD/0MM/YYYY"/>
End date: <$macrocall $name="edit-date" tiddler=<<currentTiddler>> field="end-date" type="button" format="YYYY0MM0DD" /> <$view field=end-date format=date template="0DD/0MM/YYYY"/>

<$let new-entry={{{ [{!!start-date}addsuffix[-]addsuffix{!!end-date}addsuffix[;]addsuffix{!!booking-by}] }}} revised-text={{{ [{TF Bookings}addsuffix[ ]addsuffix<new-entry>] }}}
>

<br>

<$button> 
<$action-listops $tiddler="TF Bookings" $field="text" $filter="[<revised-text>]"/>
Add booking
</$button>

</$let>

<hr>

''Bookings''

{{TF Bookings}}

The routine adds the revised data to the events tiddler but surrounds it in [] and also the line breaks between entries have gotten lost.

Any advice on what to do to correct this would be greatly appreciated.

Cheers, Rob

Hi Rob,
The code that you posted does not work. So it is hard to give any advice.

There is no link to the tools you use.

First, I hope you aren’t using tiddlers from It's About Time! — TiddlyTools: "Small Tools for Big Ideas!" (tm), which is very old has not been updated since Sept 2022! All current TiddlyTools add-ons are hosted directly in https://TiddlyTools.com. Specifically, for your usage, you need to copy TiddlyTools/Time/EditDate and TiddlyTools/Time/Calendar

Now, on to your problem…

Try this:

Booking for:<br><$edit-text field=booking-by/>
<hr>
Start date:
<$macrocall $name="edit-date" field="start-date" type="button" format="YYYY0MM0DD"/>
<$view field=start-date format=date template="[UTC]0DD/0MM/YYYY"/>
End date:
<$macrocall $name="edit-date" field="end-date" type="button" format="YYYY0MM0DD"/>
<$view field=end-date format=date template="[UTC]0DD/0MM/YYYY"/>
<hr>
<$let new-entry={{{ [{!!start-date}addsuffix[-]addsuffix{!!end-date}addsuffix[;]addsuffix{!!booking-by}] }}}
   lf={{{ [charcode[10]] }}}
   revised-text={{{ [{TF Bookings}!is[blank]] [<new-entry>] +[join<lf>] }}}>
<$button> Add booking
<$list filter="[{!!start-date}!is[blank]then{!!end-date}!is[blank]then{!!booking-by}!is[blank]]" variable="has-input">
<$action-setfield $tiddler="TF Bookings" text=<<revised-text>> tags="events" type="text/plain"/>
<$action-deletefield booking-by start-date end-date/>
</$list>
</$button>
</$let>
<hr>
''Bookings''
{{TF Bookings}}

Notes:

  • The $view widgets that show the entered dates use templates starting with “[UTC]”. This prevents the displayed dates from being adjusted by your current timezone offset. Note that this is only a display issue and does NOT affect the stored start-date and end-date field values.
  • The lf variable uses the charcode[10] filter operator so it contains a literal newline (aka, “line feed”) character (ASCII code 10).
  • The revised-text variable assembles any existing content from “TF Bookings” with the newly generated new-entry value, joined with a literal newline (NOT a space!). Note the test for !is[blank]… this ensures that if the existing “TF Bookings” tiddler content is empty (or the tiddler is missing), then the revised-text will not get a leading newline, and will just be the value of new-entry.
  • The actions within the “Add booking” $button widget are enclosed by a $list widget that ensures that all three needed inputs have been provided (i.e., are not blank). Note the use of variable=none… this prevents the $list widget from altering the value of currentTiddler within the body of the widget.
  • To update the text content of the “TF Bookings” tiddler, we use $action-setfield… NOT $action-listops which incorrectly resulted in the text value being stored as a space-separated, bracketed list rather than individual lines of text (this is where the erroneous square brackets came from!)
  • The $action-setfield also sets type="text/plain" so that the text contents of the “TF Bookings” tiddler can be displayed as regular text without being “wikified”.
  • The $action-setfield also sets tags="events" so that the events listed in the “TF Bookings” tiddler can be selected for display in the TiddlyTools/Calendar.
  • The $button also invokes an $action-deletefield widget to reset the booking-by, start-date, and end-date input fields. Note that no $tiddler parameter is specified for this widget, so that it defaults to the currentTiddler, which is where your inputs have been stored. This is why we used the variable=none in the enclosing $list widget above.

Finally, in order for your “TF Bookings” entries to appear in the TiddlyTools Calendar, you will need to ensure that you have used the Calendar Settings popup to select the “TF Bookings” tiddler in the “Events and Timelines” section.

That should do it. Let me know how it goes…

enjoy,
-e

2 Likes

As always @EricShulman you have provided a solution that works perfectly and a really useful explanation of the code steps. This really helps users like myself to understand the nuances of Tiddlywiki. I just love what can be done with this application.

For your information, I am using the latest TiddlyTools add-ons and have a much better understand the workings of the calendar set-up following you help with another topic.

Your help is always much appreciated. Thank you.

Regards, Rob