Add edit functionality to shares

This commit is contained in:
Max Berger
2026-03-10 23:28:59 +01:00
parent 011efdcc86
commit d99631e47d
5 changed files with 309 additions and 94 deletions

View File

@@ -27,7 +27,7 @@ import {
} from "../api/sharing.js";
import { Collection } from "../models/collection.js";
import { ErrorHandler } from "../utils/error.js";
import { NewShareScene } from "./NewShareScene.js";
import { CreateEditShareScene } from "./CreateEditShareScene.js";
import { Scene, pop_scene, push_scene, scene_stack } from "./scene_manager.js";
/**
@@ -73,17 +73,17 @@ export class ShareCollectionScene {
}
function onsharebytoken() {
let new_share_scene = new NewShareScene(user, password, collection, "token", function () {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "token", function () {
update_share_list(user, password, collection, errorHandler);
});
push_scene(new_share_scene, false);
push_scene(create_edit_share_scene, false);
}
function onsharebymap() {
let new_share_scene = new NewShareScene(user, password, collection, "map", function () {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, "map", function () {
update_share_list(user, password, collection, errorHandler);
});
push_scene(new_share_scene, false);
push_scene(create_edit_share_scene, false);
}
this.show = function () {
@@ -167,7 +167,7 @@ function update_share_list(user, password, collection, errorHandler) {
* @param {import('../api/sharing.js').Share} share
* @param {HTMLElement} template
* @param {string} delete_label
* @param {function(string, string, string, function(?string):void):void} delete_action
* @param {function(string, string, import('../api/sharing.js').Share, function(?string):void):void} delete_action
* @param {ErrorHandler} errorHandler
*/
function add_share_row_node(user, password, collection, share, template, delete_label, delete_action, errorHandler) {
@@ -193,6 +193,14 @@ function add_share_row_node(user, password, collection, share, template, delete_
console.warn("Unknown permissions", permissions);
}
/** @type {HTMLElement} */ let edit_btn = node.querySelector("[data-name=edit]");
edit_btn.onclick = function () {
let create_edit_share_scene = new CreateEditShareScene(user, password, collection, share.ShareType, function () {
update_share_list(user, password, collection, errorHandler);
}, share);
push_scene(create_edit_share_scene, false);
};
/** @type {HTMLElement} */ let delete_btn = node.querySelector("[data-name=delete]");
delete_btn.onclick = function () {
if (!confirm("Are you sure you want to delete " + delete_label + " " + pathortoken + "?")) {
@@ -201,7 +209,7 @@ function add_share_row_node(user, password, collection, share, template, delete_
delete_action(
user,
password,
pathortoken,
share,
function (error) {
if (error) {
errorHandler.setError(error);