Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/centerofci/mathesar into …
Browse files Browse the repository at this point in the history
…boolean_type
  • Loading branch information
pavish committed Mar 24, 2022
2 parents 475a31e + 119c60f commit 3794a14
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mathesar/tests/imports/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def headerless_data_file(headerless_csv_filename):
def schema(engine, test_db_model):
create_schema(TEST_SCHEMA, engine)
schema_oid = get_schema_oid_from_name(TEST_SCHEMA, engine)
yield Schema.objects.create(oid=schema_oid, database=test_db_model)
yield Schema.current_objects.create(oid=schema_oid, database=test_db_model)
with engine.begin() as conn:
conn.execute(text(f'DROP SCHEMA "{TEST_SCHEMA}" CASCADE;'))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { tick, createEventDispatcher } from 'svelte';
import {
faAngleDoubleLeft,
faAngleDoubleRight,
Expand Down Expand Up @@ -46,14 +46,17 @@
$: pageCount = Math.ceil(total / pageSize);
$: pageInfo = calculatePages(currentPage, pageCount);
function setPage(e: Event, _page: number) {
async function setPage(e: Event, _page: number) {
if (_page > 0 && _page <= pageCount && currentPage !== _page) {
currentPage = _page;
dispatch('change', {
currentPage,
originalEvent: e,
});
}
await tick();
const pagebutton = document.querySelector(`[data-page="${currentPage}"]`);
(pagebutton as HTMLElement)?.focus();
}
</script>

Expand Down Expand Up @@ -125,6 +128,7 @@
: `Goto Page ${_page}`}
aria-selected={currentPage === _page}
on:click={(e) => setPage(e, _page)}
data-page={_page}
data-tinro-ignore
>
{_page}
Expand All @@ -138,6 +142,7 @@
: `Goto Page ${_page}`}
class="page"
on:click={(e) => setPage(e, _page)}
data-page={_page}
aria-selected={currentPage === _page}
>
{_page}
Expand Down
25 changes: 18 additions & 7 deletions mathesar_ui/src/sections/import-data/preview/PreviewColumn.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
import type { PreviewColumn } from '@mathesar/stores/fileImports';
const dispatch = createEventDispatcher();
export let column: PreviewColumn;
const options = column.valid_target_types?.map((type) => ({
id: type,
label: type,
}));
function getOptions(_column: PreviewColumn) {
if (_column.valid_target_types === null) {
return [{ id: _column.type, label: _column.type }];
}
return _column.valid_target_types.map((type) => ({
id: type,
label: type,
}));
}
$: options = getOptions(column);
$: disabled = !column.isEditable;
let selectedOption = {
id: column.type,
label: column.type,
Expand All @@ -23,13 +33,14 @@
}
</script>

<th class:disabled={!column.isEditable}>
<th class:disabled>
<div class="name">
<Checkbox disabled={!column.isEditable} bind:checked={column.isSelected} />
<TextInput disabled={!column.isEditable} bind:value={column.displayName} />
<Checkbox {disabled} bind:checked={column.isSelected} />
<TextInput {disabled} bind:value={column.displayName} />
</div>
<div class="type">
<Select
{disabled}
{options}
triggerAppearance="plain"
bind:value={selectedOption}
Expand Down
2 changes: 1 addition & 1 deletion mathesar_ui/src/stores/fileImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface PreviewColumn {
isSelected?: boolean;
isEditable?: boolean;
primary_key?: boolean;
valid_target_types: string[];
valid_target_types: string[] | null;
}

export type PreviewRow = Record<string, string>;
Expand Down

0 comments on commit 3794a14

Please sign in to comment.