From 63a04935862d25a4564945030caa58a1a45f896f Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 23 May 2019 17:32:31 -0600 Subject: [PATCH] Add Create New Dictionary button in account actions --- src/js/account/dictionaryManagement.js | 13 ++++++++++++- src/js/account/render.js | 4 +++- src/js/account/setupListeners.js | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/js/account/dictionaryManagement.js b/src/js/account/dictionaryManagement.js index fdfd3c9..a1b2390 100644 --- a/src/js/account/dictionaryManagement.js +++ b/src/js/account/dictionaryManagement.js @@ -1,7 +1,18 @@ -import { performSync } from "./sync"; +import { clearDictionary, saveDictionary } from "../dictionaryManagement"; +import { uploadWholeDictionary, performSync } from "./sync"; import { request } from "./helpers"; import { saveToken } from "./utilities"; import { addMessage } from "../utilities"; +import { renderAll } from "../render"; + +export function createNewDictionary() { + clearDictionary(); + saveDictionary(); + renderAll(); + uploadWholeDictionary(true); + document.getElementById('settingsModal').style.display = 'none'; + addMessage('New Dictionary Created!'); +} export function changeDictionary(dictionary) { dictionary = typeof dictionary.target !== 'undefined' ? dictionary.target.value : dictionary; diff --git a/src/js/account/render.js b/src/js/account/render.js index 5f40470..f076260 100644 --- a/src/js/account/render.js +++ b/src/js/account/render.js @@ -1,4 +1,4 @@ -import { setupLoginModal, setupChangeDictionary } from "./setupListeners"; +import { setupLoginModal, setupChangeDictionary, setupCreateNewDictionary } from "./setupListeners"; import { request } from "./helpers"; export function renderLoginForm() { @@ -66,6 +66,7 @@ export function renderAccountActions() { const accountActionsColumn = document.getElementById('accountActions'); const accountActionsHTML = `

Account Actions

+

Create New Dictionary

Request Your Data

Per your GDPR rights in Articles 13–15 and 20, we allow you to request any and all data we have stored about you. The only data we have about you personally is your email address and your Public Name, if you decided to set one. All other data (your Dictionary data) is visible and accessible via the Export button under your Dictionary's Settings. Send an email to help@lexicon.ga to request your information. @@ -82,6 +83,7 @@ export function renderAccountActions() { accountActionsColumn.innerHTML = accountActionsHTML; renderChangeDictionaryOptions(); + setupCreateNewDictionary(); } export function renderChangeDictionaryOptions() { diff --git a/src/js/account/setupListeners.js b/src/js/account/setupListeners.js index c8100b3..77b9088 100644 --- a/src/js/account/setupListeners.js +++ b/src/js/account/setupListeners.js @@ -1,6 +1,6 @@ import { logIn, createAccount } from "./login"; import { setCookie } from "../StackOverflow/cookie"; -import { changeDictionary } from "./dictionaryManagement"; +import { changeDictionary, createNewDictionary } from "./dictionaryManagement"; export function setupLoginModal(modal) { const closeElements = modal.querySelectorAll('.modal-background, .close-button'); @@ -24,3 +24,7 @@ export function setupLogoutButton(logoutButton) { export function setupChangeDictionary() { document.getElementById('accountSettingsChangeDictionary').addEventListener('change', changeDictionary); } + +export function setupCreateNewDictionary() { + document.getElementById('accountSettingsCreateNewDictionary').addEventListener('click', createNewDictionary); +}