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

Update Column.js to support parent #348

Merged

Conversation

alexander-alvarez
Copy link
Collaborator

No description provided.

@offirgolan
Copy link
Collaborator

@alexander-alvarez what is the reason behind this PR?

@alexander-alvarez
Copy link
Collaborator Author

if you're doing data manipulation / formatting it's nice to have a reference to the parent column while you're in the subColumn -- I'm adding these at instantiation, so it's nbd, but seemed logical that if we have the relationship one way, we'd have it the other way -- like ember-data inverses

@@ -333,7 +342,7 @@ export default class Column extends Ember.Object.extend({

let { subColumns } = options;

subColumns = emberArray(makeArray(subColumns).map((sc) => new Column(sc)));
subColumns = emberArray(makeArray(subColumns).map((sc) => merge(sc, { parent: this })).map((sc) => new Column(sc)));
subColumns.setEach('_group', this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alexander-alvarez the parent is already being set here. Maybe we can just make this public API?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lol...
the. next. line.
and I didn't even see it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would vote for making it public.
what would we want to call it:
parent?
parentColumn?
group?

Copy link
Collaborator

Choose a reason for hiding this comment

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

LOL its all good. I think parent works okay. Make sure you change the rest of _group to parent. I think it's referenced in a couple places.

}).readOnly(),

isDropTarget: computed(function() {
let column = this.get('column');
/*
A column is a valid drop target only if its in the same group
*/
return column.get('droppable') && column.get('_group') === sourceColumn.get('_group');
return column.get('droppable') && column.get('dragColumnGroup') === sourceColumn.get('dragColumnGroup');
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alexander-alvarez 'dragColumnGroup' should be 'parent' for both here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's the same thing.
I was going off of the comment: A column is a valid drop target only if its in the same group, so decided to use the variable that had the word group in it, instead of parent.

dragColumnGroup is derived from parent, so if parent's are equal, then the dragColumnGroup will be equal, and if no parents are defined:
null === null will be truthy just as
this.get('table.columns') === this.get('table.columns') is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right but the dragColumnGroup exists on the column component not the column instance. You are currently always comparing undefined to undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup... I'm going to show myself the door... so off these days man...

Copy link
Collaborator

Choose a reason for hiding this comment

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

LOL its all good! I got you 😄

dragColumnGroup does not exist on the column class.
@offirgolan
Copy link
Collaborator

offirgolan commented Mar 1, 2017

Looks good to me! Thanks for seeing this through! I'll make a patch release a little later today 😸

@offirgolan offirgolan merged commit 248a06f into adopted-ember-addons:master Mar 1, 2017
@alexander-alvarez alexander-alvarez deleted the parent-col-ref branch March 1, 2017 21:43
@offirgolan
Copy link
Collaborator

@alexander-alvarez v1.8.4 released.

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