Fixed: Selection of last added custom filter

Plus some translations and typos

(cherry picked from commit 1f97679868012b70beecc553557e96e6c8bc80e3)
pull/3322/head
Bogdan 3 months ago
parent 17094f1998
commit 8efb2eb71a

@ -1,3 +1,4 @@
import { maxBy } from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import FormInputGroup from 'Components/Form/FormInputGroup'; import FormInputGroup from 'Components/Form/FormInputGroup';
@ -50,7 +51,7 @@ class FilterBuilderModalContent extends Component {
if (id) { if (id) {
dispatchSetFilter({ selectedFilterKey: id }); dispatchSetFilter({ selectedFilterKey: id });
} else { } else {
const last = customFilters[customFilters.length -1]; const last = maxBy(customFilters, 'id');
dispatchSetFilter({ selectedFilterKey: last.id }); dispatchSetFilter({ selectedFilterKey: last.id });
} }
@ -108,7 +109,7 @@ class FilterBuilderModalContent extends Component {
this.setState({ this.setState({
labelErrors: [ labelErrors: [
{ {
message: 'Label is required' message: translate('LabelIsRequired')
} }
] ]
}); });
@ -146,13 +147,13 @@ class FilterBuilderModalContent extends Component {
return ( return (
<ModalContent onModalClose={onModalClose}> <ModalContent onModalClose={onModalClose}>
<ModalHeader> <ModalHeader>
Custom Filter {translate('CustomFilter')}
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<div className={styles.labelContainer}> <div className={styles.labelContainer}>
<div className={styles.label}> <div className={styles.label}>
Label {translate('Label')}
</div> </div>
<div className={styles.labelInputContainer}> <div className={styles.labelInputContainer}>
@ -195,7 +196,7 @@ class FilterBuilderModalContent extends Component {
<ModalFooter> <ModalFooter>
<Button onPress={onCancelPress}> <Button onPress={onCancelPress}>
Cancel {translate('Cancel')}
</Button> </Button>
<SpinnerErrorButton <SpinnerErrorButton
@ -203,7 +204,7 @@ class FilterBuilderModalContent extends Component {
error={saveError} error={saveError}
onPress={this.onSaveFilterPress} onPress={this.onSaveFilterPress}
> >
Save {translate('Save')}
</SpinnerErrorButton> </SpinnerErrorButton>
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>

@ -37,8 +37,8 @@ class CustomFilter extends Component {
dispatchSetFilter dispatchSetFilter
} = this.props; } = this.props;
// Assume that delete and then unmounting means the delete was successful. // Assume that delete and then unmounting means the deletion was successful.
// Moving this check to a ancestor would be more accurate, but would have // Moving this check to an ancestor would be more accurate, but would have
// more boilerplate. // more boilerplate.
if (this.state.isDeleting && id === selectedFilterKey) { if (this.state.isDeleting && id === selectedFilterKey) {
dispatchSetFilter({ selectedFilterKey: 'all' }); dispatchSetFilter({ selectedFilterKey: 'all' });

@ -186,6 +186,7 @@
"CreateEmptyAuthorFolders": "Create empty author folders", "CreateEmptyAuthorFolders": "Create empty author folders",
"CreateEmptyAuthorFoldersHelpText": "Create missing author folders during disk scan", "CreateEmptyAuthorFoldersHelpText": "Create missing author folders during disk scan",
"CreateGroup": "Create group", "CreateGroup": "Create group",
"CustomFilter": "Custom Filter",
"CustomFormat": "Custom Format", "CustomFormat": "Custom Format",
"CustomFormatScore": "Custom Format Score", "CustomFormatScore": "Custom Format Score",
"CustomFormatSettings": "Custom Format Settings", "CustomFormatSettings": "Custom Format Settings",
@ -470,6 +471,7 @@
"Iso639-3": "ISO 639-3 language codes, or 'null', comma separated", "Iso639-3": "ISO 639-3 language codes, or 'null', comma separated",
"ItsEasyToAddANewAuthorOrBookJustStartTypingTheNameOfTheItemYouWantToAdd": "It's easy to add a New Author or Book just start typing the name of the item you want to add", "ItsEasyToAddANewAuthorOrBookJustStartTypingTheNameOfTheItemYouWantToAdd": "It's easy to add a New Author or Book just start typing the name of the item you want to add",
"Label": "Label", "Label": "Label",
"LabelIsRequired": "Label is required",
"Language": "Language", "Language": "Language",
"Large": "Large", "Large": "Large",
"LastDuration": "Last Duration", "LastDuration": "Last Duration",

Loading…
Cancel
Save