mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-06-06 17:26:36 +02:00
Add logic for sorting words by definition if setting is chosen
This commit is contained in:
parent
9869d29a55
commit
47a9c96c76
4 changed files with 14 additions and 2 deletions
|
@ -78,6 +78,7 @@ export class MainDisplay extends Component {
|
||||||
details={ dictionaryInfo.details }
|
details={ dictionaryInfo.details }
|
||||||
settings={ dictionaryInfo.settings }
|
settings={ dictionaryInfo.settings }
|
||||||
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
|
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
|
||||||
|
updateDisplay={ updateDisplay }
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<WordsList
|
<WordsList
|
||||||
|
|
|
@ -29,6 +29,7 @@ export class DictionaryDetails extends Component {
|
||||||
details: PropTypes.object,
|
details: PropTypes.object,
|
||||||
settings: PropTypes.object,
|
settings: PropTypes.object,
|
||||||
updater: PropTypes.object,
|
updater: PropTypes.object,
|
||||||
|
updateDisplay: PropTypes.func,
|
||||||
}, props, 'prop', 'DictionaryDetails');
|
}, props, 'prop', 'DictionaryDetails');
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -129,6 +130,7 @@ export class DictionaryDetails extends Component {
|
||||||
alphabeticalOrder={ this.props.alphabeticalOrder }
|
alphabeticalOrder={ this.props.alphabeticalOrder }
|
||||||
details={ this.props.details }
|
details={ this.props.details }
|
||||||
settings={ this.props.settings }
|
settings={ this.props.settings }
|
||||||
|
updateDisplay={ this.props.updateDisplay }
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,6 +28,7 @@ export class EditDictionaryModal extends Component {
|
||||||
details: PropTypes.object,
|
details: PropTypes.object,
|
||||||
settings: PropTypes.object,
|
settings: PropTypes.object,
|
||||||
isLoggedIn: PropTypes.bool,
|
isLoggedIn: PropTypes.bool,
|
||||||
|
updateDisplay: PropTypes.func,
|
||||||
}, props, 'prop', 'EditDictionaryModal');
|
}, props, 'prop', 'EditDictionaryModal');
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -233,7 +234,12 @@ export class EditDictionaryModal extends Component {
|
||||||
|
|
||||||
this.props.updater.updateDictionaryDetails(updatedDetails)
|
this.props.updater.updateDictionaryDetails(updatedDetails)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({ hasChanged: false });
|
this.setState({ hasChanged: false }, () => {
|
||||||
|
// If setting that alters word display is changed, update the display.
|
||||||
|
if (updatedDetails.hasOwnProperty('sortByDefinition')) {
|
||||||
|
this.props.updateDisplay();
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(errorMessage => {
|
.catch(errorMessage => {
|
||||||
console.error(errorMessage);
|
console.error(errorMessage);
|
||||||
|
@ -289,7 +295,7 @@ export class EditDictionaryModal extends Component {
|
||||||
<div className='columns'>
|
<div className='columns'>
|
||||||
|
|
||||||
<div className='column has-text-centered'>
|
<div className='column has-text-centered'>
|
||||||
{ specification } marked complete<br />
|
{ specification } marked complete—editing has been disabled.<br />
|
||||||
<a className='button is-warning is-small'
|
<a className='button is-warning is-small'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.setState({ isComplete: false, currentDisplay: DISPLAY.SETTINGS }, () => {
|
this.setState({ isComplete: false, currentDisplay: DISPLAY.SETTINGS }, () => {
|
||||||
|
|
|
@ -313,6 +313,9 @@ class DictionaryData {
|
||||||
}
|
}
|
||||||
|
|
||||||
get wordsPromise () {
|
get wordsPromise () {
|
||||||
|
if (this.sortByDefinition) {
|
||||||
|
return wordDb.words.toCollection().sortBy('definition');
|
||||||
|
}
|
||||||
return wordDb.words.toArray();
|
return wordDb.words.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue