cms/app-client/app/serializers/theme.js
author ymh <ymh.work@gmail.com>
Tue, 04 Oct 2016 11:58:39 +0200
changeset 319 78990a8a069b
parent 179 9b703ece424f
child 474 245b4df137d3
permissions -rw-r--r--
Work on front and back integration, correct the expected data format

import DS from 'ember-data';

export default DS.JSONSerializer.extend({

    normalizeResponse: function(store, primaryModelClass, payload) {
        var data = [];
        var themes = payload['themes'];
        Object.keys(themes).forEach(function(key) {
            data.push({
                'id': key,
                'type': 'theme',
                'attributes': {
                    'label': themes[key].label,
                    'count': themes[key].count
                }
            });
        });
        return {
            'data': data
        };
    }

});