Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iobserve-ui-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iobserve-ui
iobserve-ui-frontend
Commits
d5a94d8c
Commit
d5a94d8c
authored
8 years ago
by
Mathis Neumann
Browse files
Options
Downloads
Patches
Plain Diff
extend serializer to support websocket responses
parent
6f7627c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/serializers/application.js
+30
-1
30 additions, 1 deletion
app/serializers/application.js
with
30 additions
and
1 deletion
app/serializers/application.js
+
30
−
1
View file @
d5a94d8c
import
JSONSerializer
from
'
ember-data/serializers/json
'
;
import
JSONSerializer
from
'
ember-data/serializers/json
'
;
/**
* Serializer used for any backend interaction.
* Used by Ember Data for rest interactions as well as by the changelog stream
*
* @class ApplicationSerializer
* @extends DS.JSONSerializer
*/
export
default
JSONSerializer
.
extend
({
export
default
JSONSerializer
.
extend
({
serialize
:
function
(
record
,
options
)
{
/**
* Enhances the compatibility with the RESTAdapter
* automatic detection of id and type does not work,
* type property inside data json is not what Ember expects
*
* @param {Model} Model the class of the ember model used for record creation
* @param {Object} data raw object parsed from JSON API responses
* @return {[type]} normalized record payload data (not yet a record instance)
*/
normalize
(
Model
,
data
){
const
normalized
=
this
.
_super
.
apply
(
this
,
arguments
);
normalized
.
id
=
data
.
id
;
normalized
.
type
=
data
.
type
;
return
normalized
;
},
/**
* overwrites the default json serialisation such that serialised records always contain the id
*
* @param {Model} record the record from the Ember Data store
* @param {Object} options serialisation options
* @return {Object} a serialized version (plain JS object) of the record
*/
serialize
(
record
,
options
)
{
options
=
options
||
{};
options
=
options
||
{};
options
.
includeId
=
true
;
options
.
includeId
=
true
;
return
this
.
_super
.
call
(
this
,
record
,
options
);
// Get default serialization
return
this
.
_super
.
call
(
this
,
record
,
options
);
// Get default serialization
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment