mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
19 lines
620 B
JavaScript
19 lines
620 B
JavaScript
|
import BaseSerializer from './application';
|
||
|
|
||
|
export default BaseSerializer.extend({
|
||
|
// make the label.count.members value dynamic
|
||
|
serialize(labelModelOrCollection, request) {
|
||
|
let updateMemberCount = (label) => {
|
||
|
label.update('count', {members: label.memberIds.length});
|
||
|
};
|
||
|
|
||
|
if (this.isModel(labelModelOrCollection)) {
|
||
|
updateMemberCount(labelModelOrCollection);
|
||
|
} else {
|
||
|
labelModelOrCollection.models.forEach(updateMemberCount);
|
||
|
}
|
||
|
|
||
|
return BaseSerializer.prototype.serialize.call(this, labelModelOrCollection, request);
|
||
|
}
|
||
|
});
|