diff options
| author | Andrew <saintruler@gmail.com> | 2019-07-21 12:14:09 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2019-07-21 12:14:09 +0400 |
| commit | 2305ced85888a23f86ecfcdfb64a3b69c4997a4c (patch) | |
| tree | 9d5cc4ad1c322ca2bf46b990498ad0a79d508aff /day9/task5/static/js/editForm.js | |
| parent | 8c8712f0e6b165f6967f5d2958f300df6182296c (diff) | |
Переписан бекенд. Добавлена валидация при обновлении значений в ряду.
Удалена предыдущая версия приложения без vue.
Diffstat (limited to 'day9/task5/static/js/editForm.js')
| -rw-r--r-- | day9/task5/static/js/editForm.js | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/day9/task5/static/js/editForm.js b/day9/task5/static/js/editForm.js deleted file mode 100644 index f371664..0000000 --- a/day9/task5/static/js/editForm.js +++ /dev/null @@ -1,142 +0,0 @@ -const baseFormFields = `<form id="tableForm" action="/api/update" method="post"> - <div class="formRow"> - <div class="formRow-label">service_id</div> - <div class="formRow-input"><input type="text" name="service_id" class="formInput" id="formServiceId" readonly="readonly"></div> - </div> - - <div class="formRow"> - <div class="formRow-label"> servtype </div> - <div class="formRow-input"> - <input type="text" name="servtype" class="formInput"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> subtype </div> - <div class="formRow-input"> - <input type="text" name="subtype" class="formInput"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> user_id </div> - <div class="formRow-input"> - <input type="text" name="user_id" class="formInput"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> referrer_user_id </div> - <div class="formRow-input"> - <input type="text" name="referrer_user_id" class="formInput"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> state </div> - <div class="formRow-input"> - <select name="state"> - <option>N</option> - <option>A</option> - <option>S</option> - <option>D</option> - <option>O</option> - </select> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> creation_date </div> - <div class="formRow-input"> - <input type="date" name="creation_date" class="formInput"> - </div> - </div> - <div class="formRow"> - <div class="formRow-label"> creation_time </div> - <div class="formRow-input"> - <input type="time" name="creation_time" class="formInput"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> creation_request_sent_date </div> - <div class="formRow-input" style="display: flex; flex-direction: row"> - <input type="date" name="creation_request_sent_date" class="formInput" style="width: 50%;"> - <input type="time" name="creation_request_sent_time" class="formInput" style="width: 50%;"> - </div> - </div> - - <div class="formRow"> - <div class="formRow-label"> notified_about_expiration </div> - <div class="formRow-input"> - <input type="text" name="notified_about_expiration" class="formInput"> - </div> - </div> -</form>`; - -const formCreateButtons = `<div class="formButtons"> - <button type="button" onclick="hideForm()">Cancel</button> - <button type="submit">Create</button> -</div>`; - -const formEditButtons = `<div class="formButtons"> - <button type="button" onclick="hideForm()">Cancel</button> - <button type="submit">Update</button> -</div>`; - -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; -} |