Ghost/ghost/admin/app/transforms/product-benefits.js
Rishabh 03b37b05fb Fixed product benefits not loaded on memberships settings
refs https://github.com/TryGhost/Team/issues/905

- benefits were overridden with a secondary products query for segment select which did not have proper includes
- fixes includes for products when fetched for member segments
2021-09-17 12:41:56 +05:30

33 lines
886 B
JavaScript

import ProductBenefitItem from '../models/product-benefit-item';
import Transform from '@ember-data/serializer/transform';
import {A as emberA, isArray as isEmberArray} from '@ember/array';
export default Transform.extend({
deserialize(serialized) {
let benefitsItems, benefitsArray;
benefitsArray = serialized || [];
benefitsItems = benefitsArray.map((itemDetails) => {
return ProductBenefitItem.create(itemDetails);
});
return emberA(benefitsItems);
},
serialize(deserialized) {
let benefitsArray;
if (isEmberArray(deserialized)) {
benefitsArray = deserialized.map((item) => {
let name = item.get('name').trim();
return {name};
}).compact();
} else {
benefitsArray = [];
}
return benefitsArray;
}
});