diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index a00e99b..5764e9b 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -1,53 +1,56 @@ import React from 'react'; +import {Word} from './Word'; import {Button} from './Button'; export class Dictionary extends React.Component { constructor(props) { super(props); + } - this.state = { - // name: this.props.reference.name, - // description: this.props.reference.description, - // createdBy: this.props.reference.createdBy, - // nextWordId: this.props.reference.nextWordId, - // externalID: this.props.reference.externalID, - // allowDuplicates: this.props.reference.settings.allowDuplicates, - // caseSensitive: this.props.reference.settings.caseSensitive, - // partsOfSpeech: this.props.reference.settings.partOfSpeech, - // sortByEquivalent: this.props.reference.settings.sortByEquivalent, - // isComplete: this.props.reference.settings.isComplete, - // isPublic: this.props.reference.settings.isPublic - dictionary: this.props.parent.state.details, - settings: this.props.parent.state.settings + showWords() { + let words = this.props.words.map((word, index) => { + return this.passWordAndUpdate(index, wordObject)} />; + }); + + if (this.showConsoleMessages) { + console.log('Showing these words:'); + console.log(words); } + + return
{words}
; + } + + passWordAndUpdate(index, wordObject) { + console.log('Passing edited up: ' + wordObject.name); + this.props.updateWord(index, wordObject); } render() { return (

- {this.state.dictionary.name} + {this.props.details.name}

- {this.state.dictionary.createdBy} + {this.props.details.createdBy}

- Dictionary is complete: {this.state.settings.isComplete.toString()} + Dictionary is complete: {this.props.settings.isComplete.toString()}
- {this.props.children} + {this.showWords()}
- -
); } diff --git a/src/components/Input.jsx b/src/components/Input.jsx index 0b7eee1..3d503bf 100644 --- a/src/components/Input.jsx +++ b/src/components/Input.jsx @@ -56,6 +56,6 @@ export class Input extends React.Component { } Input.defaultProps = { - name: 'Field', + name: '', doValidate: true }; \ No newline at end of file diff --git a/src/components/Word.jsx b/src/components/Word.jsx index 98d5fdc..232ef43 100644 --- a/src/components/Word.jsx +++ b/src/components/Word.jsx @@ -1,18 +1,24 @@ import React from 'react'; +import {Input} from './Input'; +import {TextArea} from './TextArea'; import {Button} from './Button'; +const saveIcon = 💾; +const editIcon = 🖉; + export class Word extends React.Component { constructor(props) { super(props); this.state = { - name: this.props.name, - pronunciation: this.props.pronunciation, - partOfSpeech: ((this.props.partOfSpeech.length > 0) ? this.props.partOfSpeech : " "), - simpleDefinition: this.props.simpleDefinition, - longDefinition: this.props.longDefinition - } + editWord: false, + editName: false, + editPronunciation: false, + editPartOfSpeech: false, + editSimpleDefinition: false, + editLongDefinition: false + }; } /* @@ -26,65 +32,210 @@ export class Word extends React.Component { } */ + showName() { + let editButton; + if (this.state.editName) { + if (this.state.editWord) { + editButton = ( +