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