diff --git a/src/components/MainDisplay.jsx b/src/components/MainDisplay.jsx
index 7f1cd6d..4453d5c 100644
--- a/src/components/MainDisplay.jsx
+++ b/src/components/MainDisplay.jsx
@@ -56,8 +56,8 @@ export class MainDisplay extends Component {
@@ -74,6 +74,7 @@ export class MainDisplay extends Component {
description={ dictionaryInfo.description }
partsOfSpeech={ dictionaryInfo.partsOfSpeech }
details={ dictionaryInfo.details }
+ settings={ dictionaryInfo.settings }
alphabeticalOrder={ dictionaryInfo.alphabeticalOrder }
/>
diff --git a/src/components/display/DictionaryDetails/index.jsx b/src/components/display/DictionaryDetails/index.jsx
index 5fca623..c147832 100644
--- a/src/components/display/DictionaryDetails/index.jsx
+++ b/src/components/display/DictionaryDetails/index.jsx
@@ -27,6 +27,7 @@ export class DictionaryDetails extends Component {
partsOfSpeech: PropTypes.array,
alphabeticalOrder: PropTypes.array,
details: PropTypes.object,
+ settings: PropTypes.object,
updater: PropTypes.object,
}, props, 'prop', 'DictionaryDetails');
@@ -103,7 +104,6 @@ export class DictionaryDetails extends Component {
render () {
const { currentDisplay } = this.state;
-
return (
@@ -121,12 +121,14 @@ export class DictionaryDetails extends Component {
diff --git a/src/components/management/EditDictionaryModal/EditSettingsForm.jsx b/src/components/management/EditDictionaryModal/EditSettingsForm.jsx
new file mode 100644
index 0000000..9db6c8e
--- /dev/null
+++ b/src/components/management/EditDictionaryModal/EditSettingsForm.jsx
@@ -0,0 +1,145 @@
+import Inferno from 'inferno';
+import PropTypes from 'prop-types';
+
+import { LargeTextArea } from '../LargeTextArea';
+
+export const EditSettingsForm = (props) => {
+ PropTypes.checkPropTypes({
+ editDictionaryModal: PropTypes.object.isRequired,
+ allowDuplicates: PropTypes.bool.isRequired,
+ caseSensitive: PropTypes.bool.isRequired,
+ sortByDefinition: PropTypes.bool.isRequired,
+ isComplete: PropTypes.bool.isRequired,
+ specification: PropTypes.string.isRequired,
+ isLoggedIn: PropTypes.bool.isRequired,
+ isPublic: PropTypes.bool.isRequired,
+ }, props, 'prop', 'EditSettingsForm');
+
+ const {
+ editDictionaryModal,
+ allowDuplicates,
+ caseSensitive,
+ sortByDefinition,
+ isComplete,
+ specification,
+ isLoggedIn,
+ isPublic,
+ } = props;
+ return (
+
+
+
+
+
+ Allow Duplicate Words
+ { ' ' }
+ {
+ editDictionaryModal.setState({
+ allowDuplicates: event.target.checked,
+ hasChanged: event.target.checked != editDictionaryModal.props.allowDuplicates,
+ });
+ }} />
+
+
+ Checking this box will allow any number of the exact same spelling of a word to be added
+
+
+
+
+
+
+
+ Words are Case-Sensitive
+ { ' ' }
+ {
+ editDictionaryModal.setState({
+ caseSensitive: event.target.checked,
+ hasChanged: event.target.checked != editDictionaryModal.props.caseSensitive,
+ });
+ }} />
+
+
+ Checking this box will allow any words spelled the same but with different capitalization to be added.
+
+
+
+
+
+
+
+ Sort by Definition
+ { ' ' }
+ {
+ editDictionaryModal.setState({
+ sortByDefinition: event.target.checked,
+ hasChanged: event.target.checked != editDictionaryModal.props.sortByDefinition,
+ });
+ }} />
+
+
+ Checking this box will sort the words in alphabetical order based on the Definition instead of the Word.
+
+
+
+
+
+
+
+ Mark Complete
+ { ' ' }
+ {
+ editDictionaryModal.setState({
+ isComplete: event.target.checked,
+ hasChanged: event.target.checked != editDictionaryModal.props.isComplete,
+ });
+ }} />
+
+
+ Checking this box will mark your { specification } as "complete", and you will not be able to alter it until this checkbox is unchecked.
+
+
+
+
+ {isLoggedIn
+ && (
+
+
+
+ Make Public
+ { ' ' }
+ {
+ editDictionaryModal.setState({
+ isPublic: event.target.checked,
+ hasChanged: event.target.checked != editDictionaryModal.props.isPublic,
+ });
+ }} />
+
+
+ Checking this box will make your { specification } as public.
+ {
+ isPublic
+ ? [ , 'Use this link to share it: PUBLIC_LINK']
+ : ' You will receive a public link that you can share with others.'
+ }
+
+
+
+ )
+ }
+
+
+ );
+}
diff --git a/src/components/management/EditDictionaryModal/index.jsx b/src/components/management/EditDictionaryModal/index.jsx
index 2ad3171..cd4383a 100644
--- a/src/components/management/EditDictionaryModal/index.jsx
+++ b/src/components/management/EditDictionaryModal/index.jsx
@@ -7,6 +7,7 @@ import { Modal } from '../../structure/Modal';
import { EditDictionaryForm } from './EditDictionaryForm';
import { EditLinguisticsForm } from './EditLinguisticsForm';
+import { EditSettingsForm } from './EditSettingsForm';
const DISPLAY = {
DETAILS: 1,
@@ -25,6 +26,8 @@ export class EditDictionaryModal extends Component {
alphabeticalOrder: PropTypes.array,
partsOfSpeech: PropTypes.array,
details: PropTypes.object,
+ settings: PropTypes.object,
+ isLoggedIn: PropTypes.bool,
}, props, 'prop', 'EditDictionaryModal');
this.state = {
@@ -34,6 +37,7 @@ export class EditDictionaryModal extends Component {
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(' '),
@@ -44,6 +48,12 @@ export class EditDictionaryModal extends Component {
exceptions: props.details.phonology.phonotactics.exceptions,
orthographyNotes: props.details.orthography.notes,
+ allowDuplicates: props.settings.allowDuplicates,
+ caseSensitive: props.settings.caseSensitive,
+ sortByDefinition: props.settings.sortByDefinition,
+ isComplete: props.settings.isComplete,
+ isPublic: props.settings.isPublic,
+
hasChanged: false,
}
}
@@ -100,9 +110,16 @@ export class EditDictionaryModal extends Component {
case DISPLAY.SETTINGS : {
displayJSX = (
-
+
);
break;
}
@@ -192,6 +209,26 @@ export class EditDictionaryModal extends Component {
updatedDetails['orthographyNotes'] = this.state.orthographyNotes;
}
+ if (this.state.allowDuplicates !== this.props.settings.allowDuplicates) {
+ updatedDetails['allowDuplicates'] = this.state.allowDuplicates;
+ }
+
+ if (this.state.caseSensitive !== this.props.settings.caseSensitive) {
+ updatedDetails['caseSensitive'] = this.state.caseSensitive;
+ }
+
+ if (this.state.sortByDefinition !== this.props.settings.sortByDefinition) {
+ updatedDetails['sortByDefinition'] = this.state.sortByDefinition;
+ }
+
+ if (this.state.isComplete !== this.props.settings.isComplete) {
+ updatedDetails['isComplete'] = this.state.isComplete;
+ }
+
+ if (this.state.isPublic !== this.props.settings.isPublic) {
+ updatedDetails['isPublic'] = this.state.isPublic;
+ }
+
// console.log(updatedDetails);
this.props.updater.updateDictionaryDetails(updatedDetails)
diff --git a/src/index.jsx b/src/index.jsx
index 68da3e0..1e8f958 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -28,6 +28,7 @@ class App extends Component {
description: dictionary.description,
partsOfSpeech: dictionary.partsOfSpeech,
details: dictionary.details,
+ settings: dictionary.settings,
alphabeticalOrder: dictionary.alphabeticalOrder,
displayedWords: [],
@@ -46,6 +47,7 @@ class App extends Component {
description,
partsOfSpeech,
details,
+ settings,
alphabeticalOrder,
} = this.state;
@@ -55,6 +57,7 @@ class App extends Component {
description,
partsOfSpeech,
details,
+ settings,
alphabeticalOrder,
};
}
diff --git a/src/managers/DictionaryData.js b/src/managers/DictionaryData.js
index bdf1046..f05df96 100644
--- a/src/managers/DictionaryData.js
+++ b/src/managers/DictionaryData.js
@@ -258,7 +258,7 @@ class DictionaryData {
}
set allowDuplicates (value) {
- assert(typeof value === 'bool', 'allowDuplicates must be passed as a boolean.');
+ assert(typeof value === 'boolean', 'allowDuplicates must be passed as a boolean.');
const updatedValues = store.get('Lexiconga');
updatedValues.settings.allowDuplicates = value;
return store.set('Lexiconga', updatedValues);
@@ -270,7 +270,7 @@ class DictionaryData {
}
set caseSensitive (value) {
- assert(typeof value === 'bool', 'caseSensitive must be passed as a boolean.');
+ assert(typeof value === 'boolean', 'caseSensitive must be passed as a boolean.');
const updatedValues = store.get('Lexiconga');
updatedValues.settings.caseSensitive = value;
return store.set('Lexiconga', updatedValues);
@@ -282,7 +282,7 @@ class DictionaryData {
}
set sortByDefinition (value) {
- assert(typeof value === 'bool', 'sortByDefinition must be passed as a boolean.');
+ assert(typeof value === 'boolean', 'sortByDefinition must be passed as a boolean.');
const updatedValues = store.get('Lexiconga');
updatedValues.settings.sortByDefinition = value;
return store.set('Lexiconga', updatedValues);
@@ -294,7 +294,7 @@ class DictionaryData {
}
set isComplete (value) {
- assert(typeof value === 'bool', 'isComplete must be passed as a boolean.');
+ assert(typeof value === 'boolean', 'isComplete must be passed as a boolean.');
const updatedValues = store.get('Lexiconga');
updatedValues.settings.isComplete = value;
return store.set('Lexiconga', updatedValues);
@@ -306,7 +306,7 @@ class DictionaryData {
}
set isPublic (value) {
- assert(typeof value === 'bool', 'isPublic must be passed as a boolean.');
+ assert(typeof value === 'boolean', 'isPublic must be passed as a boolean.');
const updatedValues = store.get('Lexiconga');
updatedValues.settings.isPublic = value;
return store.set('Lexiconga', updatedValues);
diff --git a/src/managers/Updater.js b/src/managers/Updater.js
index 17eedc1..808515f 100644
--- a/src/managers/Updater.js
+++ b/src/managers/Updater.js
@@ -34,19 +34,30 @@ export class Updater {
'exceptions',
'orthographyNotes',
];
+ const settingKeys = [
+ 'allowDuplicates',
+ 'caseSensitive',
+ 'sortByDefinition',
+ 'isComplete',
+ 'isPublic',
+ ];
for (const key in dictionaryDetails) {
this.dictionary[key] = dictionaryDetails[key];
- if (!detailKeys.includes(key)) {
+ if (!detailKeys.includes(key) && !settingKeys.includes(key)) {
updatedDetails[key] = dictionaryDetails[key];
}
}
- if (Object.keys(dictionaryDetails).some(key => { return detailKeys.includes(key) })) {
+ if (Object.keys(dictionaryDetails).some(key => detailKeys.includes(key))) {
updatedDetails['details'] = this.dictionary.details;
}
+ if (Object.keys(dictionaryDetails).some(key => settingKeys.includes(key))) {
+ updatedDetails['settings'] = this.dictionary.settings;
+ }
+
console.log(updatedDetails);
if (updatedDetails.isEmpty()) {