Here is an example,

In this case you provide the macro with a date fieldname (default date) and 
is stores the selected value in html to an "-input" field, it retains this 
to keep the date displayed, however simultaneously it generates a date 
serial number (at noon on the selected day).

Now the date serial can be used with sort, days operator, view widget and 
more.

\define pick-date(fieldname:"date")
<$set name=date-fieldname value="$fieldname$">
<$set name=date-input-field value={{{ [<date-fieldname>addsuffix[-input]] 
}}} >
<$edit-text field=<<date-input-field>> type="date" 
inputActions=<<set-date-actions>>/>
</$set></$set>
\end
\define set-date-actions()
<$action-setfield $tiddler=<<currentTiddler>> $field=<<date-fieldname>> 
$value={{{ 
[all[current]get<date-input-field>split[-]join[]addsuffix[120000000]] }}}/>
\end
<<pick-date journal-date>> <$view field="journal-date" 
format="relativedate"/>


Here is a pick time macro;

\define pick-time(fieldname:"time")
<$set name=date-fieldname value="$fieldname$">
<$set name=date-input-field value={{{ [<date-fieldname>addsuffix[-input]] 
}}} >
<$edit-text field=<<date-input-field>> type="time" 
inputActions=<<set-date-actions>>/>
</$set></$set>
\end
\define set-date-actions()
<$action-setfield $tiddler=<<currentTiddler>> $field=<<date-fieldname>> 
$value={{{ [all[current]get<date-input-field>] }}}/>
\end
<<pick-time journal-time>> <$view field="journal-time" format="time"/>

Tones

On Monday, 26 April 2021 at 11:09:14 UTC+10 TW Tones wrote:

> Here is a really simple answer;
>
> <$edit-text field="journal-date" type=date/>
>
> However I would be inclined to save this to a temporary field and using 
> the edit text widget actions convert it to a tiddlywiki date serial number.
>
> Regards
> Tones
>
> On Monday, 26 April 2021 at 00:44:53 UTC+10 si wrote:
>
>> I am trying to re-create the functionality from Projectify 
>> <https://projectify.wiki/> which enables you to set a due date for a 
>> task by clicking a tag-pill style button. See here 
>> <https://projectify.wiki/demo.html#Buy%20milk> for a demo - you can 
>> click schedule and then the text of the button gets replaced with the 
>> scheduled date.
>>
>> I have my code for the button (see below), but I need to create a tiddler 
>> containing a date-picker to be activated by the reveal widget. 
>> Unfortunately it seems that the date-picker plugin 
>> <http://kixam.github.io/TW5-datePicker/> doesn't work like this - it 
>> creates an icon for you to click, rather than just displaying the 
>> date-picker to use where you wish.
>>
>> I also tried copying some of the code from Projectify, but I ran into at 
>> least two problems:
>>
>>    - The date-picker widget that Projectify has no way to change the 
>>    field that stores the date, and I need to create two separate buttons 
>> (for 
>>    due-date and threshold).
>>    - The styling got all messed up (see image).
>>
>> [image: date-picker .png]
>>
>> Anyway I'm wondering if there is any easy way to get what I want, or am I 
>> destined to have to play with javascript and css?
>>
>> <hr>
>>
>> *Here is the code I used for the button, if relevant. I was hoping to 
>> just be able to add a date-picker to the tiddler 
>> $:/si/entry-method/date-picker and then just transclude it in:*
>>
>> \define due-button()
>>     <span class="tc-tag-list-item">
>>         <$vars stateTiddler=<<qualify "$:/state/due-button">> 
>> tag-value={{{ [{!!due}!is[blank]else[Schedule]] }}}>
>>             <$macrocall $name="tag-pill-body" tag=<<tag-value>> 
>> colour="#eee8d5" palette={{$:/palette}} element-tag="""$button""" 
>> element-attributes="""popup=<<stateTiddler>> tag='span'"""/>   
>>             <$reveal state=<<stateTiddler>> type="popup" position="below" 
>> animate="no" class="tc-drop-down">
>>                 {{||$:/si/entry-method/date-picker}}
>>             </$reveal>
>>         </$vars>
>>     </span>
>> \end
>> <$list filter="[all[current]tag[Task]]">
>> <<due-button>>
>> </$list>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6a935f9f-2257-4f03-973a-97046f98a1afn%40googlegroups.com.

Reply via email to