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

Display expiry date on Preview and Detail View for a segment of a TV/radio transcript #685

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions assets/wire/components/PreviewMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const DEFAULT_META_FIELDS = [
'source',
['charcount', 'wordcount'],
'previous_versions',
'expiry',
];

function PreviewMeta({
Expand Down
23 changes: 23 additions & 0 deletions assets/wire/components/fields/ExpiryDateLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import PropTypes from 'prop-types';
import {gettext} from 'utils';
import {get} from 'lodash';

export function ExpiryDateLabel ({item, filterGroupLabels}: any) {
MarkLark86 marked this conversation as resolved.
Show resolved Hide resolved
if (item.expiry == null) {
return null;
}

const label = get(filterGroupLabels, 'expiry', gettext('Expiry Date'));
Copy link
Member

Choose a reason for hiding this comment

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

no get pls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so label is just const label = gettext('Expirt Date'); ???

const value = item.expiry;
const text = label + ': ' + value;
petrjasek marked this conversation as resolved.
Show resolved Hide resolved

return (
<span>{text}</span>
);
}

ExpiryDateLabel.propTypes = {
item: PropTypes.object,
filterGroupLabels: PropTypes.object,
};
2 changes: 2 additions & 0 deletions assets/wire/components/fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {PreviousVersions} from './PreviousVersions';
import {Embargo} from './Embargo';
import {VersionCreated} from './VersionCreated';
import {VersionType} from './VersionType';
import {ExpiryDateLabel} from './ExpiryDateLabel';

const ALLOWED_SEPARATORS = ['/', '//', '-'];
const SEPARATOR_KEY = 'separator';
Expand All @@ -19,6 +20,7 @@ const MAP_FIELD_TO_COMPONENT: any = {
previous_versions: PreviousVersions,
embargo: Embargo,
versioncreated: VersionCreated,
expiry: ExpiryDateLabel,
};

// Example config:
Expand Down
Loading