Skip to content

Commit

Permalink
Merge pull request #123 from kongregate/update-ember-cli
Browse files Browse the repository at this point in the history
Update ember cli and convert to DDAU
  • Loading branch information
dgavey authored Aug 30, 2018
2 parents b2cfa19 + 2e31f4c commit 3b7caa3
Show file tree
Hide file tree
Showing 76 changed files with 492 additions and 494 deletions.
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

14 changes: 0 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
42 changes: 38 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
parser: 'babel-eslint',
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
"no-console": 0
}
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
}
]
};
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
Expand All @@ -14,5 +14,13 @@
/coverage/*
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try

.idea/
yarn.lock
8 changes: 6 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
.bowerrc
.editorconfig
.ember-cli
.gitignore
.eslintrc.js
.jshintrc
.gitignore
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
46 changes: 23 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
---
language: node_js
node_js:
- "6"
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "4"

dist: trusty
sudo: false
dist: trusty

addons:
firefox: latest-esr
chrome: stable

cache:
directories:
- node_modules
yarn: true

env:
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-beta

before_install:
- npm config set spin false
- npm install -g bower
- bower --version
- npm install -g bower phantomjs-prebuilt
- phantomjs --version
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # wait for xfvb to start up
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

install:
- npm install
- bower install
- yarn install --no-lockfile --non-interactive

script:
- yarn lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016
Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ At the start of the drag a property of isDraggingObject will be set to true on t
Optionally you can set actions on the component to get notified on drag start and end. The content value of the current object being dragged is sent as the parameter.

```handlebars
{{#draggable-object content=this dragStartAction='myStartAction' dragEndAction='myEndAction'}}
{{#draggable-object content=this dragStartAction=(action 'myStartAction') dragEndAction=(action 'myEndAction')}}
{{name}}
{{/draggable-object}}
```
Expand Down Expand Up @@ -133,15 +133,15 @@ The action is called with two arguments:
```handlebars
... your regular template code
{{#draggable-object-target action="increaseRating" amount="5"}}
{{#draggable-object-target action=(action 'increaseRating') amount="5"}}
Drag here to increase rating
{{/draggable-object-target}}
```

Optionally you can also get an action fired when an object is being dragged over and out of the drop target. No parameter is currently sent with these actions.

```handlebars
{{#draggable-object-target action="increaseRating" amount="5" dragOverAction='myOverAction' dragOutAction='myDragOutAction'}}
{{#draggable-object-target action=(action 'increaseRating') amount="5" dragOverAction=(action 'myOverAction') dragOutAction=(action 'myDragOutAction')}}
Drag here to increase rating
{{/draggable-object-target}}
```
Expand Down Expand Up @@ -183,7 +183,7 @@ This only applies if you use the sort capabilities, regular dragging is not vers
An Example:

```handlebars
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction='sortEndAction' enableSort=true useSwap=true inPlace=false sortingScope="sortingGroup"}}
{{#sortable-objects sortableObjectList=sortableObjectList sortEndAction=(action 'sortEndAction') enableSort=true useSwap=true inPlace=false sortingScope="sortingGroup"}}
{{#each sortableObjectList as |item|}}
{{#draggable-object content=item isSortable=true sortingScope="sortingGroup"}}
{{item.name}}
Expand All @@ -209,21 +209,21 @@ When writing tests, there is a `drag` helper you can use to help facilitate drag
#### drag helper
- As of v0.4.5 you can use this helper in integration tests without booting up the entire application.
- Is an async aware helper ( use await to wait for drop to finish )
- Can be used to test sortable elements as well as plain draggable
- Has one argument
- the drag start selector
- Can be used to test sortable elements as well as plain draggable
- Has one argument
- the drag start selector
- Example: ```.draggable-object.drag-handle```
- And many options:
- **dragStartOptions**
- options for the drag-start event
- can be used to set a cursor position for the drag start event
- Example: ```{ pageX: 0, pageY: 0 }```
- can be used to set a cursor position for the drag start event
- Example: ```{ pageX: 0, pageY: 0 }```
- **dragOverMoves**
- array of moves used to simulate dragging over.
- array of moves used to simulate dragging over.
- it's an array of [position, selector] arrays where the selector is optional
and will use the 'drop' selector ( from drop options ) as default
- Example:
```js
```js
[
[{ clientX: 1, clientY: 500 }, '.drag-move-div'],
[{ clientX: 1, clientY: 600 }, '.drag-move-div']
Expand All @@ -232,7 +232,7 @@ When writing tests, there is a `drag` helper you can use to help facilitate drag
[
[{ clientX: 1, clientY: 500 }], // moves drop selector
[{ clientX: 1, clientY: 600 }] // moves drop selector
]
]
```
- **dropEndOptions**
- options for the drag-end event
Expand All @@ -247,19 +247,19 @@ When writing tests, there is a `drag` helper you can use to help facilitate drag
// check on state of things
}
```
- **beforeDrop**
- **beforeDrop**
- a function to call before drop action is called
- gives you a chance to inspect state before dropping
- Example:
```js
beforeDrop() {
// check on state of things
// check on state of things
}
```
- **drop**
- selector for the element to drop onto
- Example: ```.drop-target-div```

- You import it like this:

```js
Expand All @@ -270,38 +270,38 @@ import { drag } from 'your-app/tests/helpers/drag-drop';
You can pass the CSS selector for the `draggable-object-target` and pass a `beforeDrop` callback.

Async test Example:

```js
test('drag stuff', async function(assert) {
// setup component
await drag('.draggable-object.drag-handle', {
drop: '.draggable-container .draggable-object-target:nth-child(1)'
});
assert.equal("things happened", true);
});
```

In this example,
- we're dragging the draggable-object element with CSS selector `.draggable-object.drag-handle`
- and dropping on a draggable-object-target with the CSS selector `draggable-object-target:eq(1)`.
- we're dragging the draggable-object element with CSS selector `.draggable-object.drag-handle`
- and dropping on a draggable-object-target with the CSS selector `draggable-object-target:eq(1)`.
For a fuller example check out this integration [test](https://github.com/mharris717/ember-drag-drop/blob/master/tests/integration/components/sortable-objects-test.js#L63)
**Note #1**
In order to use async / await style tests you need to tell ember-cli-babel to include a polyfill
in [ember-cli-build.js](https://github.com/mharris717/ember-drag-drop/blob/master/ember-cli-build.js#L7)
**Note #2**
You don't have to use the new async/await helper.
**Note #2**
You don't have to use the new async/await helper.
You can simply keep using the older drag helper ( which makes your tests far slower because you have to start the application for each test. )
This older helper only has one option ( beforeDrop )

```javascript
// old drag helper
import { drag } from 'your-app/tests/helpers/ember-drag-drop';
```

### TODO

Theses additions to sort are still incoming:
Expand Down Expand Up @@ -375,11 +375,11 @@ app/templates/posts.hbs
{{/each}}
<h3>Possible Statuses</h3>
{{#draggable-object-target action="setStatus" status="Ready to Publish"}}
{{#draggable-object-target action=(action 'setStatus') status="Ready to Publish"}}
Ready to Publish
{{/draggable-object-target}}
{{#draggable-object-target action="setStatus" status="Needs Revision"}}
{{#draggable-object-target action=(action 'setStatus') status="Needs Revision"}}
Needs Revision
{{/draggable-object-target}}
```
14 changes: 9 additions & 5 deletions addon/components/draggable-object-target.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Ember from 'ember';
import Component from '@ember/component';
import Droppable from 'ember-drag-drop/mixins/droppable';

export default Ember.Component.extend(Droppable, {
export default Component.extend(Droppable, {
classNameBindings: ['overrideClass'],
overrideClass: 'draggable-object-target',
isOver: false,

handlePayload(payload, event) {
let obj = this.get('coordinator').getObject(payload,{target: this});
this.sendAction('action',obj,{target: this, event: event});
this.get('action')(obj, { target: this, event: event });
},

handleDrop(event) {
Expand All @@ -28,13 +28,17 @@ export default Ember.Component.extend(Droppable, {
if (!this.get('isOver')) {
//only send once per hover event
this.set('isOver', true);
this.sendAction('dragOverAction', event);
if(this.get('dragOverAction')) {
this.get('dragOverAction')(event);
}
}
},

handleDragOut(event) {
this.set('isOver', false);
this.sendAction('dragOutAction', event);
if(this.get('dragOutAction')) {
this.get('dragOutAction')(event);
}
},

click(e) {
Expand Down
Loading

0 comments on commit 3b7caa3

Please sign in to comment.