-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { attr, Model } from 'ember-cli-simple-store/model'; | ||
|
||
export default Model.extend({ | ||
name: attr() | ||
}); |
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,22 @@ | ||
import { computed } from '@ember/object'; | ||
import { alias } from '@ember/object/computed'; | ||
import { inject as service } from '@ember/service'; | ||
import { attr, Model } from 'ember-cli-simple-store/model'; | ||
|
||
export default Model.extend({ | ||
name: attr(), | ||
simpleStore: service(), | ||
role: alias('belongs_to.firstObject'), | ||
belongs_to: computed(function() { | ||
let user_id = this.get('id'); | ||
let store = this.get('simpleStore'); | ||
let filter = function(role) { | ||
let users = role.get('users'); | ||
return users.indexOf(user_id) > -1; | ||
}; | ||
return store.find('role', filter); | ||
}), | ||
change_role() { | ||
//this seems to be the problem in ember 3.1 | ||
} | ||
}); |
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,16 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
simpleStore: service(), | ||
model() { | ||
const id = 1; | ||
const simpleStore = this.get('simpleStore'); | ||
simpleStore.push('user', {id: id, name: 'toran'}); | ||
|
||
// this next line breaks because of ... | ||
// https://github.com/toranb/ember-cli-simple-store/blob/master/addon/store.js#L253 | ||
const model = simpleStore.find('user', id); | ||
return model; | ||
} | ||
}); |
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,5 +1,3 @@ | ||
{{!-- The following component displays Ember's default welcome message. --}} | ||
{{welcome-page}} | ||
{{!-- Feel free to remove this! --}} | ||
<h1>HERE!</h1> | ||
|
||
{{outlet}} | ||
{{outlet}} |