mirror of
https://github.com/flarum/core.git
synced 2025-08-01 14:10:37 +02:00
Upgrade to JSON-API RC3 + latest version of tobscure/json-api
Note: npm source for ember-json-api changed to a fork, but I still had to apply a custom change to get polymorphic relationships to work (see https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import DS from 'ember-data';
|
||||
|
||||
export default DS.Model.extend({
|
||||
type: DS.attr('string'),
|
||||
content: DS.attr('string'),
|
||||
contentType: DS.attr('string'),
|
||||
content: DS.attr(),
|
||||
time: DS.attr('date'),
|
||||
|
||||
user: DS.belongsTo('user'),
|
||||
|
@@ -47,10 +47,14 @@ export default DS.Model.extend(HasItemLists, {
|
||||
// post-stream object, we're only interested in obtaining a list of IDs, so
|
||||
// we make it a string and then split it by comma. Instead, we'll put a
|
||||
// relationship on `loadedPosts`.
|
||||
posts: DS.attr('string'),
|
||||
postIds: Ember.computed('posts', function() {
|
||||
var posts = this.get('posts') || '';
|
||||
return posts.split(',');
|
||||
// posts: DS.attr('string'),
|
||||
posts: DS.hasMany('post', {async: true}),
|
||||
postIds: Ember.computed(function() {
|
||||
var ids = [];
|
||||
this.get('data.posts').forEach(function(post) {
|
||||
ids.push(post.id);
|
||||
});
|
||||
return ids;
|
||||
}),
|
||||
loadedPosts: DS.hasMany('post'),
|
||||
relevantPosts: DS.hasMany('post'),
|
||||
|
@@ -182,7 +182,7 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
|
||||
if (post) {
|
||||
item.setProperties({
|
||||
content: post,
|
||||
component: 'discussion/post-'+post.get('type')
|
||||
component: 'discussion/post-'+post.get('contentType')
|
||||
});
|
||||
}
|
||||
return item;
|
||||
|
@@ -7,8 +7,8 @@ export default DS.Model.extend({
|
||||
|
||||
time: DS.attr('date'),
|
||||
user: DS.belongsTo('user'),
|
||||
type: DS.attr('string'),
|
||||
content: DS.attr('string'),
|
||||
contentType: DS.attr('string'),
|
||||
content: DS.attr(),
|
||||
contentHtml: DS.attr('string'),
|
||||
|
||||
editTime: DS.attr('date'),
|
||||
|
Reference in New Issue
Block a user