Ghost/ghost/admin/app/transforms/visibility-string.js
Rishabh 3c5e334041 Added ability to set post access to segments
refs https://github.com/TryGhost/Team/issues/801

- This reverts commit de560733c5
- brings back members segment select component to post access, which allows setting access to specific labels/products
- only works behind the alpha feature flag - `multipleProducts`
2021-06-28 17:46:24 +05:30

30 lines
823 B
JavaScript

import Transform from '@ember-data/serializer/transform';
// post visibility supports `'members'` and `'paid'` 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 VisibilityString extends Transform {
deserialize(serialized) {
if (serialized === 'members') {
return 'status:free,status:-free';
}
if (serialized === 'paid') {
return 'status:-free';
}
return serialized;
}
serialize(deserialized) {
if (deserialized === 'status:free,status:-free') {
return 'members';
}
if (deserialized === 'status:-free') {
return 'paid';
}
return deserialized;
}
}