Skip to content

Conversation

@mgd722
Copy link
Contributor

@mgd722 mgd722 commented Dec 4, 2020

Consider the following:

healthcareOptions = [
    new ChoiceOption({
        label: 'family: $7,100 annually (deducted from pay)',
        value: {amount: 7100, type: 'deducted'}
    }),
    new ChoiceOption({
        label: 'family: $7,100 annually (contributed out of pocket)',
        value: {amount: 7100, type: 'contributed'}
    }),
    new ChoiceOption({
        label: 'individual: $3,550 annually (deducted from pay)',
        value: {amount: 3500, type: 'deducted'}
    }),
    new ChoiceOption({
        label: 'individual: $3,550 annually (contributed out of pocket)',
        value: {amount: 3500, type: 'contributed'}
    }),
    new ChoiceOption({
        label: 'none',
        value: {amount: 0, type: null}
    })
]

Here the choices are more than just numbers, they also need some metadata to go along with the number. The above implementation already works because Vue isn't strict in its validation of props, but it kicks up a prop validation warning with each question answered. This change formally supports setting an Object as a ChoiceOption.value.

The only downside I could see to this is that if you pass only a Object value and not a label to a ChoiceOption, the Object would be printed as a string. This is an atypical case and is easily solved by providing a label.

This PR also removes a stray console.log that got left behind in a previous PR.

@mgd722
Copy link
Contributor Author

mgd722 commented Dec 14, 2020

Any thoughts here? It's not a big change and I've been using it for the past 10 days without issue. If you cherry-picked my changes and merged them in somewhere else I'll close my PR.

@spinn spinn merged commit 8dbf2fc into ditdot-dev:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants