[ui] *actually* make AttributeUpdate work

feat/vaults
Tomáš Mládek 2022-01-09 21:46:52 +01:00
parent 74e09146a4
commit 57847facee
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
3 changed files with 10 additions and 19 deletions

View File

@ -60,11 +60,11 @@
});
break;
case "delete":
await fetch(`/api/obj/${change.addr}`, { method: "DELETE" });
await fetch(`/api/obj/${change.address}`, { method: "DELETE" });
break;
case "update":
// TODO
await fetch(`/api/obj/${change.addr}`, { method: "DELETE" });
await fetch(`/api/obj/${change.address}`, { method: "DELETE" });
await fetch(`/api/obj`, {
method: "PUT",
headers: { "Content-Type": "application/json" },

View File

@ -4,12 +4,11 @@
import Ellipsis from "../utils/Ellipsis.svelte";
import UpObject from "../display/UpObject.svelte";
import { createEventDispatcher, getContext } from "svelte";
import type { AttributeChange } from "../../types/base";
import type { AttributeChange, AttributeUpdate } from "../../types/base";
import { useParams } from "svelte-navigator";
import type { Writable } from "svelte/store";
import type { UpEntry } from "upend";
import IconButton from "../utils/IconButton.svelte";
import Input from "../utils/Input.svelte";
import Selector from "../utils/Selector.svelte";
import type { IValue } from "upend/types";
import Editable from "../utils/Editable.svelte";
@ -41,26 +40,18 @@
newEntryAttribute = "";
newEntryValue = undefined;
}
async function removeEntry(addr: string) {
async function removeEntry(address: string) {
if (confirm("Are you sure you want to remove the attribute?")) {
dispatch("change", { type: "delete", addr } as AttributeChange);
dispatch("change", { type: "delete", address } as AttributeChange);
}
}
async function updateEntry(addr: string, attribute: string, value: IValue) {
async function updateEntry(address: string, attribute: string, value: IValue) {
dispatch("change", {
type: "update",
addr,
value,
} as AttributeChange);
dispatch("change", {
type: "delete",
addr,
} as AttributeChange);
dispatch("change", {
type: "create",
address,
attribute,
value,
} as AttributeChange);
} as AttributeUpdate);
}
// Sorting

View File

@ -13,12 +13,12 @@ export interface AttributeCreate {
export interface AttributeUpdate {
type: "update";
addr: string;
address: string;
attribute: string; // TODO: remove
value: IValue;
}
export interface AttributeDelete {
type: "delete";
addr: string;
address: string;
}