From b9aa03afb81bb37f8289096f8bb7835ea7cb3466 Mon Sep 17 00:00:00 2001 From: Max Berger Date: Fri, 13 Mar 2026 23:34:59 +0100 Subject: [PATCH] CollectionScene: Clarify collections --- .../js/scenes/CollectionsScene.js | 36 ++++++++++++------- .../web/internal_data/js/scenes/LoginScene.js | 4 +-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/radicale/web/internal_data/js/scenes/CollectionsScene.js b/radicale/web/internal_data/js/scenes/CollectionsScene.js index 6d191ad0..d6883f66 100644 --- a/radicale/web/internal_data/js/scenes/CollectionsScene.js +++ b/radicale/web/internal_data/js/scenes/CollectionsScene.js @@ -40,11 +40,11 @@ export class CollectionsScene { /** * @param {string} user * @param {string} password - * @param {Collection} collection The collection to show sharing options for. + * @param {Collection} principal_collection The princial collection * @param {function(string):void} onerror Called when an error occurs, before the * scene is popped. */ - constructor(user, password, collection, onerror) { + constructor(user, password, principal_collection, onerror) { /** @type {HTMLElement} */ let html_scene = document.getElementById("collectionsscene"); /** @type {HTMLElement} */ let template = html_scene.querySelector("[data-name=collectiontemplate]"); /** @type {HTMLElement} */ let new_btn = html_scene.querySelector("[data-name=new]"); @@ -53,12 +53,12 @@ export class CollectionsScene { /** @type {?number} */ let scene_index = null; /** @type {?XMLHttpRequest} */ let collections_req = null; - /** @type {?Array} */ let collections = null; + /** @type {?Array} */ let child_collections = null; /** @type {Array} */ let nodes = []; function onnew() { try { - let create_collection_scene = new CreateEditCollectionScene(user, password, collection); + let create_collection_scene = new CreateEditCollectionScene(user, password, principal_collection); push_scene(create_collection_scene, false); } catch (err) { console.error(err); @@ -68,7 +68,7 @@ export class CollectionsScene { function onupload() { try { - let upload_scene = new UploadCollectionScene(user, password, collection); + let upload_scene = new UploadCollectionScene(user, password, principal_collection); push_scene(upload_scene, false); } catch (err) { console.error(err); @@ -86,6 +86,9 @@ export class CollectionsScene { return false; } + /** + * @param {Collection} collection + */ function onedit(collection) { try { let edit_collection_scene = new CreateEditCollectionScene(user, password, collection); @@ -96,6 +99,9 @@ export class CollectionsScene { return false; } + /** + * @param {Collection} collection + */ function onshare(collection) { try { let share_collection_scene = new ShareCollectionScene(user, password, collection); @@ -106,6 +112,9 @@ export class CollectionsScene { return false; } + /** + * @param {Collection} collection + */ function ondelete(collection) { try { let delete_collection_scene = new DeleteCollectionScene(user, password, collection); @@ -116,12 +125,15 @@ export class CollectionsScene { return false; } + /** + * @param {any[]} collections + */ function show_collections(collections) { /** @type {HTMLElement} */ let navBar = document.querySelector("#logoutview"); let heightOfNavBar = navBar.offsetHeight + "px"; html_scene.style.marginTop = heightOfNavBar; html_scene.style.height = "calc(100vh - " + heightOfNavBar + ")"; - collections.forEach(function (collection) { + collections.forEach(function (/** @type {Collection} */ collection) { /** @type {HTMLElement} */ let node = /** @type {HTMLElement} */(template.cloneNode(true)); node.classList.remove("hidden"); /** @type {HTMLElement} */ let title_form = node.querySelector("[data-name=title]"); @@ -184,7 +196,7 @@ export class CollectionsScene { function update() { let loading_scene = new LoadingScene(); push_scene(loading_scene, false); - collections_req = get_collections(user, password, collection, function (collections1, error) { + collections_req = get_collections(user, password, principal_collection, function (child_collections_, error) { if (scene_index === null) { return; } @@ -193,7 +205,7 @@ export class CollectionsScene { onerror(error); pop_scene(scene_index - 1); } else { - collections = collections1; + child_collections = child_collections_; pop_scene(scene_index); } }); @@ -204,12 +216,12 @@ export class CollectionsScene { new_btn.onclick = onnew; upload_btn.onclick = onupload; incomingshares_btn.onclick = onincomingshares; - if (collections === null) { + if (child_collections === null) { update(); discover_server_features(user, password, maybe_enable_sharing_options); } else { // from update loading scene - show_collections(collections); + show_collections(child_collections); } }; this.hide = function () { @@ -218,7 +230,7 @@ export class CollectionsScene { new_btn.onclick = null; upload_btn.onclick = null; incomingshares_btn.onclick = null; - collections = null; + child_collections = null; // remove collection nodes.forEach(function (node) { node.parentNode.removeChild(node); @@ -231,7 +243,7 @@ export class CollectionsScene { collections_req.abort(); collections_req = null; } - collections = null; + child_collections = null; }; } } \ No newline at end of file diff --git a/radicale/web/internal_data/js/scenes/LoginScene.js b/radicale/web/internal_data/js/scenes/LoginScene.js index f6cc6b91..9d69e645 100644 --- a/radicale/web/internal_data/js/scenes/LoginScene.js +++ b/radicale/web/internal_data/js/scenes/LoginScene.js @@ -72,7 +72,7 @@ export class LoginScene { // Fetch principal let loading_scene = new LoadingScene(); push_scene(loading_scene, false); - principal_req = get_principal(user, password, function (collection, error1) { + principal_req = get_principal(user, password, function (principal_collection, error1) { if (scene_index === null) { return; } @@ -85,7 +85,7 @@ export class LoginScene { let saved_user = user; user = ""; let collections_scene = new CollectionsScene( - saved_user, password, collection, function (error1) { + saved_user, password, principal_collection, function (error1) { errorHandler.setError(error1); user = saved_user; });