28 lines
1.1 KiB
CoffeeScript
28 lines
1.1 KiB
CoffeeScript
import { ActiveModelSerializer } from 'active-model-adapter'
|
|
export default ActiveModelSerializer.extend #DS.EmbeddedRecordsMixin,
|
|
|
|
#serializeIntoHash: ->
|
|
# debugger
|
|
# @_super arguments...
|
|
# debugger
|
|
# 3
|
|
|
|
#payloadKeyFromModelName: (modelName) ->
|
|
# key = @_super(modelName)
|
|
# key.replace(/\//g, '.')
|
|
|
|
serializeBelongsTo: (snapshot, json, relationship)->
|
|
payloadKey = @keyForRelationship(relationship.key, 'belongsTo', 'serialize')
|
|
belongsToId = snapshot.record.get("#{relationship.key}.id")
|
|
belongsToId?= null
|
|
json[payloadKey] = belongsToId
|
|
# the super method looks up the inverse (workflow_step_definition) in stead of the constraint_workflow_step_definition id
|
|
#debugger
|
|
#@_super(arguments...)
|
|
|
|
# If a relationship has configuration serialize: 'ids' then add the association's ids
|
|
# comments: DS.hasMany('comment', serialize: 'ids')
|
|
serializeHasMany: (snapshot, json, relationship)->
|
|
if relationship.options.serialize is 'ids'
|
|
json["#{relationship.key.singularize()}_ids"] = Ember.get(snapshot.record, relationship.key).mapBy('id').toArray()
|