cms/app-client/app/serializers/discourse.js
author ymh <ymh.work@gmail.com>
Fri, 15 Sep 2017 14:54:08 +0200
changeset 548 f624c19354e4
parent 465 9df336529b2f
permissions -rw-r--r--
to version 0.23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
465
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import DS from 'ember-data';
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
export default DS.JSONSerializer.extend({
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
  normalizeResponse: function (store, primaryModelClass, payload) {
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
    var data = [];
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
    var discourses = payload['discourses'];
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
    Object.keys(discourses).forEach(function (key) {
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
      data.push({
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
        'id': key,
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
        'type': 'discourse',
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
        'attributes': {
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
          'label': discourses[key].label,
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
          'count': discourses[key].count
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
        }
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
      });
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    });
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    return {
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
      'data': data
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    };
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
  }
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
});