Skip to content

Commit

Permalink
Planning compatability fixes with client-core post-broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Oct 31, 2023
1 parent 1efa363 commit 7993470
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 37 deletions.
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';
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

0 comments on commit 7993470

Please sign in to comment.