Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/blueprints/*/files/**/*.js
41 changes: 39 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,47 @@ module.exports = {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
}
},
overrides: [
// node files
{
files: [
'ember-cli-build.js',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'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
})
}
]
};
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
/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
7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
.bowerrc
.editorconfig
.ember-cli
.gitignore
.eslintrc.js
.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
43 changes: 24 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
---
sudo: required
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"

sudo: false
dist: trusty

addons:
chrome: stable

cache:
yarn: true
directories:
- $HOME/.cache # includes bowers cache

env:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- 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
Expand All @@ -28,16 +37,12 @@ matrix:
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- yarn global add bower
- bower --version

install:
- yarn install --no-lock-file
- bower install
before_script:
- "sudo chown root /opt/google/chrome/chrome-sandbox"
- "sudo chmod 4755 /opt/google/chrome/chrome-sandbox"
- 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".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ Use this action to update your `results` array.

This is fired when the `esc` key is pressed.
Use this action handle a clear of the search, ie clear results array and search term.

## License

This project is licensed under the [MIT License](LICENSE.md).
38 changes: 22 additions & 16 deletions addon/components/autocomplete-input.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import Ember from 'ember';
import { notEmpty } from '@ember/object/computed';
import Component from '@ember/component';
import { observer, computed } from '@ember/object';
import layout from '../templates/components/autocomplete-input';
import KeyboardNavMixin from 'ember-cli-keyboard-nav/mixins/keyboard-nav';

const { Component, computed, observer } = Ember;

export default Component.extend(KeyboardNavMixin, {

layout,

// Hooks

init() {
this._super(...arguments);

if (!this.get('results')) {
this.set('results', []);
}
},

didInsertElement() {
this.bindKeys(this.$('input[type="text"]'));
this.set('lastTerm', this.get('term'));
},

// Attributes

name: '',
Expand All @@ -16,8 +31,6 @@ export default Component.extend(KeyboardNavMixin, {

resultValue: 'value',

results: [],

highlightedResultIndex: -1,

term: '',
Expand All @@ -34,21 +47,14 @@ export default Component.extend(KeyboardNavMixin, {
return this.get('results')[this.get('highlightedResultIndex')];
}),

hasResults: computed.notEmpty("results"),
hasResults: notEmpty("results"),

// Observers

termDidChange: observer('term', function() {
this.send('updateTerm', this.get('term'));
}),

// Hooks

didInsertElement() {
this.bindKeys(this.$('input[type="text"]'));
this.set('lastTerm', this.get('term'));
},

// Keyboard Nav actions

onEnterPress() {
Expand Down Expand Up @@ -94,18 +100,18 @@ export default Component.extend(KeyboardNavMixin, {

actions: {
selectResult(result) {
this.sendAction('selectResult', result);
this.get('selectResult')(result);
},

updateTerm(term) {
if (term !== this.get('lastTerm')) {
this.set('lastTerm', term);
this.sendAction('updateTerm', term);
this.get('updateTerm')(term);
}
},

clearSearch() {
this.sendAction("clearSearch");
this.get("clearSearch")();
}
}

Expand Down
7 changes: 3 additions & 4 deletions addon/components/autocomplete-result-item.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Ember from 'ember';
import Component from '@ember/component';
import { computed } from '@ember/object';
import layout from '../templates/components/autocomplete-result-item';

const { Component, computed } = Ember;

export default Component.extend({

layout,
Expand Down Expand Up @@ -49,7 +48,7 @@ export default Component.extend({

actions: {
selectResult(value) {
this.attrs.selectResult(value);
this.get('selectResult')(value);
}
}

Expand Down
Loading