Сделал заготовку для кубсатов

This commit is contained in:
2025-11-10 16:15:55 +03:00
parent 9e9468ed34
commit 0858961410
2 changed files with 24 additions and 19 deletions

View File

@@ -62,6 +62,12 @@
<div class="col-12 d-flex justify-content-between align-items-center"> <div class="col-12 d-flex justify-content-between align-items-center">
<h2>{% if object %}Редактировать объект: {{ object.name }}{% else %}Создать объект{% endif %}</h2> <h2>{% if object %}Редактировать объект: {{ object.name }}{% else %}Создать объект{% endif %}</h2>
<div> <div>
{% if user.customuser.role == 'admin' or user.customuser.role == 'moderator' %}
<button type="submit" class="btn btn-primary btn-action">Сохранить</button>
{% if object %}
<a href="{% url 'mainapp:objitem_delete' object.id %}{% if request.GET.urlencode %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-action">Удалить</a>
{% endif %}
{% endif %}
<a href="{% url 'mainapp:objitem_list' %}{% if request.GET.urlencode %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-secondary btn-action">Назад</a> <a href="{% url 'mainapp:objitem_list' %}{% if request.GET.urlencode %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-secondary btn-action">Назад</a>
</div> </div>
</div> </div>
@@ -329,14 +335,6 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% if user.customuser.role == 'admin' or user.customuser.role == 'moderator' %}
<div class="d-flex justify-content-end mt-4">
<button type="submit" class="btn btn-primary btn-action">Сохранить</button>
{% if object %}
<a href="{% url 'mainapp:objitem_delete' object.id %}{% if request.GET.urlencode %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-action">Удалить</a>
{% endif %}
</div>
{% endif %}
</form> </form>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -976,7 +976,7 @@
} }
// Function to save selected items to localStorage // Function to save selected items to localStorage
function saveSelectedItemsToStorage() { window.saveSelectedItemsToStorage = function() {
try { try {
localStorage.setItem('selectedItems', JSON.stringify(window.selectedItems)); localStorage.setItem('selectedItems', JSON.stringify(window.selectedItems));
} catch (e) { } catch (e) {
@@ -984,9 +984,6 @@
} }
} }
// Load selected items from localStorage on page load
loadSelectedItemsFromStorage();
// Function to update the selected items counter // Function to update the selected items counter
window.updateSelectedCounter = function() { window.updateSelectedCounter = function() {
const counterElement = document.getElementById('selectedCounter'); const counterElement = document.getElementById('selectedCounter');
@@ -1004,6 +1001,12 @@
} }
} }
// Load selected items from localStorage on page load
loadSelectedItemsFromStorage();
// Update counters after loading items from localStorage
updateSelectedCounter();
// Function to add selected items to the list // Function to add selected items to the list
window.addSelectedToList = function() { window.addSelectedToList = function() {
const checkedCheckboxes = document.querySelectorAll('.item-checkbox:checked'); const checkedCheckboxes = document.querySelectorAll('.item-checkbox:checked');
@@ -1037,10 +1040,10 @@
geo_coords: row.cells[11].textContent, geo_coords: row.cells[11].textContent,
kupsat_coords: row.cells[12].textContent, kupsat_coords: row.cells[12].textContent,
valid_coords: row.cells[13].textContent, valid_coords: row.cells[13].textContent,
updated_at: row.cells[14].textContent, updated_at: row.cells[17].textContent,
updated_by: row.cells[15].textContent, updated_by: row.cells[18].textContent,
created_at: row.cells[16].textContent, created_at: row.cells[19].textContent,
created_by: row.cells[17].textContent created_by: row.cells[20].textContent
}; };
window.selectedItems.push(rowData); window.selectedItems.push(rowData);
@@ -1052,6 +1055,9 @@
updateSelectedCounter(); updateSelectedCounter();
} }
// Save selected items to localStorage
saveSelectedItemsToStorage();
// Clear selections in the main table // Clear selections in the main table
const itemCheckboxes = document.querySelectorAll('.item-checkbox'); const itemCheckboxes = document.querySelectorAll('.item-checkbox');
itemCheckboxes.forEach(checkbox => { itemCheckboxes.forEach(checkbox => {
@@ -1061,9 +1067,7 @@
if (selectAllCheckbox) { if (selectAllCheckbox) {
selectAllCheckbox.checked = false; selectAllCheckbox.checked = false;
} }
//alert(`Добавлено ${checkedCheckboxes.length} элемент(ов) в список. Всего: ${window.selectedItems.length} элемент(ов).`);
// Show success message
alert(`Добавлено ${checkedCheckboxes.length} элемент(ов) в список. Всего: ${window.selectedItems.length} элемент(ов).`);
} }
setTimeout(initColumnVisibility, 100); setTimeout(initColumnVisibility, 100);
@@ -1120,6 +1124,9 @@
// Remove items from the selectedItems array // Remove items from the selectedItems array
window.selectedItems = window.selectedItems.filter(item => !idsToRemove.includes(item.id)); window.selectedItems = window.selectedItems.filter(item => !idsToRemove.includes(item.id));
// Save selected items to localStorage
saveSelectedItemsToStorage();
// Update the counter and table // Update the counter and table
if (typeof updateSelectedCounter === 'function') { if (typeof updateSelectedCounter === 'function') {
updateSelectedCounter(); updateSelectedCounter();