Skip to content

Commit 08b2dd7

Browse files
committed
[SDBELGA-778] fix: Show recurring Planning update method on Ignore|Cancel|Save modal
Also improve look and feel when rendering Event & Planning metadata in the modal
1 parent ed5e386 commit 08b2dd7

File tree

18 files changed

+546
-369
lines changed

18 files changed

+546
-369
lines changed

client/actions/events/api.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,9 @@ const save = (original, updates) => (
565565
) {
566566
delete eventUpdates.dates;
567567
}
568-
eventUpdates.update_method = get(eventUpdates, 'update_method.value') ||
569-
EVENTS.UPDATE_METHODS[0].value;
568+
eventUpdates.update_method = eventUpdates.update_method == null ?
569+
EVENTS.UPDATE_METHODS[0].value :
570+
eventUpdates.update_method?.value ?? eventUpdates.update_method;
570571

571572
return originalEvent?._id != null ?
572573
planningApi.events.update(originalItem, eventUpdates) :

client/actions/events/ui.ts

+1
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ const save = (original, updates, confirmation, unlockOnClose) => (
928928
{
929929
actionType: 'save',
930930
unlockOnClose: unlockOnClose,
931+
large: true,
931932
}
932933
));
933934
}

client/actions/main.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,7 @@ const openIgnoreCancelSaveModal = ({
703703
const storedItems = itemType === ITEM_TYPE.EVENT ?
704704
selectors.events.storedEvents(getState()) :
705705
selectors.planning.storedPlannings(getState());
706-
707-
const item = {
708-
...get(storedItems, itemId) || {},
709-
...autosaveData,
710-
};
706+
const item = get(storedItems, itemId) || {};
711707

712708
if (!isExistingItem(item)) {
713709
delete item._id;
@@ -736,7 +732,7 @@ const openIgnoreCancelSaveModal = ({
736732
modalType: MODALS.IGNORE_CANCEL_SAVE,
737733
modalProps: {
738734
item: itemWithAssociatedData,
739-
itemType: itemType,
735+
updates: autosaveData,
740736
onCancel: onCancel,
741737
onIgnore: onIgnore,
742738
onSave: onSave,

client/components/ConfirmationModal.tsx

+30-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32

43
import {gettext} from '../utils';
54

65
import {Modal} from './index';
76
import {ButtonList, Icon} from './UI';
87
import {KEYCODES} from '../constants';
98

10-
export class ConfirmationModal extends React.Component {
9+
interface IProps {
10+
handleHide(itemType?: string): void;
11+
modalProps: {
12+
onCancel?(): void;
13+
cancelText?: string;
14+
ignore?(): void;
15+
showIgnore?: boolean;
16+
ignoreText?: string;
17+
okText?: string;
18+
action?(): void;
19+
title?: string;
20+
body: React.ReactNode;
21+
itemType?: string;
22+
autoClose?: boolean;
23+
large?: boolean;
24+
bodyClassname?: string;
25+
};
26+
}
27+
28+
interface IState {
29+
submitting: boolean;
30+
}
31+
32+
export class ConfirmationModal extends React.Component<IProps, IState> {
1133
constructor(props) {
1234
super(props);
1335

@@ -96,14 +118,18 @@ export class ConfirmationModal extends React.Component {
96118
}
97119

98120
return (
99-
<Modal show={true} onHide={this.onCancel}>
121+
<Modal
122+
show={true}
123+
onHide={this.onCancel}
124+
large={this.props.modalProps.large}
125+
>
100126
<Modal.Header>
101127
<h3 className="modal__heading">{modalProps.title || gettext('Confirmation')}</h3>
102128
<a className="icn-btn" aria-label={gettext('Close')} onClick={this.onCancel}>
103129
<Icon icon="icon-close-small" />
104130
</a>
105131
</Modal.Header>
106-
<Modal.Body>
132+
<Modal.Body className={this.props.modalProps.bodyClassname}>
107133
<div>
108134
{modalProps.body || gettext('Are you sure ?')}
109135
</div>
@@ -115,23 +141,3 @@ export class ConfirmationModal extends React.Component {
115141
);
116142
}
117143
}
118-
119-
ConfirmationModal.propTypes = {
120-
handleHide: PropTypes.func.isRequired,
121-
modalProps: PropTypes.shape({
122-
onCancel: PropTypes.func,
123-
cancelText: PropTypes.string,
124-
ignore: PropTypes.func,
125-
showIgnore: PropTypes.bool,
126-
ignoreText: PropTypes.string,
127-
okText: PropTypes.string,
128-
action: PropTypes.func,
129-
title: PropTypes.string,
130-
body: PropTypes.oneOfType([
131-
PropTypes.string,
132-
PropTypes.element,
133-
]),
134-
itemType: PropTypes.string,
135-
autoClose: PropTypes.bool,
136-
}),
137-
};

client/components/Events/EventScheduleSummary/index.tsx

+38-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import {get} from 'lodash';
43

4+
import {IEventItem} from 'interfaces';
5+
import {gettext, eventUtils, timeUtils} from '../../../utils';
6+
7+
import {FormLabel, Text, ContentDivider} from 'superdesk-ui-framework/react';
58
import {RepeatEventSummary} from '../RepeatEventSummary';
69
import {Row} from '../../UI/Preview';
7-
import {gettext, eventUtils, timeUtils} from '../../../utils';
10+
811
import './style.scss';
9-
import {IEventItem} from 'interfaces';
12+
13+
1014
interface IProps {
1115
event: Partial<IEventItem>,
1216
noPadding?: boolean,
1317
forUpdating?: boolean,
1418
useEventTimezone?: boolean
19+
useFormLabelAndText?: boolean
20+
addContentDivider?: boolean
1521
}
1622

1723
export const EventScheduleSummary = ({
1824
event,
1925
noPadding = false,
2026
forUpdating = false,
21-
useEventTimezone = false
27+
useEventTimezone = false,
28+
useFormLabelAndText = false,
29+
addContentDivider = false,
2230
}: IProps) => {
2331
if (!event) {
2432
return null;
@@ -74,7 +82,32 @@ export const EventScheduleSummary = ({
7482
currentDateLabel = gettext('Current Date (Based on Event timezone)');
7583
}
7684

77-
return (
85+
return useFormLabelAndText ? (
86+
<React.Fragment>
87+
<div>
88+
<FormLabel text={forUpdating ? currentDateLabel : gettext('Date:')} />
89+
<Text size="small" weight="medium">
90+
{currentDateText || ''}
91+
</Text>
92+
</div>
93+
{addContentDivider !== true ? null : (
94+
<ContentDivider type="dashed" margin="x-small" />
95+
)}
96+
{doesRepeat !== true ? null : (
97+
<React.Fragment>
98+
<div>
99+
<FormLabel text={gettext('Repeat Summary')} />
100+
<Text size="small" weight="medium">
101+
{eventUtils.getRepeatSummaryForEvent(eventSchedule)}
102+
</Text>
103+
</div>
104+
{addContentDivider !== true ? null : (
105+
<ContentDivider type="dashed" margin="x-small" />
106+
)}
107+
</React.Fragment>
108+
)}
109+
</React.Fragment>
110+
) : (
78111
<React.Fragment>
79112
<Row
80113
label={forUpdating ? currentDateLabel : gettext('Date:')}

0 commit comments

Comments
 (0)