add batch import button to database index pages
This commit is contained in:
parent
2dd643e92e
commit
64e50e1b50
4 changed files with 51 additions and 12 deletions
|
|
@ -11,13 +11,16 @@
|
||||||
import { onMount, onDestroy } from 'svelte'
|
import { onMount, onDestroy } from 'svelte'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
resource: 'weapons' | 'characters' | 'summons'
|
resource: 'weapons' | 'characters' | 'summons'
|
||||||
columns: IColumn[]
|
columns: IColumn[]
|
||||||
pageSize?: number
|
pageSize?: number
|
||||||
|
headerActions?: Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resource, columns, pageSize: initialPageSize = 20 }: Props = $props()
|
const { resource, columns, pageSize: initialPageSize = 20, headerActions }: Props = $props()
|
||||||
|
|
||||||
// State
|
// State
|
||||||
let data = $state<any[]>([])
|
let data = $state<any[]>([])
|
||||||
|
|
@ -159,6 +162,11 @@
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" placeholder="Search..." bind:value={searchTerm} />
|
<input type="text" placeholder="Search..." bind:value={searchTerm} />
|
||||||
|
|
||||||
|
<div class="controls-right">
|
||||||
|
{#if headerActions}
|
||||||
|
{@render headerActions()}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="page-size-selector">
|
<div class="page-size-selector">
|
||||||
<label for="page-size">Show:</label>
|
<label for="page-size">Show:</label>
|
||||||
<select id="page-size" value={pageSize} onchange={handlePageSizeChange}>
|
<select id="page-size" value={pageSize} onchange={handlePageSizeChange}>
|
||||||
|
|
@ -169,6 +177,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid-wrapper" class:loading>
|
<div class="grid-wrapper" class:loading>
|
||||||
{#if loading}
|
{#if loading}
|
||||||
|
|
@ -249,6 +258,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.controls-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: spacing.$unit;
|
||||||
|
}
|
||||||
|
|
||||||
.page-size-selector {
|
.page-size-selector {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,11 @@
|
||||||
import DatabaseGridWithProvider from '$lib/components/database/DatabaseGridWithProvider.svelte'
|
import DatabaseGridWithProvider from '$lib/components/database/DatabaseGridWithProvider.svelte'
|
||||||
import ElementCell from '$lib/components/database/cells/ElementCell.svelte'
|
import ElementCell from '$lib/components/database/cells/ElementCell.svelte'
|
||||||
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
||||||
|
import Button from '$lib/components/ui/Button.svelte'
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
import { getRarityLabel } from '$lib/utils/rarity'
|
import { getRarityLabel } from '$lib/utils/rarity'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +63,13 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<DatabaseGridWithProvider resource="characters" {columns} pageSize={20} />
|
<DatabaseGridWithProvider resource="characters" {columns} pageSize={20}>
|
||||||
|
{#snippet headerActions()}
|
||||||
|
<Button variant="secondary" size="small" onclick={() => goto('/database/characters/import')}>
|
||||||
|
Batch Import
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
|
</DatabaseGridWithProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
import ElementCell from '$lib/components/database/cells/ElementCell.svelte'
|
import ElementCell from '$lib/components/database/cells/ElementCell.svelte'
|
||||||
import SummonUncapCell from '$lib/components/database/cells/SummonUncapCell.svelte'
|
import SummonUncapCell from '$lib/components/database/cells/SummonUncapCell.svelte'
|
||||||
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
||||||
|
import Button from '$lib/components/ui/Button.svelte'
|
||||||
import { getRarityLabel } from '$lib/utils/rarity'
|
import { getRarityLabel } from '$lib/utils/rarity'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
// Column configuration for summons
|
// Column configuration for summons
|
||||||
const columns: IColumn[] = [
|
const columns: IColumn[] = [
|
||||||
|
|
@ -61,7 +63,13 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="database-page">
|
<div class="database-page">
|
||||||
<DatabaseGridWithProvider resource="summons" {columns} pageSize={20} />
|
<DatabaseGridWithProvider resource="summons" {columns} pageSize={20}>
|
||||||
|
{#snippet headerActions()}
|
||||||
|
<Button variant="secondary" size="small" onclick={() => goto('/database/summons/import')}>
|
||||||
|
Batch Import
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
|
</DatabaseGridWithProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@
|
||||||
import ProficiencyCell from '$lib/components/database/cells/ProficiencyCell.svelte'
|
import ProficiencyCell from '$lib/components/database/cells/ProficiencyCell.svelte'
|
||||||
import WeaponUncapCell from '$lib/components/database/cells/WeaponUncapCell.svelte'
|
import WeaponUncapCell from '$lib/components/database/cells/WeaponUncapCell.svelte'
|
||||||
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
import LastUpdatedCell from '$lib/components/database/cells/LastUpdatedCell.svelte'
|
||||||
|
import Button from '$lib/components/ui/Button.svelte'
|
||||||
import { getRarityLabel } from '$lib/utils/rarity'
|
import { getRarityLabel } from '$lib/utils/rarity'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
// Column configuration for weapons
|
// Column configuration for weapons
|
||||||
const columns: IColumn[] = [
|
const columns: IColumn[] = [
|
||||||
|
|
@ -69,7 +71,13 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="database-page">
|
<div class="database-page">
|
||||||
<DatabaseGridWithProvider resource="weapons" {columns} pageSize={20} />
|
<DatabaseGridWithProvider resource="weapons" {columns} pageSize={20}>
|
||||||
|
{#snippet headerActions()}
|
||||||
|
<Button variant="secondary" size="small" onclick={() => goto('/database/weapons/import')}>
|
||||||
|
Batch Import
|
||||||
|
</Button>
|
||||||
|
{/snippet}
|
||||||
|
</DatabaseGridWithProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue