-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Admin dashboard item page with pagination
- Loading branch information
1 parent
7a2fe13
commit 217fe5c
Showing
13 changed files
with
822 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ | |
|
||
class ItemAgeRating extends Model | ||
{ | ||
use HasFactory; | ||
protected $guarded = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/database/migrations/2024_01_19_102803_rename_category_on_items.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('items', function (Blueprint $table) { | ||
// remove category_id column | ||
$table->dropForeign(['category']); | ||
$table->dropColumn('category'); | ||
|
||
// remove rating column | ||
$table->dropForeign(['rating']); | ||
$table->dropColumn('rating'); | ||
|
||
// add category_id column | ||
$table->unsignedBigInteger('category_id')->nullable()->after('description'); | ||
$table->foreign('category_id')->references('id')->on('item_categories'); | ||
|
||
// add rating_id column | ||
$table->unsignedBigInteger('rating_id')->nullable()->after('ISBN'); | ||
$table->foreign('rating_id')->references('id')->on('item_age_ratings'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('items', function (Blueprint $table) { | ||
$table->renameColumn('category_id', 'category'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<div class="pagination" v-if="links.length > 3"> | ||
<div class="flex flex-wrap -mb-1"> | ||
<template v-for="(link, key) in links" :key="key"> | ||
<div v-if="link.url === null" class="link-wrap" v-html="link.label" /> | ||
<InertiaLink v-else :key="key" class="inertia-link" :class="{ 'bg-white': link.active }" :href="link.url" v-html="link.label" /> | ||
</template> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "Pagination", | ||
props: { | ||
links: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.link-wrap { | ||
display: inline-block; | ||
margin-right: 0.25rem; | ||
margin-bottom: 0.25rem; | ||
padding: 0.5rem 0.75rem; | ||
font-size: 0.875rem; | ||
line-height: 1.25rem; | ||
border-radius: 0.25rem; | ||
color: #9ca3af; | ||
} | ||
.inertia-link { | ||
margin-right: 0.25rem; | ||
margin-bottom: 0.25rem; | ||
padding: 0.5rem 0.75rem; | ||
font-size: 0.875rem; | ||
line-height: 1.25rem; | ||
border-radius: 0.25rem; | ||
} | ||
.inertia-link:hover { | ||
background-color: #fff; | ||
color: #1d4ed8; | ||
} | ||
.inertia-link:focus { | ||
outline: 2px solid transparent; | ||
outline-offset: 2px; | ||
box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5); | ||
} | ||
.pagination { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
margin-top: 1rem; | ||
margin-bottom: 1rem; | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<template> | ||
<AdminLayout > | ||
<div class="content"> | ||
<div class="header"> | ||
<h1>Items</h1> | ||
</div> | ||
<div class="table"> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Titel</th> | ||
<th scope="col">Beschrijving</th> | ||
<th scope="col">Auteur</th> | ||
<th scope="col">Categorie</th> | ||
<th scope="col">Leeftijd</th> | ||
<th scope="col">ISBN</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="item in items.data"> | ||
<th scope="row">{{item.id}}</th> | ||
<td>{{item.name}}</td> | ||
<td>{{item.description}}</td> | ||
<td>{{item.author}}</td> | ||
<td>{{item.category}}</td> | ||
<td>{{item.age_rating}}</td> | ||
<td>{{item.ISBN ?? 'Onbekend'}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<Pagination :links="items.links" /> | ||
</div> | ||
</AdminLayout> | ||
</template> | ||
<script> | ||
import AdminLayout from "@layouts/admin-layout.vue"; | ||
import Pagination from "@components/admin/pagination.vue"; | ||
import { computed } from 'vue' | ||
import { usePage } from '@inertiajs/vue3' | ||
export default { | ||
name: "admin-items-index", | ||
components: { | ||
AdminLayout, | ||
Pagination | ||
}, | ||
setup() { | ||
const page = usePage(); | ||
const items = computed(() => page.props.items); | ||
return {items}; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
|
||
.content { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: flex-start; | ||
padding: 50px; | ||
} | ||
|
||
.header { | ||
display: flex; | ||
justify-content: flex-start; | ||
width: 100%; | ||
padding-left: 30px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.table { | ||
padding: 0 30px 0 30px; | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
border-radius: 1em; | ||
overflow: hidden; | ||
} | ||
|
||
tbody:has(tr) { | ||
cursor: pointer; | ||
} | ||
|
||
td, th { | ||
max-width: 210px; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.