author | ymh <ymh.work@gmail.com> |
Fri, 16 Dec 2016 17:43:07 +0100 | |
changeset 474 | 245b4df137d3 |
parent 319 | 78990a8a069b |
permissions | -rw-r--r-- |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
1 |
import DS from 'ember-data'; |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
2 |
|
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
3 |
export default DS.JSONSerializer.extend({ |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
4 |
|
179
9b703ece424f
Discourse and theme linting
Chloe Laisne <chloe.laisne@gmail.com>
parents:
176
diff
changeset
|
5 |
normalizeResponse: function(store, primaryModelClass, payload) { |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
6 |
var data = []; |
319
78990a8a069b
Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents:
179
diff
changeset
|
7 |
var themes = payload['themes']; |
78990a8a069b
Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents:
179
diff
changeset
|
8 |
Object.keys(themes).forEach(function(key) { |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
9 |
data.push({ |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
10 |
'id': key, |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
11 |
'type': 'theme', |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
12 |
'attributes': { |
319
78990a8a069b
Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents:
179
diff
changeset
|
13 |
'label': themes[key].label, |
78990a8a069b
Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents:
179
diff
changeset
|
14 |
'count': themes[key].count |
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
15 |
} |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
16 |
}); |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
17 |
}); |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
18 |
return { |
474 | 19 |
'data': data, |
20 |
'meta': payload['meta'] |
|
176
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
21 |
}; |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
22 |
} |
d1baf7ccecc8
Add `thematiques` components
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
23 |
|
319
78990a8a069b
Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents:
179
diff
changeset
|
24 |
}); |