Change phonotactics exceptions to notes where used

This commit is contained in:
Robbie Antenesse 2019-07-05 11:44:53 -06:00 committed by Robbie Antenesse
parent 686a7fa542
commit 1c2570684d
8 changed files with 41 additions and 39 deletions

View File

@ -305,8 +305,8 @@
</label>
</div>
</div>
<label>Exceptions <small>(Markdown-enabled)</small><br>
<textarea id="editExceptions"></textarea>
<label>Notes <small>(Markdown-enabled)</small><br>
<textarea id="editPhonotacticsNotes"></textarea>
</label>
<h3>Orthography</h3>
<label>Notes <small>(Markdown-enabled)</small><a class="label-button maximize-button">Maximize</a><br>

View File

@ -1,6 +1,6 @@
import { getTimestampInSeconds } from "./helpers";
export const MIGRATE_VERSION = '2.0.1';
export const MIGRATE_VERSION = '2.1.0';
export const DEFAULT_DICTIONARY = {
name: 'New',
specification: 'Dictionary',

View File

@ -13,8 +13,8 @@ export function updateDictionary () {
export function openEditModal() {
const { name, specification, description, partsOfSpeech } = window.currentDictionary;
const { consonants, vowels, blends, phonotactics } = window.currentDictionary.details.phonology;
const { orthography, grammar } = window.currentDictionary.details;
const { consonants, vowels, blends } = window.currentDictionary.details.phonology;
const { phonotactics, orthography, grammar } = window.currentDictionary.details;
const { allowDuplicates, caseSensitive, sortByDefinition, theme, isPublic } = window.currentDictionary.settings;
document.getElementById('editName').value = name;
@ -28,7 +28,7 @@ export function openEditModal() {
document.getElementById('editOnset').value = phonotactics.onset.join(',');
document.getElementById('editNucleus').value = phonotactics.nucleus.join(',');
document.getElementById('editCoda').value = phonotactics.coda.join(',');
document.getElementById('editExceptions').value = phonotactics.exceptions;
document.getElementById('editPhonotacticsNotes').value = phonotactics.notes;
document.getElementById('editOrthography').value = orthography.notes;
document.getElementById('editGrammar').value = grammar.notes;
@ -54,10 +54,10 @@ export function saveEditModal() {
window.currentDictionary.details.phonology.consonants = document.getElementById('editConsonants').value.split(' ').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.vowels = document.getElementById('editVowels').value.split(' ').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.blends = document.getElementById('editBlends').value.split(' ').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.phonotactics.onset = document.getElementById('editOnset').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.phonotactics.nucleus = document.getElementById('editNucleus').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.phonotactics.coda = document.getElementById('editCoda').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonology.phonotactics.exceptions = removeTags(document.getElementById('editExceptions').value.trim());
window.currentDictionary.details.phonotactics.onset = document.getElementById('editOnset').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonotactics.nucleus = document.getElementById('editNucleus').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonotactics.coda = document.getElementById('editCoda').value.split(',').map(val => val.trim()).filter(val => val !== '');
window.currentDictionary.details.phonotactics.notes = removeTags(document.getElementById('editPhonotacticsNotes').value.trim());
window.currentDictionary.details.orthography.notes = removeTags(document.getElementById('editOrthography').value.trim());
window.currentDictionary.details.grammar.notes = removeTags(document.getElementById('editGrammar').value.trim());

View File

@ -1,4 +1,5 @@
import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants";
import { saveDictionary } from "./dictionaryManagement";
export default function migrate() {
if (window.location.pathname === '/') {
@ -103,7 +104,8 @@ export function migrateDictionary() {
migrated = true;
} else if (window.currentDictionary.version !== MIGRATE_VERSION) {
switch (window.currentDictionary.version) {
case '2.0.1': {
default: console.error('Unknown version'); break;
case '2.0.0': {
window.currentDictionary.details.phonotactics = Object.assign({}, window.currentDictionary.details.phonology.phonotactics);
delete window.currentDictionary.details.phonology.phonotactics;
window.currentDictionary.details.phonotactics.notes = window.currentDictionary.details.phonotactics.exceptions;
@ -111,10 +113,10 @@ export function migrateDictionary() {
// Add window.currentDictionary.details.orthography.translations = [];
// Add window.currentDictionary.custom.css = '';
window.currentDictionary = Object.assign({}, DEFAULT_DICTIONARY, window.currentDictionary);
window.currentDictionary.version = MIGRATE_VERSION;
migrated = true;
break;
// break; By skipping the break, all migrations can happen in sequence.
}
default: console.error('Unknown version'); break;
}
}

View File

@ -75,14 +75,14 @@ export function renderDescription() {
export function renderDetails() {
const { partsOfSpeech, alphabeticalOrder } = window.currentDictionary;
const { phonology, orthography, grammar } = window.currentDictionary.details;
const { phonology, phonotactics, orthography, grammar } = window.currentDictionary.details;
const partsOfSpeechHTML = `<p><strong>Parts of Speech:</strong> ${partsOfSpeech.map(partOfSpeech => '<span class="tag">' + partOfSpeech + '</span>').join(' ')}</p>`;
const alphabeticalOrderHTML = `<p><strong>Alphabetical Order:</strong> ${
(alphabeticalOrder.length > 0 ? alphabeticalOrder : ['English Alphabet']).map(letter => `<span class="tag">${letter}</span>`).join(' ')
}</p>`;
const generalHTML = `<h3>General</h3>${partsOfSpeechHTML}${alphabeticalOrderHTML}`;
const { consonants, vowels, blends, phonotactics } = phonology
const { consonants, vowels, blends } = phonology
const consonantHTML = `<p><strong>Consonants:</strong> ${consonants.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>`;
const vowelHTML = `<p><strong>Vowels:</strong> ${vowels.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>`;
const blendHTML = blends.length > 0 ? `<p><strong>Polyphthongs&nbsp;/&nbsp;Blends:</strong> ${blends.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>` : '';
@ -93,18 +93,18 @@ export function renderDetails() {
</div>
${blendHTML}`;
const { onset, nucleus, coda, exceptions } = phonotactics;
const { onset, nucleus, coda } = phonotactics;
const onsetHTML = `<p><strong>Onset:</strong> ${onset.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>`;
const nucleusHTML = `<p><strong>Nucleus:</strong> ${nucleus.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>`;
const codaHTML = `<p><strong>Coda:</strong> ${coda.map(letter => `<span class="tag">${letter}</span>`).join(' ')}</p>`;
const exceptionsHTML = exceptions.trim().length > 0 ? '<p><strong>Exceptions:</strong></p><div>' + md(removeTags(exceptions)) + '</div>' : '';
const phonotacticsNotesHTML = phonotactics.notes.trim().length > 0 ? '<p><strong>Notes:</strong></p><div>' + md(removeTags(phonotactics.notes)) + '</div>' : '';
const phonotacticsHTML = `<h3>Phonotactics</h3>
<div class="split three">
<div>${onsetHTML}</div>
<div>${nucleusHTML}</div>
<div>${codaHTML}</div>
</div>
${exceptionsHTML}`;
${phonotacticsNotesHTML}`;
const orthographyHTML = '<h3>Orthography</h3><p><strong>Notes:</strong></p><div>' + md(removeTags(orthography.notes)) + '</div>';
const grammarHTML = '<h3>Grammar</h3><p><strong>Notes:</strong></p><div>' + md(removeTags(grammar.notes)) + '</div>';

View File

@ -33,7 +33,7 @@ class Dictionary {
$insert_dictionary = $this->db->execute($insert_dictionary_query, array($new_id, $user, 'A new dictionary.', time()));
if ($insert_dictionary === true) {
$insert_linguistics_query = "INSERT INTO dictionary_linguistics (dictionary, parts_of_speech, exceptions, orthography_notes, grammar_notes)
$insert_linguistics_query = "INSERT INTO dictionary_linguistics (dictionary, parts_of_speech, phonotactics_notes, orthography_notes, grammar_notes)
VALUES ($new_id, ?, ?, ?, ?)";
$insert_linguistics = $this->db->execute($insert_linguistics_query, array(
$this->defaults['partsOfSpeech'],
@ -109,12 +109,12 @@ VALUES ($new_id, ?, ?, ?, ?)";
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
'vowels' => $result['vowels'] !== '' ? explode(' ', $result['vowels']) : array(),
'blends' => $result['blends'] !== '' ? explode(' ', $result['blends']) : array(),
'phonotactics' => array(
'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(),
'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(),
'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(),
'exceptions' => $result['exceptions'],
),
),
'phonotactics' => array(
'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(),
'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(),
'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(),
'notes' => $result['phonotactics_notes'],
),
'orthography' => array(
'notes' => $result['orthography_notes'],
@ -260,12 +260,12 @@ VALUES ($new_id, ?, ?, ?, ?)";
'consonants' => $result['consonants'] !== '' ? explode(' ', $result['consonants']) : array(),
'vowels' => $result['vowels'] !== '' ? explode(' ', $result['vowels']) : array(),
'blends' => $result['blends'] !== '' ? explode(' ', $result['blends']) : array(),
'phonotactics' => array(
'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(),
'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(),
'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(),
'exceptions' => $result['exceptions'],
),
),
'phonotactics' => array(
'onset' => $result['onset'] !== '' ? explode(',', $result['onset']) : array(),
'nucleus' => $result['nucleus'] !== '' ? explode(',', $result['nucleus']) : array(),
'coda' => $result['coda'] !== '' ? explode(',', $result['coda']) : array(),
'notes' => $result['phonotactics_notes'],
),
'orthography' => array(
'notes' => $result['orthography_notes'],
@ -326,7 +326,7 @@ SET parts_of_speech=:parts_of_speech,
onset=:onset,
nucleus=:nucleus,
coda=:coda,
exceptions=:exceptions,
phonotactics_notes=:phonotactics_notes,
orthography_notes=:orthography_notes,
grammar_notes=:grammar_notes
WHERE dictionary=$dictionary";
@ -337,10 +337,10 @@ WHERE dictionary=$dictionary";
':consonants' => implode(' ', $linguistics['phonology']['consonants']),
':vowels' => implode(' ', $linguistics['phonology']['vowels']),
':blends' => implode(' ', $linguistics['phonology']['blends']),
':onset' => implode(',', $linguistics['phonology']['phonotactics']['onset']),
':nucleus' => implode(',', $linguistics['phonology']['phonotactics']['nucleus']),
':coda' => implode(',', $linguistics['phonology']['phonotactics']['coda']),
':exceptions' => $linguistics['phonology']['phonotactics']['exceptions'],
':onset' => implode(',', $linguistics['phonotactics']['onset']),
':nucleus' => implode(',', $linguistics['phonotactics']['nucleus']),
':coda' => implode(',', $linguistics['phonotactics']['coda']),
':phonotactics_notes' => $linguistics['phonotactics']['notes'],
':orthography_notes' => $linguistics['orthography']['notes'],
':grammar_notes' => $linguistics['grammar']['notes'],
));

View File

@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS `dictionary_linguistics` (
`onset` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated',
`nucleus` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated',
`coda` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'Comma-separated',
`exceptions` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown',
`phonotactics_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown',
`orthography_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown',
`grammar_notes` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT 'Markdown',
UNIQUE KEY `dictionary` (`dictionary`)

View File

@ -306,8 +306,8 @@
</label>
</div>
</div>
<label>Exceptions <small>(Markdown-enabled)</small><br>
<textarea id="editExceptions"></textarea>
<label>Notes <small>(Markdown-enabled)</small><br>
<textarea id="editPhonotacticsNotes"></textarea>
</label>
<h3>Orthography</h3>
<label>Notes <small>(Markdown-enabled)</small><a class="label-button maximize-button">Maximize</a><br>