Change "Allow Duplicates" to "Prevent Duplicates"

This commit is contained in:
Robbie Antenesse 2019-05-06 14:30:57 -06:00
parent c86dfb06b6
commit 80e9a06235
3 changed files with 24 additions and 6 deletions

View File

@ -197,13 +197,13 @@
</section>
<section id="editSettingsTab" style="display:none;">
<label>Allow Duplicate Words
<input type="checkbox" id="editAllowDuplicates"><br>
<small>Checking this box will allow any number of the exact same spelling of a word to be added</small>
<label>Prevent Duplicate Words
<input type="checkbox" id="editPreventDuplicates"><br>
<small>Checking this box will prevent the creation of words with the exact same spelling.</small>
</label>
<label>Words are Case-Sensitive
<input type="checkbox" id="editCaseSensitive"><br>
<small>Checking this box will allow any words spelled the same but with different capitalization to be added.</small>
<small>Checking this box will allow the creation of words with the exact same spelling if their capitalization is different.</small>
</label>
<label>Sort by Definition
<input type="checkbox" id="editSortByDefinition"><br>

View File

@ -28,8 +28,9 @@ export function openEditModal() {
document.getElementById('editOrthography').value = orthography.notes;
document.getElementById('editGrammar').value = grammar.notes;
document.getElementById('editAllowDuplicates').checked = allowDuplicates;
document.getElementById('editPreventDuplicates').checked = !allowDuplicates;
document.getElementById('editCaseSensitive').checked = caseSensitive;
if (allowDuplicates) document.getElementById('editCaseSensitive').disabled = true;
document.getElementById('editSortByDefinition').checked = sortByDefinition;
document.getElementById('editIsComplete').checked = isComplete;
document.getElementById('editIsPublic').checked = isPublic;
@ -54,7 +55,7 @@ export function save() {
window.currentDictionary.details.orthography.notes = removeTags(document.getElementById('editOrthography').value.trim());
window.currentDictionary.details.grammar.notes = removeTags(document.getElementById('editGrammar').value.trim());
window.currentDictionary.settings.allowDuplicates = document.getElementById('editAllowDuplicates').checked;
window.currentDictionary.settings.allowDuplicates = !document.getElementById('editPreventDuplicates').checked;
window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked;
window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked;
window.currentDictionary.settings.isComplete = document.getElementById('editIsComplete').checked;

View File

@ -35,6 +35,7 @@ function setupDetailsTabs() {
});
});
setupEditFormTabs();
setupEditFormInteractions();
setupEditFormButtons();
}
@ -52,6 +53,22 @@ function setupEditFormTabs() {
});
}
function setupEditFormInteractions() {
const preventDuplicatesBox = document.getElementById('editPreventDuplicates');
preventDuplicatesBox.addEventListener('change', () => {
console.log('changed');
const caseSensitiveBox = document.getElementById('editCaseSensitive');
if (preventDuplicatesBox.checked) {
console.log('checked');
caseSensitiveBox.disabled = false;
} else {
console.log('unchecked');
caseSensitiveBox.disabled = true;
caseSensitiveBox.checked = false;
}
});
}
function setupEditFormButtons() {
document.getElementById('editSave').addEventListener('click', () => save());
document.getElementById('editSaveAndClose').addEventListener('click', () => saveAndClose());