mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-05-11 04:31:16 +02:00
Disable editing dictionary if marked complete
This commit is contained in:
parent
629bb9858b
commit
9869d29a55
4 changed files with 114 additions and 62 deletions
|
@ -49,6 +49,7 @@ export class MainDisplay extends Component {
|
||||||
render () {
|
render () {
|
||||||
const { dictionaryInfo, wordsToDisplay, updateDisplay, updater } = this.props;
|
const { dictionaryInfo, wordsToDisplay, updateDisplay, updater } = this.props;
|
||||||
const { isMobile, wordFormIsOpen } = this.state;
|
const { isMobile, wordFormIsOpen } = this.state;
|
||||||
|
const wordFormIsDisabled = dictionaryInfo.settings.isComplete;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className='section'>
|
<section className='section'>
|
||||||
|
@ -56,6 +57,7 @@ export class MainDisplay extends Component {
|
||||||
<div className='columns'>
|
<div className='columns'>
|
||||||
|
|
||||||
<LeftColumn
|
<LeftColumn
|
||||||
|
isDisabled={ wordFormIsDisabled }
|
||||||
isMobile={ isMobile }
|
isMobile={ isMobile }
|
||||||
displayForm={ wordFormIsOpen }
|
displayForm={ wordFormIsOpen }
|
||||||
openWordForm={ this.openWordForm.bind(this) }
|
openWordForm={ this.openWordForm.bind(this) }
|
||||||
|
@ -66,7 +68,7 @@ export class MainDisplay extends Component {
|
||||||
/>
|
/>
|
||||||
</LeftColumn>
|
</LeftColumn>
|
||||||
|
|
||||||
<RightColumn formIsDisplayed={ this.state.wordFormIsOpen }>
|
<RightColumn formIsDisplayed={ !wordFormIsDisabled && wordFormIsOpen }>
|
||||||
<DictionaryDetails
|
<DictionaryDetails
|
||||||
updater={ updater }
|
updater={ updater }
|
||||||
name={ dictionaryInfo.name }
|
name={ dictionaryInfo.name }
|
||||||
|
|
|
@ -106,7 +106,7 @@ export const EditSettingsForm = (props) => {
|
||||||
}} />
|
}} />
|
||||||
</label>
|
</label>
|
||||||
<div className='help'>
|
<div className='help'>
|
||||||
Checking this box will mark your { specification } as "complete", and you will not be able to alter it until this checkbox is unchecked.
|
Checking this box will mark your { specification } as "complete" and prevent any changes from being made.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -242,10 +242,11 @@ export class EditDictionaryModal extends Component {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { currentDisplay, hasChanged } = this.state;
|
const { currentDisplay, hasChanged } = this.state;
|
||||||
|
const { specification, settings, isLoggedIn } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal title={ `Edit ${ this.props.specification }` }
|
<Modal title={ `Edit ${ specification }` }
|
||||||
buttonText={ `Edit ${ this.props.specification }` }
|
buttonText={ `Edit ${ specification }` }
|
||||||
footerAlign='right'
|
footerAlign='right'
|
||||||
footerContent={
|
footerContent={
|
||||||
(
|
(
|
||||||
|
@ -261,6 +262,8 @@ export class EditDictionaryModal extends Component {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
{!settings.isComplete
|
||||||
|
? [(
|
||||||
<div className='tabs'>
|
<div className='tabs'>
|
||||||
<ul>
|
<ul>
|
||||||
<li className={ (currentDisplay === DISPLAY.DETAILS) ? 'is-active' : null }>
|
<li className={ (currentDisplay === DISPLAY.DETAILS) ? 'is-active' : null }>
|
||||||
|
@ -280,9 +283,53 @@ export class EditDictionaryModal extends Component {
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
),
|
||||||
|
this.displaySection(),
|
||||||
|
] : (
|
||||||
|
<div className='columns'>
|
||||||
|
|
||||||
{ this.displaySection() }
|
<div className='column has-text-centered'>
|
||||||
|
{ specification } marked complete<br />
|
||||||
|
<a className='button is-warning is-small'
|
||||||
|
onClick={() => {
|
||||||
|
this.setState({ isComplete: false, currentDisplay: DISPLAY.SETTINGS }, () => {
|
||||||
|
this.save();
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
Mark it incomplete
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isLoggedIn
|
||||||
|
&& (
|
||||||
|
<div className='column has-text-centered'>
|
||||||
|
Your dictionary is <strong>{ settings.isPublic ? 'Public' : 'Private'}</strong>
|
||||||
|
{settings.isPublic
|
||||||
|
&& (
|
||||||
|
[
|
||||||
|
' You can view it at',
|
||||||
|
<br />,
|
||||||
|
<a className='button is-text is-small'
|
||||||
|
onClick={() => console.log('set up copying to clipboard')}>
|
||||||
|
PUBLIC_LINK
|
||||||
|
</a>,
|
||||||
|
]
|
||||||
|
)}
|
||||||
|
<br />
|
||||||
|
<a className='button is-small'
|
||||||
|
onClick={() => {
|
||||||
|
this.setState({ isPublic: !settings.isPublic }, () => {
|
||||||
|
this.save();
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
Mark it { settings.isPublic ? 'Private' : 'Public'}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import './styles.scss';
|
||||||
|
|
||||||
export const LeftColumn = (props) => {
|
export const LeftColumn = (props) => {
|
||||||
PropTypes.checkPropTypes({
|
PropTypes.checkPropTypes({
|
||||||
|
isDisabled: PropTypes.bool,
|
||||||
isMobile: PropTypes.bool.isRequired,
|
isMobile: PropTypes.bool.isRequired,
|
||||||
displayForm: PropTypes.bool.isRequired,
|
displayForm: PropTypes.bool.isRequired,
|
||||||
openWordForm: PropTypes.func.isRequired,
|
openWordForm: PropTypes.func.isRequired,
|
||||||
|
@ -14,8 +15,9 @@ export const LeftColumn = (props) => {
|
||||||
children: PropTypes.object,
|
children: PropTypes.object,
|
||||||
}, props, 'prop', 'LeftColumn');
|
}, props, 'prop', 'LeftColumn');
|
||||||
|
|
||||||
const { isMobile, displayForm, openWordForm, closeWordForm } = props;
|
const { isDisabled, isMobile, displayForm, openWordForm, closeWordForm } = props;
|
||||||
|
|
||||||
|
if (!isDisabled) {
|
||||||
return (
|
return (
|
||||||
<div className={ `left-column-${ displayForm ? 'open' : 'closed' }` } >
|
<div className={ `left-column-${ displayForm ? 'open' : 'closed' }` } >
|
||||||
{isMobile
|
{isMobile
|
||||||
|
@ -53,3 +55,4 @@ export const LeftColumn = (props) => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue