summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/Update.svelte.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--frontend/src/lib/Update.svelte.ts (renamed from frontend/src/lib/Update.ts)19
1 files changed, 8 insertions, 11 deletions
diff --git a/frontend/src/lib/Update.ts b/frontend/src/lib/Update.svelte.ts
index 507dd52..1d684d5 100644
--- a/frontend/src/lib/Update.ts
+++ b/frontend/src/lib/Update.svelte.ts
@@ -4,17 +4,14 @@ import {
type UpdateOptions,
type UpdateTagInput
} from '$gql/graphql';
-
-type Key = string | number | symbol;
+import type { Key } from './Utils';
interface AssociationUpdate {
ids?: number[] | string[] | null;
options?: UpdateOptions | null;
}
-type Input<T, K extends Key> = {
- [Property in K]?: T | null;
-};
+type Input<T, K extends Key> = Partial<Record<K, T | null>>;
abstract class Entry<K extends Key> {
key: K;
@@ -28,10 +25,10 @@ abstract class Entry<K extends Key> {
}
class Association<K extends Key> extends Entry<K> {
- ids = [];
- options = {
+ ids = $state([]);
+ options = $state({
mode: UpdateMode.Add
- };
+ });
constructor(key: K) {
super(key);
@@ -49,7 +46,7 @@ class Association<K extends Key> extends Entry<K> {
}
class Enum<K extends Key> extends Entry<K> {
- value?: string = undefined;
+ value?: string = $state(undefined);
constructor(key: K) {
super(key);
@@ -67,13 +64,13 @@ class Enum<K extends Key> extends Entry<K> {
}
abstract class Controls<I> {
- toInput() {
+ input() {
const input = {} as I;
Object.values(this).forEach((v: Entry<keyof I>) => v.integrate(input));
return input;
}
- hasInput() {
+ pending() {
return Object.values(this).some((i: Entry<keyof I>) => i.hasInput());
}
}