Ghost/ghost/admin/app/transforms/members-segment-string.js
Kevin Ansfield da49dc4922 Added default newsletter recipients setting (#1946)
refs https://github.com/TryGhost/Team/issues/496
reqs https://github.com/TryGhost/Ghost/pull/12925

The publish menu was meant to default to matching post visibility but that wasn't working consistently and didn't make sense for sites which don't email every post to their members.

A "Default newsletter recipients" option has been added to the "Email newsletter" settings screen and the publish menu updated to reflect the option. The free/paid toggles in the publish menu have also been swapped out for a multi-select style component that will cater to more complex member segmentation.
2021-05-07 10:02:19 +01:00

30 lines
800 B
JavaScript

import Transform from '@ember-data/serializer/transform';
// the members segment supports `'none'` and `'all'` as special-case options
// but that doesn't map well for options in our token select inputs so we
// expand/convert them here to make usage elsewhere easier
export default class MembersSegmentStringTransform extends Transform {
deserialize(serialized) {
if (serialized === 'all') {
return 'status:free,status:-free';
}
if (serialized === 'none') {
return null;
}
return serialized;
}
serialize(deserialized) {
if (deserialized === 'status:free,status:-free') {
return 'all';
}
if (!deserialized) {
return 'none';
}
return deserialized;
}
}