diff --git a/client/components/planning-editor-standalone/authoring-storage-http.ts b/client/components/planning-editor-standalone/authoring-storage-http.ts index 96fc1ea1a..cfc50600d 100644 --- a/client/components/planning-editor-standalone/authoring-storage-http.ts +++ b/client/components/planning-editor-standalone/authoring-storage-http.ts @@ -5,6 +5,7 @@ import {superdeskApi} from '../../superdeskApi'; import {getProfile} from './profile'; import {omitFields} from './utils'; import {AutoSavePlanningItem, NoAutoSavePlanningItem} from './authoring-autosave'; +import {planningUtils} from '../../utils'; const getAutosavedPlanningItem = (id: IPlanningItem['_id']): Promise => { return new Promise((resolve) => { @@ -30,7 +31,10 @@ export const authoringStoragePlanningItemHttp: IAuthoringStorage path: `/planning/${id}`, }) ]).then(([autosaved, saved]) => { - return {autosaved, saved}; + return { + autosaved: autosaved == null ? null : planningUtils.modifyForClient(autosaved), + saved: planningUtils.modifyForClient(saved), + }; }); }, @@ -47,7 +51,12 @@ export const authoringStoragePlanningItemHttp: IAuthoringStorage return httpRequestJsonLocal({ method: 'PATCH', path: `/planning/${original._id}`, - payload: omitFields(generatePatch(original, current)), + payload: omitFields( + generatePatch( + planningUtils.modifyForServer(original), + planningUtils.modifyForServer(current), + ), + ), headers: { 'If-Match': original._etag, }, diff --git a/client/utils/planning.tsx b/client/utils/planning.tsx index dd3b3528a..6f5266bb1 100644 --- a/client/utils/planning.tsx +++ b/client/utils/planning.tsx @@ -890,7 +890,7 @@ function getPlanningActionsForUiFrameworkMenu(data: IGetPlanningActionArgs): Arr return toUIFrameworkInterface(planningUtils.getPlanningActions(data)); } -export function modifyForClient(plan: Partial): Partial { +export function modifyForClient>(plan: T): T { sanitizeItemFields(plan); // The `_status` field is available when the item comes from a POST/PATCH request