Skip to content
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

Fixes button for multiple selections to behave correctly #1950

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/main/resources/default/taglib/t/lookupValues.html.pasta
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
<a class="btn btn-outline-secondary" id="@id-addon"><i class="fa-solid fa-bolt"></i></a>
</i:block>
<i:block name="script">
const helper = document.getElementById('___id-addon');
helper.addEventListener('click', function () {
new LookupTableInfo({
tableName: '___table',
labelFormat: '___values.getDisplay()',
codeCallback: function (code, name) {
autocomplete.addToken({value: code, text: name});
}
const helper = document.getElementById('___id-addon');
helper.addEventListener('click', function () {
new LookupTableInfo({
tableName: '___table',
labelFormat: '___values.getDisplay()',
codeCallback: function (code, name) {
if (!autocomplete.val().includes(code)) {
autocomplete.addToken({value: code, text: name});
} else {
autocomplete.select.removeTokenWithText(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I think the library may benefit from a removeTokenWithValue helper as this would be more robust than relying on unique display texts for each option (which most likely should be the case most of the time)

}
}
});
});
});
</i:block>
<i:for var="tuple"
type="Tuple"
Expand Down