mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
30 lines
823 B
JavaScript
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;
|
||
|
}
|
||
|
}
|