Last active
February 24, 2019 05:36
-
-
Save sukima/3aad195eb666af34166d9689418731d5 to your computer and use it in GitHub Desktop.
Removing rouge links.related
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
export default { | |
data: [ | |
{ | |
id: '1', | |
type: 'app-page-people', | |
attributes: { | |
'sort-order': 34 | |
}, | |
relationships: { | |
page: { | |
links: { | |
self: 'https://example.com/api/self/1', | |
related: 'https://example.com/api/related/1' | |
}, | |
data: { | |
id: '1', | |
type: 'pages' | |
} | |
} | |
} | |
} | |
] | |
}; |
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
export default { | |
data: [ | |
{ | |
id: '1', | |
type: 'pages', | |
attributes: { | |
name: 'Page 1' | |
} | |
}, | |
{ | |
id: '2', | |
type: 'pages', | |
attributes: { | |
name: 'Page 2' | |
} | |
} | |
] | |
}; |
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
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
import { belongsTo, hasMany } from 'ember-data/relationships'; | |
export default Model.extend({ | |
sortOrder: attr('number'), | |
page: belongsTo('page', { async: false }) | |
}); |
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
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
import { belongsTo, hasMany } from 'ember-data/relationships'; | |
export default Model.extend({ | |
name: attr('string') | |
}); |
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
import Ember from 'ember'; | |
import PagesData from '../data/pages'; | |
import AppPagePeopleData from '../data/app-page-people'; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
this.store.pushPayload(PagesData); | |
}, | |
model() { | |
this.store.pushPayload(AppPagePeopleData); | |
let ids = AppPagePeopleData.data.mapBy('id'); | |
return this.store.peekAll('app-page-person') | |
.filter(model => ids.includes(model.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
import ApplicationSerializer from './application'; | |
export default ApplicationSerializer.extend({ | |
extractRelationship(relationshipHash) { | |
if (relationshipHash.links) { | |
// Comment next line to see the error | |
delete relationshipHash.links.related; | |
} | |
return this._super(...arguments); | |
} | |
}); |
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
import JSONAPISerializer from 'ember-data/serializers/json-api'; | |
export default JSONAPISerializer; |
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
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment