Update create table modal to use new forms

This commit is contained in:
Andrew Kingston 2021-04-16 09:40:44 +01:00
parent f2d3ff7f1b
commit c82c298a93
2 changed files with 26 additions and 16 deletions

View File

@ -91,9 +91,24 @@
} }
const handleTypeChange = column => evt => { const handleTypeChange = column => evt => {
schema[column].type = evt.target.value schema[column].type = evt.detail
validateCSV() validateCSV()
} }
const typeOptions = [
{
label: "Text",
value: "string",
},
{
label: "Number",
value: "number",
},
{
label: "Date",
value: "datetime",
},
]
</script> </script>
<div class="dropzone"> <div class="dropzone">
@ -108,14 +123,12 @@
<div class="field"> <div class="field">
<span>{columnName}</span> <span>{columnName}</span>
<Select <Select
secondary
thin
bind:value={schema[columnName].type} bind:value={schema[columnName].type}
on:change={handleTypeChange(columnName)}> on:change={handleTypeChange(columnName)}
<option value={'string'}>Text</option> options={typeOptions}
<option value={'number'}>Number</option> placeholder={null}
<option value={'datetime'}>Date</option> getOptionLabel={option => option.label}
</Select> getOptionValue={option => option.value} />
<span class="field-status" class:error={!schema[columnName].success}> <span class="field-status" class:error={!schema[columnName].success}>
{schema[columnName].success ? 'Success' : 'Failure'} {schema[columnName].success ? 'Success' : 'Failure'}
</span> </span>
@ -128,12 +141,10 @@
</div> </div>
{#if fields.length} {#if fields.length}
<div class="display-column"> <div class="display-column">
<Label extraSmall grey>Display Column</Label> <Select
<Select thin secondary bind:value={primaryDisplay}> label="Display Column"
{#each fields as field} bind:value={primaryDisplay}
<option value={field}>{field}</option> options={fields} />
{/each}
</Select>
</div> </div>
{/if} {/if}
@ -201,7 +212,7 @@
.field { .field {
display: grid; display: grid;
grid-template-columns: 2fr 4fr 1fr 1fr; grid-template-columns: 2fr 2fr 1fr auto;
margin-top: var(--spacing-m); margin-top: var(--spacing-m);
align-items: center; align-items: center;
grid-gap: var(--spacing-m); grid-gap: var(--spacing-m);

View File

@ -92,7 +92,6 @@
<ModalContent <ModalContent
title="Create Table" title="Create Table"
confirmText="Create" confirmText="Create"
size="large"
onConfirm={saveTable} onConfirm={saveTable}
disabled={error || !name || (dataImport && !dataImport.valid)}> disabled={error || !name || (dataImport && !dataImport.valid)}>
<Input <Input