`, methods: { formSubmit() { const addToProject = this.project_id; const company = this.$root.current_company; const docRef = db.collection("projects").doc(addToProject) db.runTransaction((t) => { return t.get(docRef).then((doc) => { if (!doc.exists) return; const newCompanies = doc.get('companies'); newCompanies.push(company); t.set(docRef, { companies: newCompanies, last_updated: firebase.firestore.Timestamp.fromDate(new Date()), }, { merge: true }); }); }).then(() => { this.$root.companyAddSuccess(); console.log("Transaction successfully committed!"); }).catch(function (error) { console.log("Transaction failed: ", error); }); } }, }); const vm = vueApp.mount('#vapp') const projectListModal = function () { const modal = document.getElementById("add-to-list-modal"); $(modal).modal("show"); } const projectListModalHide = function () { const modal = document.getElementById("add-to-list-modal"); $(modal).modal("hide"); } const buyerTools = function () { const currentUserId = get_user_id(); const userSignedIn = user_signed_in; const addToListButton = document.querySelector("[add-to-project-list]"); if (window.localStorage.getItem("project_list_on_load")) { window.addEventListener("load", () => { window.localStorage.removeItem("project_list_on_load"); projectListModal(); }); } addToListButton.addEventListener("click", (e) => { e.preventDefault(); if (!userSignedIn) { showRegisterModal("to create a project list,", () => { window.localStorage.setItem("project_list_on_load", true); window.location.reload(); }); } else { projectListModal(); } }) } buyerTools();