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

Planning compatability fixes with client-core post-broadcasting #1873

Closed
wants to merge 1 commit into from
Closed
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
76 changes: 40 additions & 36 deletions client/components/Events/ManageEventTemplatesModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/no-multi-comp */

import {IFormGroup, IBaseRestApiResponse, IGenericListPageComponent} from 'superdesk-api';
import {IFormGroup, IBaseRestApiResponse, IFormField, IPropsGenericFormItemComponent} from 'superdesk-api';
import {superdeskApi} from '../../superdeskApi';

import React from 'react';
Expand All @@ -16,20 +16,54 @@ interface IEventTemplate extends IBaseRestApiResponse {
template_name: string;
}

const getItemComponent = (nameField: IFormField) =>
class ItemComponent extends React.PureComponent<IPropsGenericFormItemComponent<any>> {
render(): React.ReactNode {
const {item, page} = this.props;

const {ListItem, ListItemColumn} = superdeskApi.components;
const {getFormFieldPreviewComponent} = superdeskApi.forms;

return (
<ListItem>
<ListItemColumn ellipsisAndGrow noBorder>
{getFormFieldPreviewComponent(item, nameField)}
</ListItemColumn>
<ListItemColumn noBorder>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<button onClick={() => page.startEditing(item._id)}>
<i className="icon-pencil" />
</button>
<button onClick={() => page.deleteItem(item)}>
<i className="icon-trash" />
</button>
</div>
</ListItemColumn>
</ListItem>
);
}
};

export class ManageEventTemplatesModal extends React.PureComponent<IProps> {
static propTypes: any;

render() {
const {handleHide} = this.props;

const {getGenericHttpEntityListPageComponent, ListItemColumn, ListItem} = superdeskApi.components;
const {getFormFieldPreviewComponent, FormFieldType} = superdeskApi.forms;
const {getGenericHttpEntityListPageComponent} = superdeskApi.components;
const {FormFieldType} = superdeskApi.forms;

const {gettext} = superdeskApi.localization;

const nameField = {
label: gettext('Template name'),
type: FormFieldType.textSingleLine,
type: FormFieldType.plainText,
field: 'template_name',
required: true,
};
Expand All @@ -47,36 +81,6 @@ export class ManageEventTemplatesModal extends React.PureComponent<IProps> {
formConfig
);

const renderRow = (
key: string,
item: IEventTemplate,
page: IGenericListPageComponent<IEventTemplate>
) => (
<ListItem
key={key}
>
<ListItemColumn ellipsisAndGrow noBorder>
{getFormFieldPreviewComponent(item, nameField)}
</ListItemColumn>
<ListItemColumn noBorder>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<button onClick={() => page.startEditing(item._id)}>
<i className="icon-pencil" />
</button>
<button onClick={() => page.deleteItem(item)}>
<i className="icon-trash" />
</button>
</div>
</ListItemColumn>
</ListItem>
);

return (
<Modal xLarge={true} show={true} onHide={handleHide}>
<Modal.Header>
Expand All @@ -87,8 +91,8 @@ export class ManageEventTemplatesModal extends React.PureComponent<IProps> {
</Modal.Header>
<Modal.Body noPadding={true}>
<EventTemplatesComponent
renderRow={renderRow}
formConfig={formConfig}
ItemComponent={getItemComponent(nameField)}
getFormConfig={() => formConfig}
defaultSortOption={{field: nameField.field, direction: 'ascending'}}
fieldForSearch={nameField}
refreshOnEvents={Object.keys(planningEventTemplateEvents)}
Expand Down
2 changes: 1 addition & 1 deletion client/components/UI/TermsList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {gettext} from 'superdesk-core/scripts/core/utils';
import {gettext} from 'superdesk-core/scripts/core/utils.tsx';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This import can be replaced with the SuperdeskAPI, and use localization.gettext in the render function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We won't need this PR since Petr decided that we use post-broadcasting branch instead. So I'm closing this PR.

import {getVocabularyItemFieldTranslated} from '../../utils/vocabularies';

type Term = {[key: string]: any};
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"client"
],
"compilerOptions": {
"allowImportingTsExtensions": true,
"baseUrl": "client",
"skipLibCheck": true,
"sourceMap": true,
Expand Down
Loading