From a9020b0388e67f6f165bff59108d6d12ba88967b Mon Sep 17 00:00:00 2001 From: Verum Date: Wed, 18 Mar 2026 17:42:14 +0700 Subject: [PATCH] 122 --- index.html | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 7be53b0..9605274 100644 --- a/index.html +++ b/index.html @@ -406,6 +406,7 @@ SELECT * FROM users LIMIT 10;"> this.primaryKey = null; this.tableStructure = []; this.filters = {}; + this.filterColumns = []; this.sortColumn = ''; this.sortDirection = 'ASC'; this.init(); @@ -583,10 +584,13 @@ SELECT * FROM users LIMIT 10;"> return `${col} ${arrow}`; }).join('') + 'Действия'; - // Generate filter inputs - filterInputs.innerHTML = columns.map(col => { - return ``; - }).join('') + ''; + // Render filter inputs once per column set and keep values in sync + if (JSON.stringify(this.filterColumns) !== JSON.stringify(columns)) { + this.filterColumns = columns; + this.renderFilterRow(columns); + } else { + this.updateFilterInputs(columns); + } if (records.length === 0) { body.innerHTML = 'Нет данных'; @@ -613,6 +617,23 @@ SELECT * FROM users LIMIT 10;"> }).join(''); } + // Filter row helpers (do not re-render inputs on every data refresh) + renderFilterRow(columns) { + const filterInputs = document.getElementById('filterInputs'); + filterInputs.innerHTML = columns.map(col => { + return ``; + }).join('') + ''; + } + + updateFilterInputs(columns) { + columns.forEach(col => { + const input = document.querySelector(`#filterInputs input[data-col="${col}"]`); + if (input) { + input.value = this.filters[col] || ''; + } + }); + } + sortBy(column) { if (this.sortColumn === column) { if (this.sortDirection === 'ASC') { @@ -665,7 +686,15 @@ SELECT * FROM users LIMIT 10;"> title.textContent = isEdit ? 'Редактировать запись' : 'Добавить запись'; // Generate form fields based on table structure - form.innerHTML = this.tableStructure.map(col => { + const columnsToRender = this.tableStructure.filter(col => { + // For new records, skip UUID/uid columns so they get generated/ignored by the server + if (!isEdit && (col.name.toLowerCase() === 'uid' || col.type.toLowerCase() === 'uuid')) { + return false; + } + return true; + }); + + form.innerHTML = columnsToRender.map(col => { const value = isEdit && this.editingRecord ? '' : ''; let inputHtml = ''; @@ -746,6 +775,17 @@ SELECT * FROM users LIMIT 10;"> } }); + // Ensure UUID/UID columns are sent (as empty strings) so the server can auto-generate values + if (!this.editingRecord) { + this.tableStructure.forEach(col => { + if (col.name.toLowerCase() === 'uid' || col.type.toLowerCase() === 'uuid') { + if (data[col.name] === undefined || data[col.name] === '') { + data[col.name] = ''; + } + } + }); + } + try { let response; if (this.editingRecord) {