Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dlaxcess committed Jan 30, 2024
1 parent ea9922f commit 01bf693
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
5 changes: 5 additions & 0 deletions svelte/components/Input/Config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export default class Config {
addAttribute = () => {

}

addField(namespace): void {
this.configAttributes[namespace].fields = [...this.configAttributes[namespace].fields, { key: "", value: "" }];
// attributes[namespace].fields = [...attributes[namespace].fields, { key: "", value: "" }];
};
}

//////////////////////////////////////////////
Expand Down
6 changes: 4 additions & 2 deletions svelte/components/Input/Config/ConfigField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import { clickOutside } from "@helpers/clickOutside";
import ConfigFieldsLoop from "./ConfigFieldsLoop.svelte";
export let attributesObject;
export let attributes;
// /////////////////////
let open = false;
Expand All @@ -18,7 +20,7 @@
<div class="titre">{attribute.display}</div>
{/if}
{#if attribute.fieldsType === "list"}
<ConfigFieldsLoop bind:attributes {attribute} bind:fields={attribute.fields} {namespace} />
<ConfigFieldsLoop bind:attributesObject bind:attributes {attribute} bind:fields={attribute.fields} {namespace} />
{:else if attribute.fieldsType === "choice"}
<div
class="select-wrapper select-network"
Expand Down Expand Up @@ -50,7 +52,7 @@
</div>
</div>
</div>
<ConfigFieldsLoop bind:attributes {attribute} bind:fields={attribute[attribute.default.value].fields} {namespace} />
<ConfigFieldsLoop bind:attributesObject bind:attributes {attribute} bind:fields={attribute[attribute.default.value].fields} {namespace} />
{/if}
{/each}

Expand Down
7 changes: 5 additions & 2 deletions svelte/components/Input/Config/ConfigFieldsLoop.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<script lang="ts">
export let attributesObject;
export let attributes;
export let attribute;
export let fields;
export let namespace;
const addField = (namespace): void => {
attributes[namespace].fields = [...attributes[namespace].fields, { key: "", value: "" }];
console.log("addField ~ attributesObject1:", attributesObject);
attributesObject.addField(namespace);
// attributes[namespace].fields = [...attributes[namespace].fields, { key: "", value: "" }];
console.log("addField ~ attributesObject2:", attributesObject);
};
const removeField = (namespace: string, i: number): void => {
Expand Down
18 changes: 12 additions & 6 deletions svelte/components/Input/Config/InputConfigFields.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@
// let userConfig: { namespace: {fields: [{ key: "" , value: ""}]} };
let userConfig;
let config;
let attributesObject;
let attributes;
const krdNamespace = "kredeum";
// $: attributesObject?.configAttributes && handle();
$: attributesObject?.configAttributes && handle();
const handle = () => {
attributes = attributesObject?.getConfig();
console.log("handle ~ attributesObject:", attributesObject);
};
onMount(() => {
config = new Config();
attributes = config.getConfig();
attributesObject = new Config();
attributes = attributesObject.getConfig();
console.log("onMount ~ attributesObject:", attributesObject)
localConfigInit();
});
Expand Down Expand Up @@ -78,7 +86,6 @@
attributes[namespace].fields.push({ key: "", value: "" });
}
}
};
/////////////////////////
Expand All @@ -105,7 +112,6 @@
localConfigRemove(namespaceKey);
}
});
};
$: attributes && handleProperties();
Expand All @@ -130,7 +136,7 @@

<div class="section">
{#if attributes}
<ConfigField bind:attributes />
<ConfigField bind:attributesObject bind:attributes />
{/if}

<div class="txtright">
Expand Down

0 comments on commit 01bf693

Please sign in to comment.