Skip to content

Commit 8fa2b8e

Browse files
committed
ui: Show planning series update method in save modal
1 parent 5f3f76d commit 8fa2b8e

File tree

7 files changed

+309
-114
lines changed

7 files changed

+309
-114
lines changed

client/actions/events/api.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -558,21 +558,7 @@ const save = (original, updates) => (
558558

559559
return promise.then((originalEvent) => {
560560
const originalItem = eventUtils.modifyForServer(cloneDeep(originalEvent), true);
561-
562-
// clone the updates as we're going to modify it
563-
let eventUpdates = eventUtils.modifyForServer(
564-
cloneDeep(updates),
565-
true
566-
);
567-
568-
originalItem.location = originalItem.location ? [originalItem.location] : null;
569-
570-
// remove all properties starting with _
571-
// and updates that are the same as original
572-
eventUpdates = pickBy(eventUpdates, (v, k) => (
573-
(k === TO_BE_CONFIRMED_FIELD || k === '_planning_item' || !k.startsWith('_')) &&
574-
!isEqual(eventUpdates[k], originalItem[k])
575-
));
561+
const eventUpdates = eventUtils.getEventDiff(originalItem, updates);
576562

577563
if (get(originalItem, 'lock_action') === EVENTS.ITEM_ACTIONS.EDIT_EVENT.lock_action &&
578564
!isTemporaryId(originalItem._id)

client/api/editor/item.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {cloneDeep} from 'lodash';
12
import {EDITOR_TYPE, IEditorAPI} from '../../interfaces';
23
import {planningApi} from '../../superdeskApi';
34

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

2526
return Object.keys(plans)
2627
.filter((planId) => plans[planId].event_item === eventId)
27-
.map((planId) => plans[planId]);
28+
.map((planId) => cloneDeep(plans[planId]));
2829
}
2930

3031
return {

client/api/events.ts

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function create(updates: Partial<IEventItem>): Promise<Array<IEventItem>> {
144144
internal_note: coverage.planning.internal_note,
145145
})),
146146
})),
147+
update_method: updates.update_method?.value ?? updates.update_method
147148
})
148149
.then((response) => {
149150
const events = modifySaveResponseForClient(response);
@@ -174,6 +175,7 @@ function update(original: IEventItem, updates: Partial<IEventItem>): Promise<Arr
174175
associated_plannings: undefined,
175176
embedded_planning: updates.associated_plannings.map((planning) => ({
176177
planning_id: planning._id.startsWith(TEMP_ID_PREFIX) ? undefined : planning._id,
178+
update_method: planning.update_method,
177179
coverages: planning.coverages.map((coverage) => ({
178180
coverage_id: coverage.coverage_id,
179181
g2_content_type: coverage.planning.g2_content_type,
@@ -188,6 +190,7 @@ function update(original: IEventItem, updates: Partial<IEventItem>): Promise<Arr
188190
internal_note: coverage.planning.internal_note,
189191
})),
190192
})),
193+
update_method: updates.update_method?.value ?? updates.update_method ?? original.update_method
191194
})
192195
.then((response) => {
193196
const events = modifySaveResponseForClient(response);

0 commit comments

Comments
 (0)