removed persistant data
This commit is contained in:
parent
345a801c40
commit
627f805377
10 changed files with 412 additions and 29 deletions
|
@ -215,12 +215,80 @@
|
|||
function createCategoryItem(category) {
|
||||
const li = document.createElement('li');
|
||||
|
||||
// Create the category item container with flexbox to place the + icon
|
||||
const categoryContainer = document.createElement('div');
|
||||
categoryContainer.className = 'flex items-center justify-between group';
|
||||
li.appendChild(categoryContainer);
|
||||
|
||||
// Create the link to view the category
|
||||
const a = document.createElement('a');
|
||||
a.href = `/category/${category.id}`;
|
||||
a.className = 'flex items-center py-1 px-2 text-gray-400 hover:text-primary rounded transition-colors';
|
||||
a.innerHTML = `<i class="mdi ${category.icon} mr-2 text-sm"></i> ${category.name}`;
|
||||
li.appendChild(a);
|
||||
let categoryClass = 'flex-grow flex items-center py-1 px-2 text-gray-400 hover:text-primary rounded transition-colors';
|
||||
|
||||
// Special styling for root
|
||||
if (category.is_root) {
|
||||
categoryClass += ' font-semibold text-primary';
|
||||
}
|
||||
|
||||
a.className = categoryClass;
|
||||
|
||||
// Special icon for root
|
||||
const iconClass = category.is_root ? 'mdi-folder-root' : category.icon;
|
||||
a.innerHTML = `<i class="mdi ${iconClass} mr-2 text-sm"></i> ${category.name}`;
|
||||
categoryContainer.appendChild(a);
|
||||
|
||||
// Create the dropdown menu container
|
||||
const dropdownContainer = document.createElement('div');
|
||||
dropdownContainer.className = 'relative';
|
||||
categoryContainer.appendChild(dropdownContainer);
|
||||
|
||||
// Create the plus button
|
||||
const plusButton = document.createElement('button');
|
||||
plusButton.className = 'ml-1 p-1 text-gray-500 hover:text-primary rounded-full opacity-0 group-hover:opacity-100 transition-opacity';
|
||||
plusButton.innerHTML = '<i class="mdi mdi-plus text-sm"></i>';
|
||||
dropdownContainer.appendChild(plusButton);
|
||||
|
||||
// Create dropdown menu
|
||||
const dropdown = document.createElement('div');
|
||||
dropdown.className = 'absolute right-0 top-full mt-1 py-1 bg-gray-800 border border-gray-700 rounded-md shadow-lg z-20 hidden w-48';
|
||||
dropdownContainer.appendChild(dropdown);
|
||||
|
||||
// Add menu items
|
||||
const newSubcategory = document.createElement('a');
|
||||
newSubcategory.href = `/category/new?parent_id=${category.id}`;
|
||||
newSubcategory.className = 'block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700 hover:text-white w-full text-left';
|
||||
newSubcategory.innerHTML = '<i class="mdi mdi-folder-plus-outline mr-2"></i> New Subcategory';
|
||||
dropdown.appendChild(newSubcategory);
|
||||
|
||||
const newDocument = document.createElement('a');
|
||||
newDocument.href = `/document/new?category=${category.id}`;
|
||||
newDocument.className = 'block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700 hover:text-white w-full text-left';
|
||||
newDocument.innerHTML = '<i class="mdi mdi-file-plus-outline mr-2"></i> New Document';
|
||||
dropdown.appendChild(newDocument);
|
||||
|
||||
// Toggle dropdown
|
||||
plusButton.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
dropdown.classList.toggle('hidden');
|
||||
|
||||
// Close other open dropdowns
|
||||
document.querySelectorAll('.category-dropdown:not(.hidden)').forEach(el => {
|
||||
if (el !== dropdown) el.classList.add('hidden');
|
||||
});
|
||||
});
|
||||
|
||||
// Add class for easy reference
|
||||
dropdown.classList.add('category-dropdown');
|
||||
|
||||
// Add click handler to close dropdown when clicking outside
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!plusButton.contains(e.target) && !dropdown.contains(e.target)) {
|
||||
dropdown.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
// Add children
|
||||
if (category.children && category.children.length > 0) {
|
||||
const childrenUl = document.createElement('ul');
|
||||
childrenUl.className = 'ml-2 pl-2 border-l border-gray-700 my-1';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue