summaryrefslogtreecommitdiff
path: root/day9/task5/static/js
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2019-07-08 01:26:51 +0400
committerAndrew <saintruler@gmail.com>2019-07-08 01:26:51 +0400
commit67c4adc2d26714ff5c5269be220fff90cec47353 (patch)
treeae64671ae6fca7072904c57f14f854371191302c /day9/task5/static/js
parenta47e9946ba94b2c8b6d0f29f937e47f929d2edae (diff)
WIP: Изменена верстка таблицы, исправлена работа формы добавления новой
записи в таблицу.
Diffstat (limited to 'day9/task5/static/js')
-rw-r--r--day9/task5/static/js/main.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/day9/task5/static/js/main.js b/day9/task5/static/js/main.js
index 39c8c9b..2ac3958 100644
--- a/day9/task5/static/js/main.js
+++ b/day9/task5/static/js/main.js
@@ -46,7 +46,7 @@ const defaultColumnInputs = {
'notified_about_expiration': `<input type="text">`
};
-const baseFormFields = `<form id="tableForm" action="/update">
+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" disabled></div>
@@ -123,14 +123,14 @@ const baseFormFields = `<form id="tableForm" action="/update">
</form>`;
const formCreateButtons = `<div class="formButtons">
- <button type="button" onclick="hideForm()">Cancel</button>
- <button type="submit">Create</button>
- </div>`;
+ <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>`;
+ <button type="button" onclick="hideForm()">Cancel</button>
+ <button type="submit">Update</button>
+</div>`;
const uploadFileHtml = '<img src="/static/images/upload_icon.png" alt="" style="width: 70%;height: 70%;">';
@@ -209,7 +209,6 @@ function renderTable(text) {
contentRow.setAttribute('id', `row_${row[0]}`);
row.forEach((column, colIndex) => {
- let color = (colIndex % 2 + rowIndex % 2) % 2 === 0 ? 'odd' : 'even';
let columnNode = document.createElement('td');
if (colIndex !== 0 && colIndex < data['headers'].length) {
@@ -219,7 +218,6 @@ function renderTable(text) {
columnNode.setAttribute('id', fieldId);
}
- columnNode.classList.add(color);
columnNode.innerHTML = column;
contentRow.appendChild(columnNode);
});
@@ -294,12 +292,14 @@ function showForm() {
showEditForm = () => {
let contentBox = showForm();
- contentBox.appendChild(elementFromHTML(formEditButtons));
+ contentBox.firstChild.appendChild(elementFromHTML(formEditButtons));
+ contentBox.firstChild.action = '/api/update';
};
showCreateForm = () => {
let contentBox = showForm();
- contentBox.appendChild(elementFromHTML(formCreateButtons));
+ contentBox.firstChild.appendChild(elementFromHTML(formCreateButtons));
+ contentBox.firstChild.action = '/api/add';
document.getElementById('formServiceId').disabled = false;
};