fix: creating index from attributes

This commit is contained in:
Torsten Dittmann
2022-11-02 12:25:58 +01:00
parent b4854d7067
commit ff54164d64
@@ -2,6 +2,7 @@
import { Modal } from '$lib/components';
import { Button, InputText, FormList, InputSelect } from '$lib/elements/forms';
import { collection } from '../store';
import { onMount } from 'svelte';
import { sdkForProject } from '$lib/stores/sdk';
import { addNotification } from '$lib/stores/notifications';
import { page } from '$app/stores';
@@ -10,6 +11,7 @@
import { Dependencies } from '$lib/constants';
export let showCreateIndex = false;
export let externalAttribute: Attributes = null;
const databaseId = $page.params.database;
@@ -30,6 +32,12 @@
let selectedAttribute = '';
let selectedOrder = '';
onMount(() => {
if (externalAttribute) {
attributeList = [{ value: externalAttribute.key, order: 'ASC' }];
}
});
$: if (showCreateIndex) {
attributeList = [];
selectedType = selectedOrder = selectedAttribute = '';
@@ -122,7 +130,7 @@
<div class="form-item-part u-cross-child-end">
<Button
text
disabled={i === 0}
disabled={externalAttribute && i === 0}
on:click={() => {
if (i === 0) attributeList = [];
attributeList = attributeList.splice(i, 1);