Collections: open collection form on creation
This commit is contained in:
@@ -29,7 +29,7 @@ function createCollection() {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
addingCollection.value = false
|
addingCollection.value = false
|
||||||
collection.value.name = ''
|
collection.value.name = ''
|
||||||
emit('created')
|
res.json().then((json) => emit('created', json.id))
|
||||||
} else {
|
} else {
|
||||||
res.json().then((json) => (errors.value = json))
|
res.json().then((json) => (errors.value = json))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { getCollections } from './api.js'
|
import { getCollections } from './api.js'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import CollectionListElement from './CollectionListElement.vue'
|
import CollectionListElement from './CollectionListElement.vue'
|
||||||
import Pagination from './Pagination.vue'
|
import Pagination from './Pagination.vue'
|
||||||
import AddCollection from './AddCollection.vue'
|
import AddCollection from './AddCollection.vue'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const limit = 5
|
const limit = 5
|
||||||
const pageNumber = ref(1)
|
const pageNumber = ref(1)
|
||||||
|
|
||||||
@@ -29,13 +31,17 @@ function pageChange(newPageNumber) {
|
|||||||
data.value = null
|
data.value = null
|
||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goToCollection(id) {
|
||||||
|
router.push(`/collection/${id}`)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div v-if="error">{{ $t('collections.error', { error: error.message }) }}</div>
|
<div v-if="error">{{ $t('collections.error', { error: error.message }) }}</div>
|
||||||
<div v-else-if="data">
|
<div v-else-if="data">
|
||||||
<AddCollection @created="fetchData" />
|
<AddCollection @created="goToCollection" />
|
||||||
<div class="collectionslist">
|
<div class="collectionslist">
|
||||||
<div class="my-2" v-for="collection in data.collections" :key="collection.id">
|
<div class="my-2" v-for="collection in data.collections" :key="collection.id">
|
||||||
<CollectionListElement v-bind="collection" />
|
<CollectionListElement v-bind="collection" />
|
||||||
|
|||||||
Reference in New Issue
Block a user