-
Notifications
You must be signed in to change notification settings - Fork 25
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
dropdown_pills added to elements; #1284
Conversation
Now filter[in] supports multi select with values as pills; Config inside in-filter: "dropdown_pills": true
The duplicate code issue has been resolved in 20d3b48 Inside the filter.mjs I add pills to be dropdown_pills, ie. true || false/undefined if (filter.dropdown || filter.dropdown_pills) {
const dropdown = mapp.ui.elements.dropdown({
pills: filter.dropdown_pills,
multi: true,
placeholder: 'Select Multiple',
entries: filter[filter.type].map(val => ({
title: val,
option: val,
selected: chkSet.has(val)
})),
callback: async (e, options) => {
if (!options.length) {
// Remove empty array filter.
delete layer.filter.current[filter.field]
} else {
// Set filter values array from options.
Object.assign(layer.filter.current, {
[filter.field]: {
[filter.type]: options
}
})
}
applyFilter(layer)
}
})
return mapp.utils.html.node`<div class="filter">${dropdown}`
} In the dropdown.mjs I add the pills element to params.pills if true. params.pills &&= mapp.ui.elements.pills({
pills: [...params.selectedTitles],
addCallback: (val, _pills) => {
params.callback?.(null, [..._pills]);
},
removeCallback: (val, _pills) => {
// deselect value in the list
const item = ul.find(li => li.title === val);
item.classList.remove('selected');
params.selectedTitles.delete(item.title);
params.selectedOptions.delete(item.dataset.option);
params.callback?.(null, [..._pills]);
}
}); A dropdown pills by definition will always be a dropdown multi and I made the mistake of introducing the dropdown_multi element before thinking this through which leaves us now with this technical debt module. export default (params) => {
console.warn('mapp.ui.elements.dropdown should be used with the multi flag')
params.multi = true
return mapp.ui.elements.dropdown(params)
} |
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 works as expected for me.
Should these work when an I put an example in The pills dont get removed when you click the I assume because |
Quality Gate passedIssues Measures |
@AlexanderGeere this should now be fixed by adding and checking on the data-value attribute instead of the title. |
Now filter[in] supports multi select with values as pills; Config inside in-filter: "dropdown_pills": true