Skip to content

Commit

Permalink
add map pool edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
stanrunge committed Nov 13, 2024
1 parent 93d7ae0 commit 2d388e5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function show(string $id)
*/
public function edit(string $id)
{
//
return Inertia::render('MapPools/Edit', ['mapPool' => MapPool::find($id)]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script>
import Layout from '../../Shared/Layout.svelte'
import { useForm } from '@inertiajs/svelte'
import { preventDefault } from 'svelte/legacy'
let { mapPool, mods } = $props()
let form = useForm({
map_pool_id: mapPool.id,
mod_id: null,
})
</script>

<Layout>
<h1>{mapPool.id}</h1>

<div class="flex flex-col justify-center text-center">
<table>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{#each mapPool.maps as map, index (map.id)}
<tr>
<td>{index + 1}</td>
<td>{map.name}</td>
<td>{map.description}</td>
</tr>
{/each}
</tbody>
</table>
<form onsubmit={preventDefault(() => $form.post('/map_pool_mods'))}>
<button>Add Mod</button>
</form>
</div>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,49 +1,14 @@
<script>
import { Link } from '@inertiajs/svelte'
import Layout from '../../Shared/Layout.svelte'
import { useForm } from '@inertiajs/svelte'
import { preventDefault } from 'svelte/legacy'
let { mapPool, mods } = $props()
let form = useForm({
map_pool_id: mapPool.id,
mod_id: null,
})
const addMod = () => {
$form.post(`/map_pool_maps`)
}
let { mapPool } = $props()
</script>

<Layout>
<h1>{mapPool.id}</h1>
<h1>{mapPool.name}</h1>

<div class="flex flex-col justify-center text-center">
<table>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{#each mapPool.maps as map, index (map.id)}
<tr>
<td>{index + 1}</td>
<td>{map.name}</td>
<td>{map.description}</td>
</tr>
{/each}
</tbody>
</table>
<form onsubmit={preventDefault(addMod)}>
<select name="new-mod">
{#each mods as mod}
<option value={mod.id}>{mod.name}</option>
{/each}
</select>
<button>Add Mod</button>
</form>
</div>
<Link href="/map_pools/{mapPool.id}/edit">
<button>Edit</button>
</Link>
</Layout>

0 comments on commit 2d388e5

Please sign in to comment.