From 9b7e797aefec1e855886f7d133aa8b44970e776e Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Sun, 20 Aug 2017 14:41:08 -0600 Subject: [PATCH] Expand and use default dictionary and Updater --- src/components/MainDisplay.jsx | 25 +--------- src/index.jsx | 19 +++++-- src/managers/DictionaryData.js | 91 +++++++++++++++++++++++++++++++++- src/managers/Updater.js | 17 +++++++ 4 files changed, 124 insertions(+), 28 deletions(-) diff --git a/src/components/MainDisplay.jsx b/src/components/MainDisplay.jsx index bd2f630..caad45d 100644 --- a/src/components/MainDisplay.jsx +++ b/src/components/MainDisplay.jsx @@ -27,29 +27,8 @@ export const MainDisplay = ({ dictionaryInfo, wordsToDisplay, updateDisplay, upd specification={ dictionaryInfo.specification } description={ dictionaryInfo.description } partsOfSpeech={ dictionaryInfo.partsOfSpeech } - alphabeticalOrder={['b', 'p', 't', 'd', 'a', 'o', 'j', 'e']} - details={{ - phonology: { - consonants: ['b', 'p', 'd', 't', 'j'], - vowels: ['a', 'o', 'e'], - blends: ['ae', 'oe', 'tj', 'dy'], - phonotactics: { - onset: ['b', 'p', 'j'], - nucleus: ['a', 'o', 'e'], - coda: ['any'], - exceptions: 'There are no exceptions', - }, - }, - grammar: { - content: 'The rules of the language are simple: just follow them!' - }, - custom: [ - { - name: 'Test Tab', - content: 'This is a test tab to test how custom tabs work!', - } - ], - }} + details={ dictionaryInfo.details } + alphabeticalOrder={ dictionaryInfo.alphabeticalOrder } /> { return value !== '' }) + .map((value) => { return value.trim() }); + return store.set('Lexiconga', updatedValues); + } + + get vowels () { + return store.get('Lexiconga').details.phonology.vowels + || defaultDictionary.details.phonology.vowels; + } + + set vowels (array) { + assert(Array.isArray(array), 'Vowels must be passed as an array'); + const updatedValues = store.get('Lexiconga'); + updatedValues.details.phonology.vowels = array + .filter((value) => { return value !== '' }) + .map((value) => { return value.trim() }); + return store.set('Lexiconga', updatedValues); + } + + get blends () { + return store.get('Lexiconga').details.phonology.blends + || defaultDictionary.details.phonology.blends; + } + + set blends (array) { + assert(Array.isArray(array), 'Blends must be passed as an array'); + const updatedValues = store.get('Lexiconga'); + updatedValues.details.phonology.blends = array + .filter((value) => { return value !== '' }) + .map((value) => { return 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'); + const updatedValues = store.get('Lexiconga'); + updatedValues.alphabeticalOrder = array + .filter((value) => { return value !== '' }) + .map((value) => { return value.trim() }); + return store.set('Lexiconga', updatedValues); + } + get wordsPromise () { return wordDb.words.toArray(); } diff --git a/src/managers/Updater.js b/src/managers/Updater.js index 9a9f34e..4fbd114 100644 --- a/src/managers/Updater.js +++ b/src/managers/Updater.js @@ -46,6 +46,23 @@ export class Updater { this.dictionary.partsOfSpeech = dicitonaryDetails.partsOfSpeech; } + if (dicitonaryDetails.consonants) { + this.dictionary.consonants = dicitonaryDetails.consonants; + updatedDetails['details'] = this.dictionary.details; + } + + if (dicitonaryDetails.vowels) { + this.dictionary.vowels = dicitonaryDetails.vowels; + updatedDetails['details'] = this.dictionary.details; + } + + if (dicitonaryDetails.blends) { + this.dictionary.blends = dicitonaryDetails.blends; + updatedDetails['details'] = this.dictionary.details; + } + + console.log(updatedDetails); + if (updatedDetails.isEmpty()) { reject('No dictionary details have changed.'); } else {