New: Optionally display authors as LastName, FirstName in index

Fixes #1062
This commit is contained in:
ta264
2021-07-21 21:50:17 +01:00
parent 332997aefe
commit 7f8dc3d2b4
28 changed files with 193 additions and 54 deletions
@@ -74,6 +74,7 @@ class AuthorIndexOverview extends Component {
const {
id,
authorName,
authorNameLastFirst,
overview,
monitored,
status,
@@ -167,7 +168,7 @@ class AuthorIndexOverview extends Component {
className={styles.title}
to={link}
>
{authorName}
{overviewOptions.showTitle === 'firstLast' ? authorName : authorNameLastFirst}
</Link>
<div className={styles.actions}>
@@ -247,7 +248,8 @@ class AuthorIndexOverview extends Component {
AuthorIndexOverview.propTypes = {
id: PropTypes.number.isRequired,
authorName: PropTypes.string.isRequired,
overview: PropTypes.string.isRequired,
authorNameLastFirst: PropTypes.string.isRequired,
overview: PropTypes.string,
monitored: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
titleSlug: PropTypes.string.isRequired,
@@ -90,7 +90,8 @@ class AuthorIndexOverviews extends Component {
if (this._grid &&
(prevState.width !== width ||
prevState.rowHeight !== rowHeight ||
hasDifferentItemsOrOrder(prevProps.items, items))) {
hasDifferentItemsOrOrder(prevProps.items, items) ||
prevProps.overviewOptions.showTitle !== overviewOptions.showTitle)) {
// recomputeGridSize also forces Grid to discard its cache of rendered cells
this._grid.recomputeGridSize();
}
@@ -101,7 +102,7 @@ class AuthorIndexOverviews extends Component {
}
if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) {
const index = getIndexOfFirstCharacter(items, jumpToCharacter);
const index = getIndexOfFirstCharacter(items, sortKey, jumpToCharacter);
if (this._grid && index != null) {
@@ -13,6 +13,11 @@ import ModalHeader from 'Components/Modal/ModalHeader';
import { inputTypes } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
const nameOptions = [
{ key: 'firstLast', value: translate('NameFirstLast') },
{ key: 'lastFirst', value: translate('NameLastFirst') }
];
const posterSizeOptions = [
{ key: 'small', value: 'Small' },
{ key: 'medium', value: 'Medium' },
@@ -28,6 +33,7 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
super(props, context);
this.state = {
showTitle: props.showTitle,
detailedProgressBar: props.detailedProgressBar,
size: props.size,
showMonitored: props.showMonitored,
@@ -43,6 +49,7 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
componentDidUpdate(prevProps) {
const {
showTitle,
detailedProgressBar,
size,
showMonitored,
@@ -57,6 +64,10 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
const state = {};
if (showTitle !== prevProps.showTitle) {
state.showTitle = showTitle;
}
if (detailedProgressBar !== prevProps.detailedProgressBar) {
state.detailedProgressBar = detailedProgressBar;
}
@@ -122,6 +133,7 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
} = this.props;
const {
showTitle,
detailedProgressBar,
size,
showMonitored,
@@ -142,6 +154,20 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
<ModalBody>
<Form>
<FormGroup>
<FormLabel>
{translate('NameStyle')}
</FormLabel>
<FormInputGroup
type={inputTypes.SELECT}
name="showTitle"
value={showTitle}
values={nameOptions}
onChange={this.onChangeOverviewOption}
/>
</FormGroup>
<FormGroup>
<FormLabel>
{translate('PosterSize')}
@@ -291,6 +317,7 @@ class AuthorIndexOverviewOptionsModalContent extends Component {
}
AuthorIndexOverviewOptionsModalContent.propTypes = {
showTitle: PropTypes.string.isRequired,
size: PropTypes.string.isRequired,
detailedProgressBar: PropTypes.bool.isRequired,
showMonitored: PropTypes.bool.isRequired,