kalcifer / ember-dragula

Simple drag and drop with dragula and ember
MIT License
27 stars 17 forks source link

Nested containers, improved actions #5

Closed oskarrough closed 9 years ago

oskarrough commented 9 years ago

Hi, a few things to note here.

Nested dragging

You can now explicitly pass down the parent drake to child components, which allows for much more happy nesting. It looks like this:

{{#ember-dragula config=dragulaconfig over="dragOverColumn" out="dragOutColumn" drop="droppedNote" as |emberDragula|}}
{{#ember-dragula-container drake=emberDragula.drake}}

This works because the ember-dragula template has {{yield this}}.

Actions and events

Events are now subscribed to with 'enabledEvents: ['drag', 'drop', ……]' and you map them like the example above. I think this is clearer compared to having all events inside a single dragulaEvent.

Linting

I changed to use .on() so we don't overwrite default hooks etc.

Also, since this changes (breaking) how actions work, it should be documented and a major version push I guess. Hope you can use it!

pksjce commented 9 years ago

I was wondering how you were accessing this.drake inside ember-dragula-container. I did not know I can pass component instances directly. This PR was a good learning for me! I am using this addon in production in a console. So I'll just check if it is working fine there and merge this. My main concern is does the ember-dragula template get added to the host application automatically? I'm slightly confused about how to define templates in addons. Anyway I will test this out today and update you.

oskarrough commented 9 years ago

It does get added automatically. Everything inside your ember addon's 'app' folder will be merged with the host application. But great! Let me know if there's anything.

I generally don't think it's a good idea to pass component instances around but passing the drake property should be fine.