Skip to content

Commit

Permalink
ui: Show planning series update method in save modal
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Feb 9, 2024
1 parent 5f3f76d commit 8fa2b8e
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 114 deletions.
16 changes: 1 addition & 15 deletions client/actions/events/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,21 +558,7 @@ const save = (original, updates) => (

return promise.then((originalEvent) => {
const originalItem = eventUtils.modifyForServer(cloneDeep(originalEvent), true);

// clone the updates as we're going to modify it
let eventUpdates = eventUtils.modifyForServer(
cloneDeep(updates),
true
);

originalItem.location = originalItem.location ? [originalItem.location] : null;

// remove all properties starting with _
// and updates that are the same as original
eventUpdates = pickBy(eventUpdates, (v, k) => (
(k === TO_BE_CONFIRMED_FIELD || k === '_planning_item' || !k.startsWith('_')) &&
!isEqual(eventUpdates[k], originalItem[k])
));
const eventUpdates = eventUtils.getEventDiff(originalItem, updates);

if (get(originalItem, 'lock_action') === EVENTS.ITEM_ACTIONS.EDIT_EVENT.lock_action &&
!isTemporaryId(originalItem._id)
Expand Down
3 changes: 2 additions & 1 deletion client/api/editor/item.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {cloneDeep} from 'lodash';
import {EDITOR_TYPE, IEditorAPI} from '../../interfaces';
import {planningApi} from '../../superdeskApi';

Expand All @@ -24,7 +25,7 @@ export function getItemInstance(type: EDITOR_TYPE): IEditorAPI['item'] {

return Object.keys(plans)
.filter((planId) => plans[planId].event_item === eventId)
.map((planId) => plans[planId]);
.map((planId) => cloneDeep(plans[planId]));
}

return {
Expand Down
3 changes: 3 additions & 0 deletions client/api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function create(updates: Partial<IEventItem>): Promise<Array<IEventItem>> {
internal_note: coverage.planning.internal_note,
})),
})),
update_method: updates.update_method?.value ?? updates.update_method
})
.then((response) => {
const events = modifySaveResponseForClient(response);
Expand Down Expand Up @@ -174,6 +175,7 @@ function update(original: IEventItem, updates: Partial<IEventItem>): Promise<Arr
associated_plannings: undefined,
embedded_planning: updates.associated_plannings.map((planning) => ({
planning_id: planning._id.startsWith(TEMP_ID_PREFIX) ? undefined : planning._id,
update_method: planning.update_method,
coverages: planning.coverages.map((coverage) => ({
coverage_id: coverage.coverage_id,
g2_content_type: coverage.planning.g2_content_type,
Expand All @@ -188,6 +190,7 @@ function update(original: IEventItem, updates: Partial<IEventItem>): Promise<Arr
internal_note: coverage.planning.internal_note,
})),
})),
update_method: updates.update_method?.value ?? updates.update_method ?? original.update_method
})
.then((response) => {
const events = modifySaveResponseForClient(response);
Expand Down
Loading

0 comments on commit 8fa2b8e

Please sign in to comment.