Skip to content

Commit

Permalink
add fixed field display & types
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaxcess committed Feb 2, 2024
1 parent a5278f8 commit a03369c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion svelte/components/Input/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Config {
display: "IPFS",
editable: false,
fields: [
{ key: "apiEndPoint", value: "", fixed: true, undeletable: true },
{ key: "apiEndPoint", value: "", display: "API end Point", fixed: true, undeletable: true },
{ key: "apiKey", value: "", fixed: true, undeletable: true }
]
},
Expand Down
2 changes: 1 addition & 1 deletion svelte/components/Input/Config/ConfigFieldsLoop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{#each fieldsGroup.fields as fieldEntries, i}
<div class="kre-section-small">
{#if fieldEntries.fixed}
<span>{fieldEntries.key}</span>
<span>{fieldEntries.display || fieldEntries.key}</span>
{:else}
<input type="text" class="kre-field-outline" placeholder={fieldEntries.key} bind:value={fieldEntries.key} />
{/if}
Expand Down
9 changes: 9 additions & 0 deletions svelte/components/Input/Config/InputConfigFields.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import type { UserConfig } from "./configTypes";
import config from "@config/config.json";
import { onMount } from "svelte";
import Config from "./Config";
Expand Down Expand Up @@ -42,6 +43,14 @@
const localConfigGetKey = (key) => key.replace(`${krdNamespace}.`, "");
const importConfigSection= (namespace, configSection) => {
}
const defaultConfigInit = () => {
let storage = config.storage;
}
const localConfigInit = (): void => {
// if (!localConfigGet("api")) localConfigSet("api", BEE_API_DEFAULT);
// if (!localConfigGet("gateway")) localConfigSet("gateway", BEE_GATEWAY_DEFAULT);
Expand Down
28 changes: 13 additions & 15 deletions svelte/components/Input/Config/configTypes.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
type UserConfig = {
[key: string]: ConfigAttribute;
};
type UserConfig = Record<string, ConfigSection>;

type ConfigAttribute = ChoiceAttribute | {
type ConfigSection = {
display: string;
default: { display: string; value: string };
editable: boolean;
fieldsType: string;
default?: { display: string; value: string };
fields?: FieldsList[];
fieldsGroups: Record<string, FieldGroup>;
}

type ChoiceAttribute = {
[key: string]: {fields: FieldsList[];};
}
type FieldGroup = {
display?: string;
editable?: boolean;
fields: Field[];
};

type FieldsList = {
type Field = {
key: string;
value: string;
display?: string;
fixed?: boolean;
undeletable?: boolean;
}
};

export type {
UserConfig,
ConfigAttribute,
ChoiceAttribute,
FieldsList
ConfigSection,
};

0 comments on commit a03369c

Please sign in to comment.