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

fix: [sc-24122] Input.ChoiceSet filtering not working with choices path #355

Merged
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
18 changes: 8 additions & 10 deletions lib/builders/Input.ChoiceSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ const { COLORS } = require('./../utils/color-reference')
const showWhen = prop => `${prop} ? parseTemplate(\`{{ \${${prop}} }}\`, { data }) === 'true' : true`

module.exports = function (definition, options) {
definition.choicesPath = definition.choicesPath
? `${definition.choicesPath}.map(r => { return { label: r.title, value: r.value, sublabel: r.subtitle } })`
: ''

const {
// inset,
isMultiSelect,
Expand Down Expand Up @@ -97,6 +93,8 @@ function select (div, definition) {
select
.addAttribute(':emit-value', true)
.addAttribute(':map-options', true)
.addAttribute('option-value', 'value')
.addAttribute(':option-label', choicesPath ? 'opt => opt.title || opt.label' : 'opt => opt.label')
.addAttribute(':dense', true)

const pathToOptions = choicesPath || `lists.${id}`
Expand Down Expand Up @@ -131,7 +129,7 @@ function select (div, definition) {
selectItem
.addChildTag('q-item-section')
.addChildTag('q-item-label')
.content('{{ props.opt.label }}')
.content(choicesPath ? '{{ props.opt.title || props.opt.label }}' : '{{ props.opt.label }}')

if (isMultiSelect) {
select.addAttribute('multiple', null)
Expand Down Expand Up @@ -195,7 +193,7 @@ function radioOrCheckbox (div, definition, selectionType) {

const itemLabel = itemSectionLabel
.addChildTag('q-item-label')
.content('{{ opt.label }}')
.content(choicesPath ? '{{ opt.title || opt.label }}' : '{{ opt.label }}')

const tooltipIcon = itemLabel
.addChildTag('q-icon')
Expand All @@ -210,18 +208,18 @@ function radioOrCheckbox (div, definition, selectionType) {
.addChildTag('q-item-label')
.addAttribute('caption', null)
.addAttribute('class', 'q-my-sm')
.addAttribute('v-if', 'Array.isArray(opt.sublabel)')
.addAttribute('v-if', choicesPath ? 'Array.isArray(opt.subtitle || opt.sublabel)' : 'Array.isArray(opt.sublabel)')
.addChildTag('div')
.addAttribute('v-for', '(sublabel, idx) in opt.sublabel')
.addAttribute('v-for', choicesPath ? '(sublabel, idx) in opt.subtitle || opt.sublabel' : '(sublabel, idx) in opt.sublabel')
.addAttribute(':key', 'idx')
.content('{{ sublabel }}')

itemSectionLabel
.addChildTag('q-item-label')
.addAttribute('caption', null)
.addAttribute('class', 'q-my-sm')
.addAttribute('v-if', 'typeof opt.sublabel === \'string\'')
.content('{{ opt.sublabel }}')
.addAttribute('v-if', choicesPath ? 'typeof opt.subtitle === \'string\' || typeof opt.sublabel === \'string\'' : 'typeof opt.sublabel === \'string\'')
.content(choicesPath ? '{{ opt.subtitle || opt.sublabel }}' : '{{ opt.sublabel }}')

// const itemSectionTooltip = item
// .addChildTag('q-item-section')
Expand Down