feat: contextmenu eigenschappen toegevoegd

This commit is contained in:
kodi
2026-03-14 11:11:03 +01:00
parent d08ca24c87
commit 73c539ba4a
4 changed files with 44 additions and 5 deletions
+33 -5
View File
@@ -330,6 +330,7 @@ function contextMenuElements() {
copyButton: document.getElementById("context-menu-copy-btn"),
moveButton: document.getElementById("context-menu-move-btn"),
deleteButton: document.getElementById("context-menu-delete-btn"),
propertiesButton: document.getElementById("context-menu-properties-btn"),
};
}
@@ -375,6 +376,8 @@ function openContextMenu(pane, entry, event) {
elements.copyButton.disabled = items.length === 0;
elements.moveButton.classList.remove("hidden");
elements.deleteButton.classList.remove("hidden");
elements.propertiesButton.classList.remove("hidden");
elements.propertiesButton.disabled = items.length === 0;
const menuWidth = 220;
const menuHeight = 120;
@@ -445,6 +448,18 @@ function startContextMenuCopy() {
startCopySelected();
}
function startContextMenuProperties() {
if (contextMenuElements().propertiesButton?.disabled) {
return;
}
if (!applyContextMenuSelection()) {
closeContextMenu();
return;
}
closeContextMenu();
openInfo();
}
function settingsElements() {
return {
overlay: document.getElementById("settings-modal"),
@@ -482,6 +497,7 @@ function searchElements() {
function infoElements() {
return {
overlay: document.getElementById("info-modal"),
title: document.getElementById("info-title"),
closeButton: document.getElementById("info-close-btn"),
error: document.getElementById("info-error"),
grid: document.getElementById("info-grid"),
@@ -2926,14 +2942,23 @@ function renderInfoField(label, value) {
async function openInfo() {
const selectedItems = activePaneState().selectedItems;
if (selectedItems.length !== 1) {
if (selectedItems.length === 0) {
return;
}
const elements = infoElements();
elements.overlay.classList.remove("hidden");
elements.title.textContent = "Properties";
elements.error.textContent = "";
elements.grid.innerHTML = "";
if (selectedItems.length > 1) {
const fileCount = selectedItems.filter((item) => item.kind === "file").length;
const directoryCount = selectedItems.filter((item) => item.kind === "directory").length;
renderInfoField("Selected items", selectedItems.length);
renderInfoField("Files", fileCount);
renderInfoField("Directories", directoryCount);
return;
}
const selected = selectedItems[0];
const elements = infoElements();
elements.overlay.classList.remove("hidden");
elements.error.textContent = "";
elements.grid.innerHTML = "";
try {
const data = await apiRequest("GET", `/api/files/info?${new URLSearchParams({ path: selected.path }).toString()}`);
renderInfoField("Name", data.name);
@@ -3772,6 +3797,9 @@ function setupEvents() {
if (contextMenu.deleteButton) {
contextMenu.deleteButton.onclick = startContextMenuDelete;
}
if (contextMenu.propertiesButton) {
contextMenu.propertiesButton.onclick = startContextMenuProperties;
}
document.addEventListener("click", (event) => {
const elements = uploadElements();
if (!elements.menu || elements.menu.contains(event.target)) {
+1
View File
@@ -126,6 +126,7 @@
<button id="context-menu-copy-btn" type="button" role="menuitem">Copy</button>
<button id="context-menu-move-btn" type="button" role="menuitem">Move</button>
<button id="context-menu-delete-btn" type="button" role="menuitem">Delete</button>
<button id="context-menu-properties-btn" type="button" role="menuitem">Properties</button>
</div>
<div id="settings-modal" class="popup-overlay hidden" role="dialog" aria-modal="true" aria-labelledby="settings-title">