Skip to content

Commit a2cce2b

Browse files
Update to ember 3.5.1.
1 parent 97ae759 commit a2cce2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+11150
-391
lines changed

.bowerrc

-4
This file was deleted.

.eslintignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# unconventional js
2+
/blueprints/*/files/
3+
/vendor/
4+
5+
# compiled output
6+
/dist/
7+
/tmp/
8+
9+
# dependencies
10+
/bower_components/
11+
/node_modules/
12+
13+
# misc
14+
/coverage/
15+
!.*
16+
17+
# ember-try
18+
/.node_modules.ember-try/
19+
/bower.json.ember-try
20+
/package.json.ember-try

.eslintrc.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 2017,
5+
sourceType: 'module'
6+
},
7+
plugins: [
8+
'ember'
9+
],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:ember/recommended'
13+
],
14+
env: {
15+
browser: true
16+
},
17+
rules: {
18+
},
19+
overrides: [
20+
// node files
21+
{
22+
files: [
23+
'.eslintrc.js',
24+
'.template-lintrc.js',
25+
'ember-cli-build.js',
26+
'index.js',
27+
'testem.js',
28+
'blueprints/*/index.js',
29+
'config/**/*.js',
30+
'tests/dummy/config/**/*.js'
31+
],
32+
excludedFiles: [
33+
'addon/**',
34+
'addon-test-support/**',
35+
'app/**',
36+
'tests/dummy/app/**'
37+
],
38+
parserOptions: {
39+
sourceType: 'script',
40+
ecmaVersion: 2015
41+
},
42+
env: {
43+
browser: false,
44+
node: true
45+
},
46+
plugins: ['node'],
47+
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
48+
// add your custom rules and overrides for node files here
49+
})
50+
}
51+
]
52+
};

.gitignore

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
# See http://help.github.com/ignore-files/ for more about ignoring files.
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
22

33
# compiled output
4-
/dist
5-
/tmp
4+
/dist/
5+
/tmp/
66

77
# dependencies
8-
/node_modules
9-
/bower_components
8+
/bower_components/
9+
/node_modules/
1010

1111
# misc
1212
/.sass-cache
1313
/connect.lock
14-
/coverage/*
14+
/coverage/
1515
/libpeerconnection.log
1616
npm-debug.log
1717
testem.log
1818
.DS_Store
1919
/.idea/
2020
.node-version
21+
22+
/npm-debug.log*
23+
/testem.log
24+
/yarn-error.log
25+
26+
# ember-try
27+
/.node_modules.ember-try/
28+
/bower.json.ember-try
29+
/package.json.ember-try

.npmignore

+28-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
bower_components/
2-
tests/
3-
tmp/
4-
dist/
1+
# compiled output
2+
/dist/
3+
/tmp/
54

6-
.bowerrc
7-
.editorconfig
8-
.ember-cli
9-
.travis.yml
10-
.npmignore
11-
**/.gitkeep
12-
bower.json
13-
ember-cli-build.js
14-
Brocfile.js
15-
testem.json
5+
# dependencies
6+
/bower_components/
7+
8+
# misc
9+
/.bowerrc
10+
/.editorconfig
11+
/.ember-cli
12+
/.eslintignore
13+
/.eslintrc.js
14+
/.gitignore
15+
/.template-lintrc.js
16+
/.travis.yml
17+
/.watchmanconfig
18+
/bower.json
19+
/config/ember-try.js
20+
/ember-cli-build.js
21+
/testem.js
22+
/tests/
23+
/yarn.lock
24+
.gitkeep
25+
26+
# ember-try
27+
/.node_modules.ember-try/
28+
/bower.json.ember-try
29+
/package.json.ember-try

.template-lintrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
extends: 'recommended'
5+
};

.travis.yml

+37-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,54 @@
11
---
22
language: node_js
33
node_js:
4-
- "0.12"
4+
# we recommend testing addons with the same minimum supported node version as Ember CLI
5+
# so that your addon works for all apps
6+
- "6"
57

68
sudo: false
9+
dist: trusty
10+
11+
addons:
12+
chrome: stable
713

814
cache:
915
directories:
10-
- node_modules
16+
- $HOME/.npm
1117

1218
env:
13-
- EMBER_TRY_SCENARIO=ember-release
14-
- EMBER_TRY_SCENARIO=ember-beta
15-
- EMBER_TRY_SCENARIO=ember-canary
19+
global:
20+
# See https://git.io/vdao3 for details.
21+
- JOBS=1
1622

17-
matrix:
18-
fast_finish: true
23+
jobs:
24+
fail_fast: true
1925
allow_failures:
2026
- env: EMBER_TRY_SCENARIO=ember-canary
2127

22-
before_install:
23-
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
24-
- "npm config set spin false"
25-
- "npm install -g npm@^2"
28+
include:
29+
# runs linting and tests with current locked deps
30+
31+
- stage: "Tests"
32+
name: "Tests"
33+
script:
34+
- npm run lint:hbs
35+
- npm run lint:js
36+
- npm test
2637

27-
install:
28-
- npm install -g bower
29-
- npm install
30-
- bower install
38+
# we recommend new addons test the current and previous LTS
39+
# as well as latest stable release (bonus points to beta/canary)
40+
- stage: "Additional Tests"
41+
env: EMBER_TRY_SCENARIO=ember-lts-2.16
42+
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
43+
- env: EMBER_TRY_SCENARIO=ember-release
44+
- env: EMBER_TRY_SCENARIO=ember-beta
45+
- env: EMBER_TRY_SCENARIO=ember-canary
46+
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery
47+
48+
before_install:
49+
- npm config set spin false
50+
- npm install -g npm@4
51+
- npm --version
3152

3253
script:
33-
- ember try $EMBER_TRY_SCENARIO test
54+
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017
3+
Copyright (c) 2018
44

55
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:
66

README.md

+32-45
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,51 @@
1-
# ember-data-has-many-query
2-
[![Build Status](https://travis-ci.org/mdehoog/ember-data-has-many-query.svg?branch=master)](https://travis-ci.org/mdehoog/ember-data-has-many-query) [![Ember Observer Score](http://emberobserver.com/badges/ember-data-has-many-query.svg)](http://emberobserver.com/addons/ember-data-has-many-query)
1+
my-addon
2+
==============================================================================
33

4-
[Ember Data](https://github.com/emberjs/data)'s `DS.Store` supports querying top-level records using the
5-
[`query`](http://emberjs.com/api/data/classes/DS.Store.html#method_query) function. This provides support
6-
for things like pagination and searching.
4+
[Short description of the addon.]
75

8-
However, `DS.hasMany` and `DS.belongsTo` cannot be queried in the same way. This means pagination and searching are not
9-
supported with has-many/belongs-to relationships.
6+
Installation
7+
------------------------------------------------------------------------------
108

11-
This addon provides a way to query has-many and belongs-to relationships. Currently the `DS.RESTAdapter` and the
12-
`DS.JSONAPIAdapter` are supported.
9+
```
10+
ember install my-addon
11+
```
1312

14-
## Installation
1513

16-
`ember install ember-data-has-many-query`
14+
Usage
15+
------------------------------------------------------------------------------
1716

18-
## Usage
17+
[Longer description of how to use the addon in apps.]
1918

20-
Add the `RESTAdapterMixin` to your `DS.RESTAdapter` (or `DS.JSONAPIAdapter`) extension:
2119

22-
```javascript
23-
import HasManyQuery from 'ember-data-has-many-query';
20+
Contributing
21+
------------------------------------------------------------------------------
2422

25-
export default DS.RESTAdapter.extend(HasManyQuery.RESTAdapterMixin, {
26-
});
27-
```
23+
### Installation
2824

29-
Add the `ModelMixin` to any `DS.Model` extensions:
25+
* `git clone <repository-url>`
26+
* `cd my-addon`
27+
* `npm install`
3028

31-
```javascript
32-
import HasManyQuery from 'ember-data-has-many-query';
29+
### Linting
3330

34-
export default DS.Model.extend(HasManyQuery.ModelMixin, {
35-
});
36-
```
31+
* `npm run lint:hbs`
32+
* `npm run lint:js`
33+
* `npm run lint:js -- --fix`
3734

38-
Models with the mixin now support has-many/belongs-to queries:
35+
### Running tests
3936

40-
```javascript
41-
post.query('comments', { page: 1 });
42-
```
43-
44-
## Sticky `belongs-to`
37+
* `ember test` – Runs the test suite on the current Ember version
38+
* `ember test --server` – Runs the test suite in "watch mode"
39+
* `ember try:each` – Runs the test suite against multiple Ember versions
4540

46-
Ember Data 2.3.x and below: each has-many query calls `reload` on the relationship's `DS.ManyArray`. This means that all previously
47-
queried records are cleared from the array. If you are caching the records from each query separately
48-
(for example, in a separate array for an infinite scroll implementation), the inverse `belongs-to`
49-
relationship is also cleared on those cached records.
41+
### Running the dummy application
5042

51-
If you want to keep the associated belongs-to record after a new query, you can define the belongs-to
52-
attribute using `belongsToSticky`:
43+
* `ember serve`
44+
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
5345

54-
```javascript
55-
import HasManyQuery from 'ember-data-has-many-query';
46+
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
5647

57-
export default DS.Model.extend(HasManyQuery.ModelMixin, {
58-
post: HasManyQuery.belongsToSticky('post'),
59-
});
60-
```
48+
License
49+
------------------------------------------------------------------------------
6150

62-
This is a (pretty terrible) hack that caches the belongs-to record in a separate property, and when the
63-
record is cleared by another query call, any property `get`s will return the cached version instead. If
64-
anyone has ideas for better implementations, please let me know!
51+
This project is licensed under the [MIT License](LICENSE.md).

addon/belongs-to-sticky.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Ember from 'ember';
1+
import { computed } from '@ember/object';
22
import DS from 'ember-data';
3-
import {stickyPropertyName} from './property-names';
3+
import { stickyPropertyName } from './property-names';
44

55
var recordHasId = function (record) {
66
return record && record.get('id');
@@ -21,7 +21,7 @@ var belongsToSticky = function () {
2121
var computed = DS.belongsTo(...arguments);
2222
var meta = computed.meta();
2323
meta.sticky = true;
24-
return Ember.computed({
24+
return computed({
2525
get: function (key) {
2626
var value = computed._getter.call(this, ...arguments);
2727
if (recordHasId(value)) {

addon/mixins/model.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import Ember from 'ember';
1+
import { next } from '@ember/runloop';
2+
import { Promise } from 'rsvp';
3+
import Mixin from '@ember/object/mixin';
24
import DS from 'ember-data';
35
import {
46
queryParamPropertyName,
@@ -7,14 +9,14 @@ import {
79
ajaxOptionsPropertyName,
810
stickyPropertyName
911
} from '../property-names';
10-
import {recordHasId} from '../belongs-to-sticky';
12+
import { recordHasId } from '../belongs-to-sticky';
1113

1214
var queryId = 0;
1315

1416
/**
1517
* Mixin for DS.Model extensions.
1618
*/
17-
export default Ember.Mixin.create({
19+
export default Mixin.create({
1820
init() {
1921
this._super(...arguments);
2022

@@ -93,9 +95,9 @@ export default Ember.Mixin.create({
9395

9496
var self = this;
9597
var reference = isHasMany ? this.hasMany(propertyName) : this.belongsTo(propertyName);
96-
return new Ember.RSVP.Promise(function (resolve) {
98+
return new Promise(function (resolve) {
9799
//run.next, so that aborted promise gets rejected before starting another
98-
Ember.run.next(this, function () {
100+
next(this, function () {
99101
var isLoaded = reference.value() !== null;
100102
if (isLoaded || force) {
101103
resolve(reference.reload());

0 commit comments

Comments
 (0)