1
0
mirror of https://github.com/flarum/core.git synced 2025-08-09 01:46:35 +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:
Toby Zerner
2015-03-24 15:04:24 +10:30
parent 536281e273
commit a62e04f956
36 changed files with 342 additions and 503 deletions

View File

@@ -18,12 +18,8 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
// `content` property to the content of the item in the post-stream object.
// This happens to be our post model!
post: Ember.computed.alias('content'),
decodedContent: Ember.computed('post.content', function() {
return JSON.parse(this.get('post.content'));
}),
oldTitle: Ember.computed.alias('decodedContent.0'),
newTitle: Ember.computed.alias('decodedContent.1'),
oldTitle: Ember.computed.alias('post.content.0'),
newTitle: Ember.computed.alias('post.content.1'),
populateControls: function(items) {
this.addActionItem(items, 'delete', 'Delete', 'times', 'post.canDelete');

View File

@@ -6,7 +6,7 @@ export default Ember.Component.extend(FadeIn, {
layoutName: 'components/user/activity-item',
tagName: 'li',
componentName: Ember.computed('activity.type', function() {
return 'user/activity-'+this.get('activity.type');
componentName: Ember.computed('activity.contentType', function() {
return 'user/activity-'+this.get('activity.contentType');
})
});

View File

@@ -6,7 +6,7 @@ export default {
initialize: function(container) {
var store = container.lookup('store:main');
if (!Ember.isEmpty(FLARUM_DATA)) {
store.pushPayload(FLARUM_DATA);
store.pushPayload({included: FLARUM_DATA});
}
if (!Ember.isEmpty(FLARUM_SESSION)) {
FLARUM_SESSION.user = store.getById('user', FLARUM_SESSION.userId);

View File

@@ -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'),

View File

@@ -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'),

View File

@@ -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;

View File

@@ -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'),

View File

@@ -34,7 +34,7 @@
"ember-data": "1.0.0-beta.15",
"ember-dynamic-component": "0.0.4",
"ember-export-application-global": "^1.0.2",
"ember-json-api": "^0.3.0",
"ember-json-api": "eneuhauser/ember-json-api",
"express": "^4.8.5",
"glob": "^4.0.5"
}