|
|
|
@ -11,6 +11,8 @@ |
|
|
|
let dropdown |
|
|
|
let editing |
|
|
|
let confirmDeleteDialog |
|
|
|
let error = "" |
|
|
|
let originalName = table.name |
|
|
|
|
|
|
|
$: fields = Object.keys(table.schema) |
|
|
|
|
|
|
|
@ -39,6 +41,15 @@ |
|
|
|
notifier.success("Table renamed successfully") |
|
|
|
hideEditor() |
|
|
|
} |
|
|
|
|
|
|
|
function checkValid(evt) { |
|
|
|
const tableName = evt.target.value |
|
|
|
if (originalName !== tableName && $backendUiStore.models.some(model => model.name === tableName)) { |
|
|
|
error = `Table with name ${tableName} already exists. Please choose another name.` |
|
|
|
return |
|
|
|
} |
|
|
|
error = "" |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<div bind:this={anchor} class="icon" on:click={dropdown.show}> |
|
|
|
@ -48,7 +59,11 @@ |
|
|
|
{#if editing} |
|
|
|
<div class="actions"> |
|
|
|
<h5>Edit Table</h5> |
|
|
|
<Input label="Table Name" thin bind:value={table.name} /> |
|
|
|
<Input |
|
|
|
label="Table Name" thin bind:value={table.name} |
|
|
|
on:input={checkValid} |
|
|
|
{error} |
|
|
|
/> |
|
|
|
<Select |
|
|
|
label="Primary Display Column" |
|
|
|
thin |
|
|
|
@ -61,7 +76,7 @@ |
|
|
|
</Select> |
|
|
|
<footer> |
|
|
|
<Button secondary on:click={hideEditor}>Cancel</Button> |
|
|
|
<Button primary on:click={save}>Save</Button> |
|
|
|
<Button primary disabled={error} on:click={save}>Save</Button> |
|
|
|
</footer> |
|
|
|
</div> |
|
|
|
{:else} |
|
|
|
|