Added ability to specify dictionary classification as something other than "dictionary" if desired. Also added non-URL helper links for Input components.

This commit is contained in:
Robbie Antenesse 2016-09-29 22:59:25 -06:00
parent 7efddf2edb
commit 12c4d4a275
3 changed files with 27 additions and 6 deletions

View File

@ -24,6 +24,7 @@ export class EditDictionaryForm extends React.Component {
saveOnClose() {
this.props.saveChanges({
name: this.nameField.state.value,
listTypeName: this.listTypeNameField.state.value,
description: this.descriptionField.state.value,
partsOfSpeech: this.partsOfSpeechField.state.value,
allowDuplicates: this.allowDuplicatesField.state.value,
@ -54,6 +55,13 @@ export class EditDictionaryForm extends React.Component {
value={this.props.settings.partsOfSpeech}
ref={(inputComponent) => this.partsOfSpeechField = inputComponent} />
<Input name='Classification'
value={this.props.details.listTypeName}
helperLink={{
action: () => alert('The word used to describe the list of words represented by this dictionary. By default, it is "Dictionary", but it could be "Lexicon" or some other classification.')
}}
ref={(inputComponent) => this.listTypeNameField = inputComponent} />
<Checkbox name='Allow Duplicates'
value={this.props.settings.allowDuplicates}
ref={(inputComponent) => this.allowDuplicatesField = inputComponent} />

View File

@ -38,11 +38,19 @@ export class Input extends React.Component {
showHelperLink() {
if (this.props.helperLink) {
return (
<a className='clickable inline-button' href={this.props.helperLink.url} target='_blank' title={this.props.helperLink.hover}>
{this.props.helperLink.label}
</a>
);
if (this.props.helperLink.url) {
return (
<a className='clickable inline-button' href={this.props.helperLink.url} target='_blank' title={this.props.helperLink.hover}>
{this.props.helperLink.label}
</a>
);
} else {
return (
<Button classes='inline-button'
action={this.props.helperLink.action}
label={this.props.helperLink.label || '?'} />
);
}
}
}

View File

@ -15,6 +15,7 @@ import {Dictionary} from './components/Dictionary';
import {dynamicSort} from './js/helpers';
const defaultDictionaryName = 'New',
defaultListTypeName = 'Dictionary',
defaultDictionaryDescription = 'A new dictionary.',
defaultDictionaryCreatedBy = 'Someone',
defaultDictionaryPartsOfSpeech = 'Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction';
@ -33,6 +34,7 @@ class Lexiconga extends React.Component {
details: {
name: defaultDictionaryName,
listTypeName: defaultListTypeName,
description: defaultDictionaryDescription,
createdBy: defaultDictionaryCreatedBy,
nextWordId: 1,
@ -58,6 +60,7 @@ class Lexiconga extends React.Component {
let updatedSettings = this.state.settings;
updatedDetails.name = changesObject.name;
updatedDetails.listTypeName = changesObject.listTypeName;
updatedDetails.description = changesObject.description;
updatedSettings.partsOfSpeech = changesObject.partsOfSpeech;
@ -164,6 +167,7 @@ class Lexiconga extends React.Component {
saveLocalDictionary() {
let saveDictionary = {
name: this.state.details.name,
listTypeName: this.state.details.listTypeName,
description: this.state.details.description,
createdBy: this.state.details.createdBy,
words: this.state.words,
@ -189,6 +193,7 @@ class Lexiconga extends React.Component {
this.setState({
details: {
name: localDictionary.name,
listTypeName: localDictionary.listTypeName || defaultListTypeName,
description: localDictionary.description,
createdBy: localDictionary.createdBy,
nextWordId: localDictionary.nextWordId,
@ -244,7 +249,7 @@ class Lexiconga extends React.Component {
saveChanges={(changesObject) => this.saveChanges(changesObject)} />
<h1 className="dictionary-name">
{this.state.details.name}
{this.state.details.name} {this.state.details.listTypeName}
</h1>
<InfoDisplay