cms/app-client/app/serializers/theme.js
author ymh <ymh.work@gmail.com>
Fri, 16 Dec 2016 17:43:07 +0100
changeset 474 245b4df137d3
parent 319 78990a8a069b
permissions -rw-r--r--
Correct themes visualisation

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,
            'meta': payload['meta']
        };
    }

});