TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.02k stars 1.19k forks source link

Feature: Allowing the results of checkbox widgets to be stored in a list #1957

Closed felixhayashi closed 2 years ago

felixhayashi commented 9 years ago

At the moment, a checkbox can be used to toggle a field. It would be nice if the checkbox widget could operate in a "list" mode, where a check would add the value to a field list-style and an uncheck would remove the value from the list again.

So if e.g. checkbox A B and C are toggled and they operate in "list" mode and store their values in field X then field X would be: [[value of A]] [[value of B]] [[value of C]].

If checkbox B is unchecked the list will be [[value of A]] [[value of C]]

twMat commented 3 years ago

Bump. Currently, to accomplish the same thing with a button that also indicates checked vs nonchecked is a pretty complex story that involves double revealwidgets and actions and likely transcluded icons that must first be imported etc.

I would actually say that a checkbox to toggle items in a list could replace the need to use buttons in many cases. If one prefers the appearance of a regular button, this is possible by styling.

@Jermolene noted (early in the thread) that:

Good idea; it's quite a small change: the checkbox widget already has logic for adding and removing members of a list, but of course it's currently tied to using the "tags" field for the list.

saqimtiaz commented 3 years ago

@twMat In case it is useful, this is the pattern I often use for buttons used for toggling things, in this case a value in a list field:

<$button> <$transclude tiddler={{{ [[target]contains:myfield[done]then[$:/core/images/unfold-button]else[$:/core/images/fold-button]]} }}}/>
<$action-listops $tiddler="target" $field="myfield" $subfilter="+[toggle[done]]" />
</$button>

Regarding the OP of this issue, it is worth considering as well that there is now extensive support for using actions with the CheckboxWidget, and there may be better ways we can implement this.

twMat commented 3 years ago

@saqimtiaz - wonderful. I know that not everyone is fond of UTF-8 charcters but here's a variation of your nugget for a more typical checkbox.

<$button class="tc-btn-invisible">
<$text text={{{ [[target]contains:myfield[done]then[🗹]else[☐]] }}} />
<$action-listops $tiddler="target" $field="myfield" $subfilter="+[toggle[done]]" />
</$button>

Or ▲▼ for accordion.

(Now, where will I put this so I remember it when I need it...?)

[...] there may be better ways we can implement this.

Jeremy said it was a small matter so I just hope somone can do it. Checklists are probably a main application in tw...

Jermolene commented 2 years ago

Closed in #5613