-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from julix14/feature/show-list
Feature/show list
- Loading branch information
Showing
10 changed files
with
197 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ logs | |
.env.* | ||
!.env.example | ||
service-account.json | ||
|
||
# Build files | ||
.firebase |
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 |
---|---|---|
@@ -1,5 +1,31 @@ | ||
<template> | ||
<div> | ||
<header> | ||
<UHorizontalNavigation | ||
:links="links" | ||
class="border-b border-gray-200 dark:border-gray-800" /> | ||
</header> | ||
<slot> </slot> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const links = [ | ||
{ label: "Home", to: "/", icon: "i-heroicons-home" }, | ||
{ | ||
label: "Add Attraction", | ||
to: "/add-attraction", | ||
icon: "i-heroicons-plus-circle", | ||
}, | ||
{ | ||
label: "List Attractions", | ||
to: "/list-attractions", | ||
icon: "i-heroicons-list-bullet", | ||
}, | ||
{ | ||
label: "List Categories", | ||
to: "/list-categories", | ||
icon: "i-heroicons-list-bullet", | ||
}, | ||
]; | ||
</script> |
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,46 @@ | ||
<template> | ||
<pre>{{ JSON.stringify(attraction, undefined, 4) }}</pre> | ||
</template> | ||
|
||
<script setup> | ||
import { collection, doc } from "firebase/firestore"; | ||
const route = useRoute(); | ||
const id = route.params.id; | ||
const { firestore } = useFirebaseClient(); | ||
const categories = useCollection( | ||
collection(firestore, "categories").withConverter({ | ||
fromFirestore(snapshot, options) { | ||
const data = snapshot.data(options); | ||
return { | ||
id: snapshot.id, | ||
name: data.name, | ||
}; | ||
}, | ||
}) | ||
); | ||
const attraction = useDocument( | ||
doc(collection(firestore, "activities"), id).withConverter({ | ||
fromFirestore(snapshot, options) { | ||
const data = snapshot.data(options); | ||
return { | ||
id: snapshot.id, | ||
name: data.name, | ||
socialMediaLink: data.socialMediaLink, | ||
websiteUrl: data.websiteUrl, | ||
price: data.price, | ||
address: data.address, | ||
isBerlin: data.isBerlin, | ||
isRegional: data.isRegional, | ||
categories: data.categories.map((category) => { | ||
return categories.value.find((c) => c.id === category); | ||
}), | ||
}; | ||
}, | ||
}), | ||
{ | ||
once: true, | ||
} | ||
); | ||
</script> |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<template> | ||
<div> | ||
<p>Hello</p> | ||
<NuxtLink to="/add-attraction">Add Attraction</NuxtLink> | ||
<NuxtLink to="/add-attraction">Add Attraction</NuxtLink><br /> | ||
<NuxtLink to="/list-attractions">List Attractions</NuxtLink> | ||
</div> | ||
</template> | ||
|
||
<script setup></script> | ||
|
||
<style></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,59 @@ | ||
<template> | ||
<div> | ||
<UTable | ||
:rows="rows" | ||
sortable | ||
:loading="tableLoad" | ||
@select="openDetails" | ||
class="m-2" /> | ||
<div | ||
class="flex justify-end px-3 py-3.5 border-t border-gray-200 dark:border-gray-700"> | ||
<UPagination | ||
v-model="page" | ||
:page-count="pageCount" | ||
:total="attractions.length" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { collection } from "firebase/firestore"; | ||
const { firestore } = useFirebaseClient(); | ||
const attractions = useCollection( | ||
collection(firestore, "activities").withConverter({ | ||
fromFirestore(snapshot, options) { | ||
const data = snapshot.data(options); | ||
return { | ||
id: snapshot.id, | ||
name: data.name, | ||
socialMediaLink: data.socialMediaLink, | ||
websiteUrl: data.websiteUrl, | ||
price: data.price, | ||
address: data.address, | ||
isBerlin: data.isBerlin, | ||
isRegional: data.isRegional, | ||
}; | ||
}, | ||
}), | ||
{ once: true } | ||
); | ||
const openDetails = (row) => { | ||
navigateTo(`/attraction-${row.id}`); | ||
}; | ||
const tableLoad = computed(() => { | ||
// Don't know why this operation works in that way, but it does | ||
return attractions.value < true; | ||
}); | ||
const page = ref(1); | ||
const pageCount = 20; | ||
const rows = computed(() => { | ||
return attractions.value.slice( | ||
(page.value - 1) * pageCount, | ||
page.value * pageCount | ||
); | ||
}); | ||
</script> |
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,50 @@ | ||
<template> | ||
<div> | ||
<UTable | ||
:rows="rows" | ||
sortable | ||
:loading="tableLoad" | ||
@select="openDetails" | ||
:columns="columns" | ||
class="m-2" /> | ||
<div | ||
class="flex justify-end px-3 py-3.5 border-t border-gray-200 dark:border-gray-700"> | ||
<UPagination | ||
v-model="page" | ||
:page-count="pageCount" | ||
:total="categories.length" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { collection } from "firebase/firestore"; | ||
const { firestore } = useFirebaseClient(); | ||
const categories = useCollection(collection(firestore, "categories"), { | ||
once: true, | ||
}); | ||
const columns = [ | ||
{ key: "name", label: "Name" }, | ||
{ key: "id", label: "ID" }, | ||
]; | ||
function openDetails(category) { | ||
console.log("To be implemented"); | ||
} | ||
const tableLoad = computed(() => { | ||
// Don't know why this operation works in that way, but it does | ||
return categories.value < true; | ||
}); | ||
const page = ref(1); | ||
const pageCount = 20; | ||
const rows = computed(() => { | ||
return categories.value.slice( | ||
(page.value - 1) * pageCount, | ||
page.value * pageCount | ||
); | ||
}); | ||
</script> |