From 9ecfa40ec754b678b04439ec664d025df862ec80 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 22 Sep 2016 14:05:49 -0600 Subject: [PATCH] Improved Inputs and NewWordForm, and made inter-component references more prolific. Made Inputs able to clear themselves, made NewWordForm able to clear itself and not rely on WordForm, added form validation for NewWordForm. Made Dictionary only display referenced data. Having trouble getting words to update the list correctly. Editing them works, but adding new words duplicates the first word created when rendering. --- src/components/Dictionary.jsx | 86 +++++--------------- src/components/Input.jsx | 10 +-- src/components/NewWordForm.jsx | 97 ++++++++++++++++++++--- src/components/Word.jsx | 71 ++++++++++++----- src/components/WordForm.jsx | 69 ---------------- src/index.jsx | 100 ++++++++++++++++++++---- src/js/dependencies/removeDiacritics.js | 6 +- src/js/helpers.js | 2 + 8 files changed, 252 insertions(+), 189 deletions(-) delete mode 100644 src/components/WordForm.jsx diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index 4165e89..a00e99b 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -1,6 +1,5 @@ import React from 'react'; -import {Word} from './Word'; import {Button} from './Button'; export class Dictionary extends React.Component { @@ -8,61 +7,20 @@ export class Dictionary extends React.Component { super(props); this.state = { - dictionary: this.props.reference, - name: this.props.reference.name, - description: this.props.reference.description, - createdBy: this.props.reference.createdBy, - words: this.props.reference.words, - 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 + // 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 } - - // this.addTestWord(); - } - - showWords() { - let words = this.state.words.map((word, index) => { - return ; - // return ; - }); - - return
{words}
; - } - - addTestWord() { - this.setState({ - words: this.state.words.concat([{ - name: 'word', - pronunciation: 'pronunciation', - partOfSpeech: 'partOfSpeech', - simpleDefinition: 'simpleDefinition', - longDefinition: 'longDefinition', - wordId: 'wordId' - }]) - }, () => console.log(this.state.words)); - } - - changeNameAgain() { - let updateDictionary = this.state.dictionary; - updateDictionary.name = 'something else again' - this.setState({ - dictionary: updateDictionary - }) } render() { @@ -73,27 +31,21 @@ export class Dictionary extends React.Component {

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

- Dictionary is complete: {this.state.isComplete.toString()} + Dictionary is complete: {this.state.settings.isComplete.toString()}
- {this.showWords()} + {this.props.children}
-