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

md-checks optionLabelPath appears dysfunctional #120

Closed
joshpfosi opened this issue May 25, 2015 · 3 comments
Closed

md-checks optionLabelPath appears dysfunctional #120

joshpfosi opened this issue May 25, 2015 · 3 comments

Comments

@joshpfosi
Copy link

I am using this component as

      {{md-checks
        selection=selectedLessons
        content=lessons
        optionValuePath="content"
        optionLabelPath="content.title"
        disabled=school.isLaunched}}

and the optionLabelPath is being completely ignored. The relevant lesson model is:

import DS from 'ember-data';

export default DS.Model.extend({
  title:             DS.attr('string')
});
@joshpfosi
Copy link
Author

I solved this by changing optionValuePath to "content.content". This is b/c in

     // addon/components/selectable-item-group.js
      if (valuePath && labelPath) {
        return Ember.A(
          map(content, el => {
            return {value: get(el, valuePath), label: get(el, labelPath)};
          })
        );
      } else {
        return Ember.A(
          map(content, el => {
            return {value: el, label: el};
          })
        );
      }

if valuePath is not set, the labelPath is ignored. I think a second clause should be added to the conditional, namely:

else if (labelPath) {
   return Ember.A(
      map(content, el => { 
        return { value: el, label: get(el, labelPath) };
      });
   );
}

or this requirement could be documented! Sorry for the confusion!

@mike-north
Copy link
Owner

@joshpfosi with your example model, there's an implicit id attribute. I'd expect you to use this as your valuePath, and title as your labelPath

      {{md-checks
        selection=selectedLessons
        content=lessons
        optionValuePath="content.id"
        optionLabelPath="content.title"
        disabled=school.isLaunched}}

We're aiming for alignment with Ember.Select, which takes the same parameters. If you find a situation where Ember.Select works and {{md-checks}} does not, please let me know and I'll look into it

@joshpfosi
Copy link
Author

I see. That makes sense. Thanks for the clarification :)

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

No branches or pull requests

2 participants