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);
|
||
|
}
|
||
|
});
|