Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDBELGA-778] fix: Show recurring Planning update method on Ignore|Cancel|Save modal #1930

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fireq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"superdesk_branch": "release/2.7"
}
5 changes: 3 additions & 2 deletions client/actions/events/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,9 @@ const save = (original, updates) => (
) {
delete eventUpdates.dates;
}
eventUpdates.update_method = get(eventUpdates, 'update_method.value') ||
EVENTS.UPDATE_METHODS[0].value;
eventUpdates.update_method = eventUpdates.update_method == null ?
EVENTS.UPDATE_METHODS[0].value :
eventUpdates.update_method?.value ?? eventUpdates.update_method;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to defined type for update_method - it's a union of strings. It'd be best to either update the type or remove the logic where .value is accessed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomaskikutis These are the ulgy parts of the code that I was talking about in last night's Scrum. Some of the ItemActionModals provide the enableSaveInModal and update_method differently. IMO we can leave as is for now, as long as it works, until we refactor the modals in Planning


return originalEvent?._id != null ?
planningApi.events.update(originalItem, eventUpdates) :
Expand Down
1 change: 1 addition & 0 deletions client/actions/events/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ const save = (original, updates, confirmation, unlockOnClose) => (
{
actionType: 'save',
unlockOnClose: unlockOnClose,
large: true,
}
));
}
Expand Down
8 changes: 2 additions & 6 deletions client/actions/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,7 @@ const openIgnoreCancelSaveModal = ({
const storedItems = itemType === ITEM_TYPE.EVENT ?
selectors.events.storedEvents(getState()) :
selectors.planning.storedPlannings(getState());

const item = {
...get(storedItems, itemId) || {},
...autosaveData,
};
const item = get(storedItems, itemId) || {};

if (!isExistingItem(item)) {
delete item._id;
Expand Down Expand Up @@ -736,7 +732,7 @@ const openIgnoreCancelSaveModal = ({
modalType: MODALS.IGNORE_CANCEL_SAVE,
modalProps: {
item: itemWithAssociatedData,
itemType: itemType,
updates: autosaveData,
onCancel: onCancel,
onIgnore: onIgnore,
onSave: onSave,
Expand Down
54 changes: 30 additions & 24 deletions client/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
import React from 'react';
import PropTypes from 'prop-types';

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

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

export class ConfirmationModal extends React.Component {
interface IProps {
handleHide(itemType?: string): void;
modalProps: {
onCancel?(): void;
cancelText?: string;
ignore?(): void;
showIgnore?: boolean;
ignoreText?: string;
okText?: string;
action?(): void;
title?: string;
body: React.ReactNode;
itemType?: string;
autoClose?: boolean;
large?: boolean;
bodyClassname?: string;
};
}

interface IState {
submitting: boolean;
}

export class ConfirmationModal extends React.Component<IProps, IState> {
constructor(props) {
super(props);

Expand Down Expand Up @@ -96,14 +118,18 @@ export class ConfirmationModal extends React.Component {
}

return (
<Modal show={true} onHide={this.onCancel}>
<Modal
show={true}
onHide={this.onCancel}
large={this.props.modalProps.large}
>
<Modal.Header>
<h3 className="modal__heading">{modalProps.title || gettext('Confirmation')}</h3>
<a className="icn-btn" aria-label={gettext('Close')} onClick={this.onCancel}>
<Icon icon="icon-close-small" />
</a>
</Modal.Header>
<Modal.Body>
<Modal.Body className={this.props.modalProps.bodyClassname}>
<div>
{modalProps.body || gettext('Are you sure ?')}
</div>
Expand All @@ -115,23 +141,3 @@ export class ConfirmationModal extends React.Component {
);
}
}

ConfirmationModal.propTypes = {
handleHide: PropTypes.func.isRequired,
modalProps: PropTypes.shape({
onCancel: PropTypes.func,
cancelText: PropTypes.string,
ignore: PropTypes.func,
showIgnore: PropTypes.bool,
ignoreText: PropTypes.string,
okText: PropTypes.string,
action: PropTypes.func,
title: PropTypes.string,
body: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element,
]),
itemType: PropTypes.string,
autoClose: PropTypes.bool,
}),
};
43 changes: 38 additions & 5 deletions client/components/Events/EventScheduleSummary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import {get} from 'lodash';

import {IEventItem} from 'interfaces';
import {gettext, eventUtils, timeUtils} from '../../../utils';

import {FormLabel, Text, ContentDivider} from 'superdesk-ui-framework/react';
import {RepeatEventSummary} from '../RepeatEventSummary';
import {Row} from '../../UI/Preview';
import {gettext, eventUtils, timeUtils} from '../../../utils';

import './style.scss';
import {IEventItem} from 'interfaces';


interface IProps {
event: Partial<IEventItem>,
noPadding?: boolean,
forUpdating?: boolean,
useEventTimezone?: boolean
useFormLabelAndText?: boolean
addContentDivider?: boolean
}

export const EventScheduleSummary = ({
event,
noPadding = false,
forUpdating = false,
useEventTimezone = false
useEventTimezone = false,
useFormLabelAndText = false,
addContentDivider = false,
}: IProps) => {
if (!event) {
return null;
Expand Down Expand Up @@ -69,12 +77,37 @@
remoteDateText = datesToShowRemote;
currentDateLabel = gettext('Current Date');
if (useEventTimezone && isRemoteTimeZone) {
currentDateText = newDateString.replace(/[\(\)]/g, '');

Check warning on line 80 in client/components/Events/EventScheduleSummary/index.tsx

View workflow job for this annotation

GitHub Actions / client (14.x)

Unnecessary escape character: \(
remoteDateText = `(${eventDateText})`;
currentDateLabel = gettext('Current Date (Based on Event timezone)');
}

return (
return useFormLabelAndText ? (
<React.Fragment>
<div>
<FormLabel text={forUpdating ? currentDateLabel : gettext('Date:')} />
<Text size="small" weight="medium">
{currentDateText || ''}
</Text>
</div>
{addContentDivider !== true ? null : (
<ContentDivider type="dashed" margin="x-small" />
)}
{doesRepeat !== true ? null : (
<React.Fragment>
<div>
<FormLabel text={gettext('Repeat Summary')} />
<Text size="small" weight="medium">
{eventUtils.getRepeatSummaryForEvent(eventSchedule)}
</Text>
</div>
{addContentDivider !== true ? null : (
<ContentDivider type="dashed" margin="x-small" />
)}
</React.Fragment>
)}
</React.Fragment>
) : (
<React.Fragment>
<Row
label={forUpdating ? currentDateLabel : gettext('Date:')}
Expand Down
Loading
Loading