in fronts-client/src/util/form.ts [139:194]
height: strToInt(article.imageCutoutSrcHeight),
origin: article.imageCutoutSrcOrigin,
thumb: article.imageCutoutSrc,
},
slideshow: slideshow.concat(slideshowBackfill),
overrideArticleMainMedia: article.overrideArticleMainMedia || false,
sportScore: article.sportScore || '',
showMainVideo: !!article.showMainVideo,
coverCardImageReplace: article.coverCardImageReplace || false,
coverCardMobileImage: article.coverCardMobileImage || {},
coverCardTabletImage: article.coverCardTabletImage || {},
isImmersive: article.isImmersive || false,
}
: undefined;
};
// Because multiple fields in the article meta map to
// a single field in the form, we need a way to map between
// the two models to figure out which meta fields should be
// added to the form output when a form field is dirtied.
const formToMetaFieldMap: { [fieldName: string]: string } = {
imageSrc: 'primaryImage',
imageSrcThumb: 'primaryImage',
imageSrcWidth: 'primaryImage',
imageSrcHeight: 'primaryImage',
imageSrcOrigin: 'primaryImage',
imageCutoutSrc: 'cutoutImage',
imageCutoutSrcWidth: 'cutoutImage',
imageCutoutSrcHeight: 'cutoutImage',
imageCutoutSrcOrigin: 'cutoutImage',
};
export const getImageMetaFromValidationResponse = (image: ImageData) => ({
imageSrc: image.src,
imageSrcThumb: image.thumb,
imageSrcWidth: intToStr(image.width),
imageSrcHeight: intToStr(image.height),
imageSrcOrigin: image.origin,
});
export const getCardMetaFromFormValues = (
state: State,
id: string,
values: CardFormData,
): CardMeta => {
const primaryImage = values.primaryImage || {};
const cutoutImage = values.cutoutImage || {};
const slideshow = compact(values.slideshow as ImageData[]).map(
(image: ImageData) => ({
...image,
width: intToStr(image.width),
height: intToStr(image.height),
}),
);
const getStringField = (field: string) => {
if (field.length === 0) {