Add more fields to the EditDictionary* and DictionaryData
This commit is contained in:
parent
3ae2114449
commit
09df4e8047
|
@ -109,6 +109,7 @@ export class DictionaryDetails extends Component {
|
|||
specification={ this.props.specification }
|
||||
description={ this.props.description }
|
||||
partsOfSpeech={ this.props.partsOfSpeech }
|
||||
alphabeticalOrder={ this.props.alphabeticalOrder }
|
||||
details={ this.props.details }
|
||||
/>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ export const EditDictionaryForm = ({
|
|||
name,
|
||||
specification,
|
||||
description,
|
||||
alphabeticalOrder,
|
||||
}) => {
|
||||
return (
|
||||
<div className='form'>
|
||||
|
@ -68,6 +69,28 @@ export const EditDictionaryForm = ({
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='field'>
|
||||
<label className='label' htmlFor='editAlphabeticalOrder'>
|
||||
Alphabetical Order
|
||||
</label>
|
||||
<p className='help'>
|
||||
The custom order for sorting the words in your { specification }. If blank, English alphabetical order will be used.<br />
|
||||
If the "Case Sensitive" setting is set, include both upper and lower case letters, otherwise, use upper or lower case exclusively.
|
||||
</p>
|
||||
<div className='control'>
|
||||
<textarea className='textarea' id='editAlphabeticalOrder'
|
||||
placeholder={ `a\nb\nc\nd\n...` }
|
||||
value={ alphabeticalOrder }
|
||||
onInput={ (event) => {
|
||||
editDictionaryModal.setState({
|
||||
alphabeticalOrder: event.target.value,
|
||||
hasChanged: event.target.value != editDictionaryModal.props.alphabeticalOrder.join('\n'),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,10 @@ export const EditLinguisticsForm = ({
|
|||
consonants,
|
||||
vowels,
|
||||
blends,
|
||||
onset,
|
||||
nucleus,
|
||||
coda,
|
||||
exceptions,
|
||||
}) => {
|
||||
return (
|
||||
<div className='form'>
|
||||
|
@ -33,12 +37,12 @@ export const EditLinguisticsForm = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h4 className='title as-4'>
|
||||
Phonology
|
||||
</h4>
|
||||
|
||||
<div className='columns'>
|
||||
|
||||
<h4 className='title as-4'>
|
||||
Phonology
|
||||
</h4>
|
||||
|
||||
<div className='column'>
|
||||
<IPAField label='Consonants' id='editConsonants'
|
||||
helpText='Separate phonemes with a space'
|
||||
|
@ -83,6 +87,84 @@ export const EditLinguisticsForm = ({
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div className='columns'>
|
||||
|
||||
<h5 className='title as-5'>
|
||||
Phonotactics
|
||||
</h5>
|
||||
<h6 className='subtitle as-6'>
|
||||
The makeup of a syllable
|
||||
</h6>
|
||||
|
||||
<div className='column'>
|
||||
<IPAField label='Onset' id='editOnset'
|
||||
helpText='Separate phonemes/groups with a space'
|
||||
placeholder='consonants blends'
|
||||
value={ onset }
|
||||
onInput={ (newValue) => {
|
||||
editDictionaryModal.setState({
|
||||
onset: newValue,
|
||||
hasChanged: newValue != editDictionaryModal.props.details.phonology.phonotactics.onset.join(' '),
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
|
||||
<div className='column'>
|
||||
<IPAField label='Nucleus' id='editNucleus'
|
||||
helpText='Separate phonemes/groups with a space'
|
||||
placeholder='vowels'
|
||||
value={ nucleus }
|
||||
onInput={ (newValue) => {
|
||||
editDictionaryModal.setState({
|
||||
nucleus: newValue,
|
||||
hasChanged: newValue != editDictionaryModal.props.details.phonology.phonotactics.nucleus.join(' '),
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
|
||||
<div className='column'>
|
||||
<IPAField label='Coda' id='editCoda'
|
||||
helpText='Separate phonemes/groups with a space'
|
||||
placeholder='any'
|
||||
value={ coda }
|
||||
onInput={ (newValue) => {
|
||||
editDictionaryModal.setState({
|
||||
coda: newValue,
|
||||
hasChanged: newValue != editDictionaryModal.props.details.phonology.phonotactics.coda.join(' '),
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div className='columns'>
|
||||
<div className='column'>
|
||||
|
||||
<div className='field'>
|
||||
<label className='label' htmlFor='editExceptions'>
|
||||
Exceptions
|
||||
</label>
|
||||
<p className='help'>
|
||||
Any exceptions for your phonotactics rules, <a href='MARKDOWN_LINK' target='_blank'>Markdown</a> enabled
|
||||
</p>
|
||||
<div className='control'>
|
||||
<textarea className='textarea' id='editExceptions'
|
||||
placeholder='Vowel blends are not allowed in the onset, and [e], including blends with [e] comprising it, is not allowed in the coda.'
|
||||
value={ exceptions }
|
||||
onInput={ (newValue) => {
|
||||
editDictionaryModal.setState({
|
||||
exceptions: newValue,
|
||||
hasChanged: newValue != editDictionaryModal.props.details.phonology.exceptions.join(' '),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ export class EditDictionaryModal extends Component {
|
|||
name: props.name,
|
||||
specification: props.specification,
|
||||
description: props.description,
|
||||
alphabeticalOrder: props.alphabeticalOrder.join('\n'),
|
||||
partsOfSpeech: props.partsOfSpeech.join('\n'),
|
||||
consonants: props.details.phonology.consonants.join(' '),
|
||||
vowels: props.details.phonology.vowels.join(' '),
|
||||
|
@ -64,6 +65,7 @@ export class EditDictionaryModal extends Component {
|
|||
name={ this.state.name }
|
||||
specification={ this.state.specification }
|
||||
description={ this.state.description }
|
||||
alphabeticalOrder={ this.state.alphabeticalOrder }
|
||||
/>
|
||||
);
|
||||
break;
|
||||
|
@ -107,23 +109,35 @@ export class EditDictionaryModal extends Component {
|
|||
const updatedDetails = {};
|
||||
|
||||
if (this.state.name !== this.props.name) {
|
||||
updatedDetails['name'] = this.state.name;
|
||||
updatedDetails['name'] = this.state.name.trim();
|
||||
}
|
||||
|
||||
if (this.state.specification !== this.props.specification) {
|
||||
updatedDetails['specification'] = this.state.specification;
|
||||
updatedDetails['specification'] = this.state.specification.trim();
|
||||
}
|
||||
|
||||
if (this.state.description !== this.props.description) {
|
||||
updatedDetails['description'] = this.state.description;
|
||||
}
|
||||
|
||||
if (this.state.alphabeticalOrder !== this.props.alphabeticalOrder.join('\n')) {
|
||||
updatedDetails['alphabeticalOrder'] = this.state.alphabeticalOrder.split('\n')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.partsOfSpeech !== this.props.partsOfSpeech.join('\n')) {
|
||||
updatedDetails['partsOfSpeech'] = this.state.partsOfSpeech.split('\n')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.alphabeticalOrder !== this.props.alphabeticalOrder.join('\n')) {
|
||||
updatedDetails['alphabeticalOrder'] = this.state.alphabeticalOrder.split('\n')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.consonants !== this.props.details.phonology.consonants.join(' ')) {
|
||||
updatedDetails['consonants'] = this.state.consonants.split(' ')
|
||||
.filter((value) => { return value !== '' })
|
||||
|
@ -142,6 +156,28 @@ export class EditDictionaryModal extends Component {
|
|||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.onset !== this.props.details.phonology.phonotactics.onset.join(' ')) {
|
||||
updatedDetails['onset'] = this.state.onset.split(' ')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.nucleus !== this.props.details.phonology.phonotactics.nucleus.join(' ')) {
|
||||
updatedDetails['nucleus'] = this.state.nucleus.split(' ')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.coda !== this.props.details.phonology.phonotactics.coda.join(' ')) {
|
||||
updatedDetails['coda'] = this.state.coda.split(' ')
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
}
|
||||
|
||||
if (this.state.exceptions !== this.props.details.phonology.phonotactics.exceptions) {
|
||||
updatedDetails['exceptions'] = this.state.exceptions;
|
||||
}
|
||||
|
||||
// console.log(updatedDetails);
|
||||
|
||||
this.props.updater.updateDictionaryDetails(updatedDetails)
|
||||
|
|
|
@ -155,13 +155,67 @@ class DictionaryData {
|
|||
return store.set('Lexiconga', updatedValues);
|
||||
}
|
||||
|
||||
get onset () {
|
||||
return store.get('Lexiconga').details.phonology.phonotactics.onset
|
||||
|| defaultDictionary.details.phonology.phonotactics.onset;
|
||||
}
|
||||
|
||||
set onset (array) {
|
||||
assert(Array.isArray(array), 'Onset must be passed as an array');
|
||||
const updatedValues = store.get('Lexiconga');
|
||||
updatedValues.details.phonology.phonotactics.onset = array
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
return store.set('Lexiconga', updatedValues);
|
||||
}
|
||||
|
||||
get nucleus () {
|
||||
return store.get('Lexiconga').details.phonology.phonotactics.nucleus
|
||||
|| defaultDictionary.details.phonology.phonotactics.nucleus;
|
||||
}
|
||||
|
||||
set nucleus (array) {
|
||||
assert(Array.isArray(array), 'Nucleus must be passed as an array');
|
||||
const updatedValues = store.get('Lexiconga');
|
||||
updatedValues.details.phonology.phonotactics.nucleus = array
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
return store.set('Lexiconga', updatedValues);
|
||||
}
|
||||
|
||||
get coda () {
|
||||
return store.get('Lexiconga').details.phonology.phonotactics.coda
|
||||
|| defaultDictionary.details.phonology.phonotactics.coda;
|
||||
}
|
||||
|
||||
set coda (array) {
|
||||
assert(Array.isArray(array), 'Coda must be passed as an array');
|
||||
const updatedValues = store.get('Lexiconga');
|
||||
updatedValues.details.phonology.phonotactics.coda = array
|
||||
.filter((value) => { return value !== '' })
|
||||
.map((value) => { return value.trim() });
|
||||
return store.set('Lexiconga', updatedValues);
|
||||
}
|
||||
|
||||
get exceptions () {
|
||||
return store.get('Lexiconga').details.phonology.phonotactics.exceptions
|
||||
|| defaultDictionary.details.phonology.phonotactics.exceptions;
|
||||
}
|
||||
|
||||
set exceptions (value) {
|
||||
assert(typeof value === 'string', 'Exceptions must be passed as a string.');
|
||||
const updatedValues = store.get('Lexiconga');
|
||||
updatedValues.details.phonology.phonotactics.exceptions = value.trim();
|
||||
return store.set('Lexiconga', updatedValues);
|
||||
}
|
||||
|
||||
get alphabeticalOrder () {
|
||||
return store.get('Lexiconga').alphabeticalOrder
|
||||
|| defaultDictionary.alphabeticalOrder;
|
||||
}
|
||||
|
||||
set alphabeticalOrder (array) {
|
||||
assert(Array.isArray(array), 'Parts of Speech must be passed as an array');
|
||||
assert(Array.isArray(array), 'Alphabetical Order must be passed as an array');
|
||||
const updatedValues = store.get('Lexiconga');
|
||||
updatedValues.alphabeticalOrder = array
|
||||
.filter((value) => { return value !== '' })
|
||||
|
|
Loading…
Reference in New Issue