Поправил баг с сортировкой
This commit is contained in:
@@ -554,7 +554,29 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Остальной ваш JavaScript код остается без изменений
|
||||
// Column visibility functions with localStorage support
|
||||
function getColumnVisibilityKey() {
|
||||
return 'objitemListColumnVisibility';
|
||||
}
|
||||
|
||||
function saveColumnVisibility() {
|
||||
const columnCheckboxes = document.querySelectorAll('.column-toggle');
|
||||
const visibility = {};
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
visibility[columnIndex] = checkbox.checked;
|
||||
});
|
||||
localStorage.setItem(getColumnVisibilityKey(), JSON.stringify(visibility));
|
||||
}
|
||||
|
||||
function loadColumnVisibility() {
|
||||
const saved = localStorage.getItem(getColumnVisibilityKey());
|
||||
if (saved) {
|
||||
return JSON.parse(saved);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function toggleColumn(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
const table = document.querySelector('.table');
|
||||
@@ -569,7 +591,27 @@
|
||||
cell.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Save state after toggle
|
||||
saveColumnVisibility();
|
||||
}
|
||||
|
||||
function toggleColumnWithoutSave(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
const table = document.querySelector('.table');
|
||||
const cells = table.querySelectorAll(`td:nth-child(${columnIndex + 1}), th:nth-child(${columnIndex + 1})`);
|
||||
|
||||
if (checkbox.checked) {
|
||||
cells.forEach(cell => {
|
||||
cell.style.display = '';
|
||||
});
|
||||
} else {
|
||||
cells.forEach(cell => {
|
||||
cell.style.display = 'none';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAllColumns(selectAllCheckbox) {
|
||||
const columnCheckboxes = document.querySelectorAll('.column-toggle');
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
@@ -734,36 +776,32 @@
|
||||
|
||||
// Initialize column visibility - hide creation columns by default
|
||||
function initColumnVisibility() {
|
||||
const creationDateCheckbox = document.querySelector('input[data-column="15"]');
|
||||
const creationUserCheckbox = document.querySelector('input[data-column="16"]');
|
||||
if (creationDateCheckbox) {
|
||||
creationDateCheckbox.checked = false;
|
||||
toggleColumn(creationDateCheckbox);
|
||||
const savedVisibility = loadColumnVisibility();
|
||||
|
||||
if (savedVisibility) {
|
||||
// Restore saved state
|
||||
const columnCheckboxes = document.querySelectorAll('.column-toggle');
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
if (savedVisibility.hasOwnProperty(columnIndex)) {
|
||||
checkbox.checked = savedVisibility[columnIndex];
|
||||
toggleColumnWithoutSave(checkbox);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Default state: hide specific columns
|
||||
const columnsToHide = [15, 16, 17, 18, 19]; // Создано, Кем(созд), Комментарий, Усреднённое, Стандарт
|
||||
|
||||
if (creationUserCheckbox) {
|
||||
creationUserCheckbox.checked = false;
|
||||
toggleColumn(creationUserCheckbox);
|
||||
columnsToHide.forEach(columnIndex => {
|
||||
const checkbox = document.querySelector(`input[data-column="${columnIndex}"]`);
|
||||
if (checkbox) {
|
||||
checkbox.checked = false;
|
||||
toggleColumnWithoutSave(checkbox);
|
||||
}
|
||||
});
|
||||
|
||||
// Hide comment, is_average, and standard columns by default
|
||||
const commentCheckbox = document.querySelector('input[data-column="17"]');
|
||||
const isAverageCheckbox = document.querySelector('input[data-column="18"]');
|
||||
const standardCheckbox = document.querySelector('input[data-column="19"]');
|
||||
|
||||
if (commentCheckbox) {
|
||||
commentCheckbox.checked = false;
|
||||
toggleColumn(commentCheckbox);
|
||||
}
|
||||
|
||||
if (isAverageCheckbox) {
|
||||
isAverageCheckbox.checked = false;
|
||||
toggleColumn(isAverageCheckbox);
|
||||
}
|
||||
|
||||
if (standardCheckbox) {
|
||||
standardCheckbox.checked = false;
|
||||
toggleColumn(standardCheckbox);
|
||||
// Save initial state
|
||||
saveColumnVisibility();
|
||||
}
|
||||
}
|
||||
// Filter counter functionality
|
||||
|
||||
@@ -1054,7 +1054,29 @@ function updateFilterCounter() {
|
||||
}
|
||||
}
|
||||
|
||||
// Column visibility functions
|
||||
// Column visibility functions with localStorage support
|
||||
function getColumnVisibilityKey() {
|
||||
return 'sourceListColumnVisibility';
|
||||
}
|
||||
|
||||
function saveColumnVisibility() {
|
||||
const columnCheckboxes = document.querySelectorAll('.column-toggle');
|
||||
const visibility = {};
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
visibility[columnIndex] = checkbox.checked;
|
||||
});
|
||||
localStorage.setItem(getColumnVisibilityKey(), JSON.stringify(visibility));
|
||||
}
|
||||
|
||||
function loadColumnVisibility() {
|
||||
const saved = localStorage.getItem(getColumnVisibilityKey());
|
||||
if (saved) {
|
||||
return JSON.parse(saved);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function toggleColumn(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
const table = document.querySelector('.table');
|
||||
@@ -1069,6 +1091,9 @@ function toggleColumn(checkbox) {
|
||||
cell.style.display = 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// Save state after toggle
|
||||
saveColumnVisibility();
|
||||
}
|
||||
|
||||
function toggleAllColumns(selectAllCheckbox) {
|
||||
@@ -1081,17 +1106,52 @@ function toggleAllColumns(selectAllCheckbox) {
|
||||
|
||||
// Initialize column visibility - hide Создано and Обновлено columns by default
|
||||
function initColumnVisibility() {
|
||||
const savedVisibility = loadColumnVisibility();
|
||||
|
||||
if (savedVisibility) {
|
||||
// Restore saved state
|
||||
const columnCheckboxes = document.querySelectorAll('.column-toggle');
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
if (savedVisibility.hasOwnProperty(columnIndex)) {
|
||||
checkbox.checked = savedVisibility[columnIndex];
|
||||
toggleColumnWithoutSave(checkbox);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Default state: hide Создано and Обновлено columns
|
||||
const createdAtCheckbox = document.querySelector('input[data-column="11"]');
|
||||
const updatedAtCheckbox = document.querySelector('input[data-column="12"]');
|
||||
|
||||
if (createdAtCheckbox) {
|
||||
createdAtCheckbox.checked = false;
|
||||
toggleColumn(createdAtCheckbox);
|
||||
toggleColumnWithoutSave(createdAtCheckbox);
|
||||
}
|
||||
|
||||
if (updatedAtCheckbox) {
|
||||
updatedAtCheckbox.checked = false;
|
||||
toggleColumn(updatedAtCheckbox);
|
||||
toggleColumnWithoutSave(updatedAtCheckbox);
|
||||
}
|
||||
|
||||
// Save initial state
|
||||
saveColumnVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to toggle without saving (used during initialization)
|
||||
function toggleColumnWithoutSave(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
const table = document.querySelector('.table');
|
||||
const cells = table.querySelectorAll(`td:nth-child(${columnIndex + 1}), th:nth-child(${columnIndex + 1})`);
|
||||
|
||||
if (checkbox.checked) {
|
||||
cells.forEach(cell => {
|
||||
cell.style.display = '';
|
||||
});
|
||||
} else {
|
||||
cells.forEach(cell => {
|
||||
cell.style.display = 'none';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1366,6 +1426,29 @@ function setupModalSelectAll() {
|
||||
}
|
||||
}
|
||||
|
||||
// Modal column visibility functions with localStorage support
|
||||
function getModalColumnVisibilityKey() {
|
||||
return 'sourceListModalColumnVisibility';
|
||||
}
|
||||
|
||||
function saveModalColumnVisibility() {
|
||||
const columnCheckboxes = document.querySelectorAll('.modal-column-toggle');
|
||||
const visibility = {};
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
visibility[columnIndex] = checkbox.checked;
|
||||
});
|
||||
localStorage.setItem(getModalColumnVisibilityKey(), JSON.stringify(visibility));
|
||||
}
|
||||
|
||||
function loadModalColumnVisibility() {
|
||||
const saved = localStorage.getItem(getModalColumnVisibilityKey());
|
||||
if (saved) {
|
||||
return JSON.parse(saved);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Function to toggle modal column visibility
|
||||
function toggleModalColumn(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
@@ -1390,6 +1473,9 @@ function toggleModalColumn(checkbox) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Save state after toggle
|
||||
saveModalColumnVisibility();
|
||||
}
|
||||
|
||||
// Function to toggle all modal columns
|
||||
@@ -1401,28 +1487,66 @@ function toggleAllModalColumns(selectAllCheckbox) {
|
||||
});
|
||||
}
|
||||
|
||||
// Helper function to toggle modal column without saving
|
||||
function toggleModalColumnWithoutSave(checkbox) {
|
||||
const columnIndex = parseInt(checkbox.getAttribute('data-column'));
|
||||
|
||||
const tbody = document.getElementById('objitemTableBody');
|
||||
if (!tbody) return;
|
||||
|
||||
const table = tbody.closest('table');
|
||||
if (!table) return;
|
||||
|
||||
const rows = table.querySelectorAll('tr');
|
||||
rows.forEach(row => {
|
||||
const cells = row.children;
|
||||
if (cells[columnIndex]) {
|
||||
if (checkbox.checked) {
|
||||
cells[columnIndex].style.removeProperty('display');
|
||||
} else {
|
||||
cells[columnIndex].style.setProperty('display', 'none', 'important');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize modal column visibility
|
||||
function initModalColumnVisibility() {
|
||||
// Hide columns by default: Создано (16), Кем(созд) (17), Комментарий (18), Усреднённое (19), Стандарт (20), Sigma (22)
|
||||
const savedVisibility = loadModalColumnVisibility();
|
||||
|
||||
if (savedVisibility) {
|
||||
// Restore saved state
|
||||
const columnCheckboxes = document.querySelectorAll('.modal-column-toggle');
|
||||
columnCheckboxes.forEach(checkbox => {
|
||||
const columnIndex = checkbox.getAttribute('data-column');
|
||||
if (savedVisibility.hasOwnProperty(columnIndex)) {
|
||||
checkbox.checked = savedVisibility[columnIndex];
|
||||
toggleModalColumnWithoutSave(checkbox);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Default state: hide columns by default: Создано (16), Кем(созд) (17), Комментарий (18), Усреднённое (19), Стандарт (20), Sigma (22)
|
||||
const columnsToHide = [16, 17, 18, 19, 20, 22];
|
||||
|
||||
// Get the specific tbody for objitems
|
||||
const tbody = document.getElementById('objitemTableBody');
|
||||
if (!tbody) {
|
||||
console.log('objitemTableBody not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the parent table
|
||||
const table = tbody.closest('table');
|
||||
if (!table) {
|
||||
console.log('Table not found');
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide columns that should be hidden by default
|
||||
// Update checkboxes and hide columns
|
||||
columnsToHide.forEach(columnIndex => {
|
||||
// Get all rows in the table (including thead and tbody)
|
||||
const checkbox = document.querySelector(`.modal-column-toggle[data-column="${columnIndex}"]`);
|
||||
if (checkbox) {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
|
||||
const rows = table.querySelectorAll('tr');
|
||||
rows.forEach(row => {
|
||||
const cells = row.children;
|
||||
@@ -1431,6 +1555,10 @@ function initModalColumnVisibility() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Save initial state
|
||||
saveModalColumnVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
// Function to show LyngSat modal
|
||||
|
||||
Reference in New Issue
Block a user