Add Save & Close button to EditDictionaryModal

This commit is contained in:
Robbie Antenesse 2018-03-09 12:21:41 -07:00
parent 548f935753
commit fa9422e048
1 changed files with 11 additions and 2 deletions

View File

@ -59,6 +59,8 @@ export class EditDictionaryModal extends Component {
hasChanged: false,
}
this.modal = null;
}
hasChanged () {
@ -144,7 +146,7 @@ export class EditDictionaryModal extends Component {
);
}
save () {
save (callback = () => {}) {
const updatedDetails = {};
if (this.state.name !== this.props.name) {
@ -252,7 +254,7 @@ export class EditDictionaryModal extends Component {
this.setState({ hasChanged: false }, () => {
// If setting that alters word display is changed, update the display.
if (updatedDetails.hasOwnProperty('sortByDefinition')) {
this.props.updateDisplay();
this.props.updateDisplay(callback);
}
});
})
@ -278,9 +280,16 @@ export class EditDictionaryModal extends Component {
>
Save
</button>
<button className='button'
disabled={ !hasChanged }
onClick={ () => this.save(this.modal.hide())}
>
Save & Close
</button>
</div>
)
}
ref={(modal) => this.modal = modal}
>
{!settings.isComplete