Only render MakePublic if logged in

This commit is contained in:
Robbie Antenesse 2019-05-24 15:37:15 -06:00
parent b1140eebb7
commit 6b46eaa148
4 changed files with 20 additions and 7 deletions

View File

@ -286,10 +286,6 @@
<input type="checkbox" id="editSortByDefinition"><br>
<small>Checking this box will sort the words in alphabetical order based on the Definition instead of the Word.</small>
</label>
<label>Make Public
<input type="checkbox" id="editIsPublic"><br>
<small>Checking this box will make this public via a link you can share with others.</small>
</label>
</section>
<section id="editActionsTab" style="display:none;">

View File

@ -2,7 +2,7 @@ import { request } from "./helpers";
import { saveToken } from "./utilities";
import { addMessage } from "../utilities";
import { setupLogoutButton } from "./setupListeners";
import { renderAccountSettings, renderAccountActions } from "./render";
import { renderAccountSettings, renderAccountActions, renderMakePublic } from "./render";
import { uploadWholeDictionary, syncDictionary } from "./sync";
import { setCookie } from "../StackOverflow/cookie";
@ -143,6 +143,7 @@ export function triggerLoginChanges() {
loginButton.parentElement.removeChild(loginButton);
setupLogoutButton(logoutButton);
renderMakePublic();
renderAccountSettings();
renderAccountActions();
}

View File

@ -53,6 +53,16 @@ export function renderLoginForm() {
setupLoginModal(loginModal);
}
export function renderMakePublic() {
const editSettingsTab = document.getElementById('editSettingsTab');
const editSettingsTabHTML = `<label>Make Public
<input type="checkbox" id="editIsPublic"><br>
<small>Checking this box will make this public via a link you can share with others.</small>
</label>
`;
editSettingsTab.innerHTML += editSettingsTabHTML;
}
export function renderAccountSettings() {
const accountSettingsColumn = document.getElementById('accountSettings');
const accountSettingsHTML = `<h3>Account Settings</h3>

View File

@ -35,7 +35,9 @@ export function openEditModal() {
document.getElementById('editCaseSensitive').checked = caseSensitive;
if (allowDuplicates) document.getElementById('editCaseSensitive').disabled = true;
document.getElementById('editSortByDefinition').checked = sortByDefinition;
document.getElementById('editIsPublic').checked = isPublic;
if (hasToken()) {
document.getElementById('editIsPublic').checked = isPublic;
}
document.getElementById('editModal').style.display = '';
}
@ -61,7 +63,11 @@ export function saveEditModal() {
window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked;
const needsReSort = window.currentDictionary.settings.sortByDefinition !== document.getElementById('editSortByDefinition').checked;
window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked;
window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked;
if (hasToken()) {
window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked;
} else {
window.currentDictionary.settings.isPublic = false;
}
addMessage('Saved ' + window.currentDictionary.specification + ' Successfully');
saveDictionary();