Replace sidebar menu with collapsible category tree showing items
This commit is contained in:
@@ -2,6 +2,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
const mainContent = document.getElementById('main-content');
|
||||
const appName = document.querySelector('.navbar-brand').textContent;
|
||||
|
||||
// Global function for editing item from tree
|
||||
window.editItem = function(id) {
|
||||
// Create a mock button to reuse handleEditItem
|
||||
const mockBtn = { getAttribute: (attr) => attr === 'data-id' ? id : null };
|
||||
handleEditItem.call(mockBtn);
|
||||
};
|
||||
|
||||
// Function to toggle category children
|
||||
window.toggleCategory = function(span) {
|
||||
const li = span.parentElement;
|
||||
const ul = li.querySelector('ul'); // First ul is children
|
||||
if (ul) {
|
||||
ul.style.display = ul.style.display === 'none' ? 'block' : 'none';
|
||||
}
|
||||
};
|
||||
|
||||
// --- Helper Functions ---
|
||||
function setPageTitle(title) {
|
||||
document.title = `${appName} - ${title}`;
|
||||
|
||||
Reference in New Issue
Block a user