aboutsummaryrefslogtreecommitdiff
path: root/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx')
-rw-r--r--packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx17
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
index 9c1a93d8e..a1f384743 100644
--- a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
@@ -37,12 +37,27 @@ export function AttributeEntryScreen(): VNode {
const fieldList: VNode[] = reqAttr.map((spec, i: number) => {
const value = attrs[spec.name];
const error = checkIfValid(value, spec);
+
+ function addAutocomplete(newValue: string): string {
+ const ac = spec.autocomplete;
+ if (!ac || ac.length < newValue.length || ac[newValue.length] === "?")
+ return newValue;
+
+ if (!value || newValue.length < value.length) {
+ return newValue.slice(0, -1);
+ }
+
+ return newValue + ac[newValue.length];
+ }
+
hasErrors = hasErrors || error !== undefined;
return (
<AttributeEntryField
key={i}
isFirst={i == 0}
- setValue={(v: string) => setAttrs({ ...attrs, [spec.name]: v })}
+ setValue={(v: string) =>
+ setAttrs({ ...attrs, [spec.name]: addAutocomplete(v) })
+ }
spec={spec}
errorMessage={error}
onConfirm={() => {