const baseFormFields = `
service_id
servtype
subtype
user_id
referrer_user_id
state
creation_date
creation_time
creation_request_sent_date
notified_about_expiration
`; const formCreateButtons = `
`; const formEditButtons = `
`; function showContentBox() { let elem = document.getElementById('backgroundTint'); elem.classList.remove('hidden'); elem.classList.add('shown'); elem = document.getElementById('contentBox'); elem.classList.remove('hidden'); elem.classList.add('shown'); } function hideContentBox() { let elem = document.getElementById('backgroundTint'); elem.classList.remove('shown'); elem.classList.add('hidden'); elem = document.getElementById('contentBox'); elem.classList.remove('shown'); elem.classList.add('hidden'); } function showForm() { let newEntryBtn = document.getElementById('newEntryBtn'); newEntryBtn.style.display = 'none'; showContentBox(); let contentBox = document.getElementById('contentBox'); while (contentBox.firstChild) contentBox.removeChild(contentBox.firstChild); contentBox.appendChild(elementFromHTML(baseFormFields)); return contentBox; } function hideForm() { let newEntryBtn = document.getElementById('newEntryBtn'); newEntryBtn.style.display = 'inline'; let contentBox = document.getElementById('contentBox'); while (contentBox.firstChild) contentBox.removeChild(contentBox.firstChild); hideContentBox(); } function showEditForm() { let contentBox = showForm(); contentBox.firstChild.appendChild(elementFromHTML(formEditButtons)); contentBox.firstChild.action = '/api/update'; } function showCreateForm() { let contentBox = showForm(); contentBox.firstChild.appendChild(elementFromHTML(formCreateButtons)); contentBox.firstChild.action = '/api/add'; document.getElementById('formServiceId').disabled = false; }