-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- needs-async and needs-async-state contextual provider component - find-all helper - find-record helper - belongs-to helper - has-many helper
- Loading branch information
Showing
36 changed files
with
420 additions
and
12,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
module.exports = { | ||
globals: { | ||
server: true, | ||
}, | ||
root: true, | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Component from '@ember/component'; | ||
import layout from '../templates/components/needs-async-state'; | ||
|
||
export default Component.extend({ | ||
layout, | ||
tagName: '' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Component from '@ember/component'; | ||
import layout from '../templates/components/needs-async'; | ||
|
||
export default Component.extend({ | ||
layout, | ||
tagName: '', | ||
|
||
needs: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Helper from '@ember/component/helper'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default Helper.extend({ | ||
belongsToTask: task(function * (model, relationship) { | ||
return yield model.belongsTo(relationship).load(); | ||
}), | ||
compute([model, relationship/*, ...rest*/]/*, hash*/) { | ||
// TODO: better error handling | ||
if(!model || !model.belongsTo || !relationship) { | ||
return null; | ||
} | ||
return this.belongsToTask.perform(model, relationship); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Helper from '@ember/component/helper'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default Helper.extend({ | ||
store: service(), | ||
findAllTask: task(function * (modelType) { | ||
return yield this.store.findAll(modelType); | ||
}), | ||
compute([modelType/*, ...rest*/]/*, hash*/) { | ||
return this.findAllTask.perform(modelType); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Helper from '@ember/component/helper'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default Helper.extend({ | ||
store: service(), | ||
findRecordTask: task(function * (modelType, id) { | ||
return yield this.store.findRecord(modelType, id); | ||
}), | ||
compute([modelType, id/*, ...rest*/]/*, hash*/) { | ||
if(!id) return null; | ||
return this.findRecordTask.perform(modelType, id); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Helper from '@ember/component/helper'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default Helper.extend({ | ||
hasManyTask: task(function * (model, relationship) { | ||
return yield model.hasMany(relationship).load(); | ||
}), | ||
compute([model, relationship/*, ...rest*/]/*, hash*/) { | ||
// TODO: better error handling | ||
if(!model || !model.hasMany || !relationship) { | ||
return null; | ||
} | ||
return this.hasManyTask.perform(model, relationship); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{#if (get this.taskInstance state)}} | ||
{{yield (get this.taskInstance state)}} | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{yield (hash | ||
taskInstance=this.needs | ||
loading=(component "needs-async-state" state="isRunning" taskInstance=this.needs) | ||
loaded=(component "needs-async-state" state="value" taskInstance=this.needs) | ||
error=(component "needs-async-state" state="error" taskInstance=this.needs) | ||
)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-needs-async/components/needs-async-state'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-needs-async/components/needs-async'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, belongsTo } from 'ember-needs-async/helpers/belongs-to'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, findAll } from 'ember-needs-async/helpers/find-all'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, findRecord } from 'ember-needs-async/helpers/find-record'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default, hasMany } from 'ember-needs-async/helpers/has-many'; |
Oops, something went wrong.