Sha256: e57aef8768a88ca898b80da50cec812eaefe9b7bd329c166c4e34c6b41eb78da
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
// Choose a Proposal Answer template, get it by AJAX and add the Template in the Proposal Answer textarea document.addEventListener("DOMContentLoaded", () => { const proposalAnswerTemplateChooser = document.getElementById("proposal_answer_template_chooser"); if (proposalAnswerTemplateChooser) { proposalAnswerTemplateChooser.addEventListener("change", () => { const dropdown = document.getElementById("proposal_answer_template_chooser"); const url = dropdown.getAttribute("data-url"); const templateId = dropdown.value; const proposalId = dropdown.dataset.proposal; if (templateId === "") { return; } fetch(`${new URL(url).pathname}?${new URLSearchParams({ id: templateId, proposalId: proposalId })}`). then((response) => response.json()). then((data) => { document.getElementById(`proposal_answer_internal_state_${data.state}`).click(); let editorContainer = null; for (const [key, value] of Object.entries(data.template)) { editorContainer = document.querySelector(`[name="proposal_answer[answer_${key}]"]`).nextElementSibling; let editor = editorContainer.querySelector(".ProseMirror").editor; editor.commands.setContent(value, true); } }) }); } });
Version data entries
3 entries across 3 versions & 1 rubygems