Skip to content

Commit

Permalink
broken template in ember 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
toranb committed Apr 15, 2018
1 parent 905eced commit 427e805
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/models/role.js
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()
});
22 changes: 22 additions & 0 deletions app/models/user.js
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
}
});
16 changes: 16 additions & 0 deletions app/routes/application.js
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;
}
});
6 changes: 2 additions & 4 deletions app/templates/application.hbs
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}}

0 comments on commit 427e805

Please sign in to comment.