Ghost/ghost/admin/mirage/serializers/label.js
Kevin Ansfield 72590083f3 Added ability to bulk delete members by label or status (#1883)
refs https://github.com/TryGhost/Team/issues/585
requires https://github.com/TryGhost/Ghost/pull/12082

When a label or status filter is selected on the members screen show a "Delete selected" option in the actions dropdown. Bulk deleted members will _not_ have any subscription data modified in Stripe, if a member should be deleted and have their subscription cancelled it's necessary to do that on a per-member basis.

- updated bulk delete handling to match API
- added link to bulk delete confirmation modal in members actions dropdown (only shown when label, status, or search is used)
- updated testing framework for members
  - added label factory for easier test setup
  - updated `GET /members` and `DEL /members` endpoints to work with label filters
  - updated test selectors for easier reference in tests
2021-04-08 12:06:27 +01:00

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