-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UI] add selectable tags- and search-dropdown #3565
Conversation
this adds a `saveTiddler` attribute to factory.js if it's present it's used as a tiddler title where all the inputs/changes made by the user get stored this can be used for selecting dropdown-entries that are filterable by an input field the entries should be sorted by the `saveTiddler` and the original tiddler (`<$edit-text tiddler="originaltiddler" .../>`) can be updated with the selected dropdown-entry which will be shown within the input, without changing the filtering of the dropdown-items
Hi @BurningTreeC this is intriguing, but I'm not sure I fully understand. Can you post a more complete example? |
@Jermolene - I've updated the first comment with the additions made |
we could refactor the logic for dropdown-selection into a macro, so that we can reuse it for the search-dropdown, fieldname-dropdown etc |
do you have a minimal-test-case? |
@pmario - this is a current prerelease with my additions from this PR: http://selectabledropdowninput.tiddlyspot.com
|
Great stuff! .... As you wrote, it would be cool to have it for the search input. Users would love this! |
thanks @pmario , for the tags and search dropdowns, we have to take into account that we can add tabs within the dropdowns with different filterings the select-logic by up/down needs the filters that are used within the current open dropdown tab I think therefor we should put the filters (the tags and search dropdowns have two different filters for non-system and system) for the dropdown lists into a field somewhere. Then I can make the macro look up for the filters in those fields |
refactored the dropdown-selector logic into a `selectable-dropdown-input` macro
lets us define the state for a tabs-list explicitely, useful for selectable-dropdown-inputs, knowing the state tiddler from outside
\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate,retain) | ||
\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate,retain,explicitState) | ||
<$set name="qualifiedState" value=<<qualify "$state$">>> | ||
<$set name="tabsState" filter="[<__explicitState__>minlength[1]] ~[<qualifiedState>]"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a workaround so that I know the state tiddler
the tabs macro simply uses a title without qualifying when explicitState is present
but a way to access a qualified state from outside the scope would be more elegant
<$keyboard key="((input-down))" actions="""<$macrocall $name="select-dropdown-actions" beforeafter="after" reverse="" editTiddler=<<__editTiddler__>> saveTiddler=<<__saveTiddler__>> refreshTiddler=<<__refreshTiddler__>> filter1={{{ [<__filterTiddler__>get[dropdown-filter-1]] }}} filter2={{{ [<__filterTiddler__>get[dropdown-filter-2]] }}} filterMinLength="$filterMinLength$"/>"""> | ||
<$keyboard key="((input-up))" actions="""<$macrocall $name="select-dropdown-actions" beforeafter="before" reverse="reverse[]" editTiddler=<<__editTiddler__>> saveTiddler=<<__saveTiddler__>> refreshTiddler=<<__refreshTiddler__>> filter1={{{ [<__filterTiddler__>get[dropdown-filter-1]] }}} filter2={{{ [<__filterTiddler__>get[dropdown-filter-2]] }}} filterMinLength="$filterMinLength$"/>"""> | ||
<$keyboard key="((input-accept))" actions="""<$macrocall $name="accept-input-actions" editTiddler=<<__editTiddler__>> acceptActions={{{ [<__filterTiddler__>get[accept-actions]] }}}/>"""> | ||
<$keyboard key="((input-clear))" actions="""<$macrocall $name="clear-input-actions" editTiddler=<<__editTiddler__>> saveTiddler=<<__saveTiddler__>> refreshTiddler=<<__refreshTiddler__>> clearEmptyActions={{{ [<__filterTiddler__>get[clear-input-empty-actions]] }}} refreshQualifier=<<__refreshQualifier__>>/>"""> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would make sense to add some keyboard widgets here that can be configured with more actions without having to edit this tiddler
<$action-setfield $tiddler=<<__refreshTiddler__>> text=<<__refreshQualifier__>>/> | ||
<$action-deletetiddler $tiddler=<<__editTiddler__>>/> | ||
<$action-deletetiddler $tiddler=<<__saveTiddler__>>/> | ||
<$action-setfield $tiddler=<<__refreshTiddler__>> text=""/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this sequence seems strange but is needed somehow like that if we don't come up with a different refresh mechanism
<$action-setfield $tiddler=<<__editTiddler__>> text=<<nextTag>>/> | ||
<$action-deletetiddler $tiddler=<<__refreshTiddler__>>/> | ||
<$action-setfield $tiddler=<<__refreshTiddler__>> refresh-qualifier={{{ [[$(tv-refresh-input-qualifier)$]] }}}/> | ||
<$action-setfield $tiddler=<<__refreshTiddler__>> text=<<nextTag>>/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theses two lines make the input field refresh after its text has changed through up/down-arrow selections
Hi @Jermolene , are you interested in this? You proposed a refresh-mechanism for inputs that restores focus. Have you got an idea how to do that? |
Very interested in gaining the functionality, but keen to do it right...
Tentatively, one possible approach is to have a tiddler called |
btw the other thing that we should be able to fix in this way is maintaining the focus/selection while editing fields within the current tiddler... |
Ah yes, that should be done while we're on it. So, if I understand it right, the widgets should define a unique ID and populate |
That's the idea, yes. There are quite a few points to think about:
|
That's the reason why I originally made the
Yes, that's important. I was thinking about an
I couldn't find another way ... a tiddler can have many inputs that edit the same tiddler and the same field/index and they could all be siblings, so a state qualifier using a combination of the editTitle, editField/Index and stateQualifier wouldn't be unique. I came up with adding the index of the widget within the array of its siblings to that identifier which is working well:
But possibly I'm just not seeing the best approach |
I see now that my approach would need to register each widget within an array of its parent widget |
I think this would be a "killer" ;) |
Hi @Jermolene , this PR has merge conflicts that could be resolved. Do you have an idea/a roadmap how to go on with this? The unique widget id seems to be difficult to solve, this mechanism here uses a different approach, demanding that a given condition must be true in order for the input to refresh its text and focus again. the condition is that a given |
It's tricky. The problem is that if we merge this then we're committed to supporting this technique forever, and that might limit our ability to address related problems in the future. On balance, experimental stuff like is good to chew over as a plugin. Do you think that's feasible, if we added enough core hooks? |
@Jermolene , I know I'm absolutely not convinced that this should be the mechanism to stick with forvever. but it's a mechanism that works, now. the plugin proposal would be just right. about the hooks ... would you just add a hook in the factory.js refresh method, passing the widget? |
Yes I think that's reasonable. |
ok, there are more points where factory.js would need to be extended, see https://github.com/Jermolene/TiddlyWiki5/pull/3565/files#diff-2788afb61c207f85b558b296f643ce5e what's the best way to do it? |
Too many hooks at random places will also box us in too far. It may be reasonable to look at subclassing the existing factory.js, I'm not sure how much hackery would be needed to make that possible though... |
ok, I'll make a minimal working concept and see where subclasses make sense without overdoing it |
Hi @Jermolene, in order to make this functionality work using hooks and a startup module, I need 3 hooks, one in the refresh method, one in the execute method and one in the getEditInfo method of factory.js it's really simple to extend it this way, I think it'd be a great hackability extension |
nah, this was exaggerated, I only need 1 hook in the refresh method |
opening this again for discussion - I got a version working that uses the new widget-subclassing here: http://selectable-inputs.tiddlyspot.com/ |
closing in favor of a new attempt |
this adds a
saveTiddler
attribute to factory.jsif it's present it's used as a tiddler title where all the inputs/changes made by the user get stored
this can be used for selecting dropdown-entries that are filterable by an input field
the entries should be sorted by the
saveTiddler
and the original tiddler (<$edit-text tiddler="originaltiddler" .../>
) can be updated with the selected dropdown-entry which will be shown within the input, without changing the filtering of the dropdown-itemsUpdate: to the above mentioned changes, this adds:
a
refreshTiddler
attribute to factory.js (refreshes the input-text when that tiddler changes, sets it to whatever is within theeditTiddler
)a full-featured keyboard-selectable tags-dropdown
up/down selects a dropdown tag
enter adds the selected tag
escape clears the input field, or - if empty - cancels editing the tiddler