[ui] *actually* make AttributeUpdate work
parent
74e09146a4
commit
57847facee
|
@ -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" },
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue