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

Selection #13

Merged
merged 14 commits into from
Jun 1, 2017
Merged

Conversation

sglanzer-deprecated
Copy link
Contributor

@sglanzer-deprecated sglanzer-deprecated commented Apr 24, 2017

This project uses semver, please check the scope of this pr:

  • #none# - documentation fixes and/or test additions
  • #patch# - backwards-compatible bug fix
  • #minor# - adding functionality in a backwards-compatible manner
  • #major# - incompatible API change

Adds a selection column to the table if selection bindings are provided. Follows the same selection conventions as ember-frost-list, but limits the selectable area to the selection column cell (represented with a checkbox)

image

CHANGELOG

  • Added a selection cell with the ability to handle range selection

@sglanzer-deprecated
Copy link
Contributor Author

Realized with a clearer brain this morning that the interface can be simplified a bit, I'll make the updates shortly

@sglanzer-deprecated sglanzer-deprecated changed the title Quick and dirty selection Selection May 26, 2017
@sglanzer-deprecated
Copy link
Contributor Author

Raised an issue to move the selection util into a common package

}
return '@index'
},

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming this can be done with getDefaultProps().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent point sir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm actually, I'll have to make sure I can safely use itemKey instead of the targeted eachItemKey, it may bleed across purposes

// == DOM Events ============================================================

click (event) {
this.onSelectionChange([])
Copy link
Contributor

Choose a reason for hiding this comment

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

Ember.A()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't really matter, but doesn't hurt, so sure

Copy link
Contributor

@quincyle quincyle May 26, 2017

Choose a reason for hiding this comment

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

Potential benefits if consumer disables prototype extension. :)

PropTypes.EmberObject,
PropTypes.object
])
})
},

getDefaultProps () {
return {
// options
columns: [],
items: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

Ember.A()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're internal and functional so probably not necessary, but again doesn't hurt so sure

this._super(...arguments)
const itemKey = this.get('itemKey')
if (itemKey) {
this.set('_itemComparator', function (lhs, rhs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

_itemComparator will never be set if itemKey is missing. I saw itemKey is assigned a default value inside frost-table-row. It's probably better to move the logic here and pass itemKey down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope - different purposes - the CP in the body is to handle optimization of the each if no itemKey is provided. This case is present only for selection/expansion, so it's actually two different cases

Copy link
Contributor

@quincyle quincyle May 26, 2017

Choose a reason for hiding this comment

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

Sure. I see they serve a different purpose. but itemKey should be a required prop (It's an option in prop type now). Otherwise, if consumer invokes the component without itemKey, and then try to select an item. It apparent will fail since _select action in frost-table and _isItemSelected cp in frost-table-row will try to run _itemComparator but no such method exists. And if itemKey is required, there's no need for providing a default in frost-table-row.

I could be missing something obvious, but I'm not following why the existence of _itemComparator is bound to itemKey. And actually, I feel itemKey should be optional and default to id if the consumer doesn't provide in frost-table. And the {{#each }} in frost-table-body can pick up the itemKey we passed in as its loop key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Selection isn't required for a table (or list) so an itemKey isn't required.
  • id is not a guaranteed property
  • _itemComparator is bound to itemKey because we want to compare for equality using that key most of the time instead of attempting a strict comparison on the object itself

@coveralls
Copy link

coveralls commented Jun 1, 2017

Coverage Status

Changes Unknown when pulling 6cba76e on sglanzer:master into ** on ciena-frost:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 9f92943 on sglanzer:master into ** on ciena-frost:master**.

@sglanzer-deprecated
Copy link
Contributor Author

sglanzer-deprecated commented Jun 1, 2017

Approved

Approved with PullApprove

@sglanzer-deprecated sglanzer-deprecated merged commit 8789d26 into ciena-frost:master Jun 1, 2017
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.

None yet

4 participants