-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add auto pagination * style: rename components. * chore(ui): css style update. * chore: loading card unit is increased from 5 to 25 per page. * docs: update README.md.
- Loading branch information
Showing
6 changed files
with
426 additions
and
222 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 was deleted.
Oops, something went wrong.
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,116 @@ | ||
<template> | ||
<section> | ||
<header> | ||
<component | ||
:is="`display-${field?.meta?.display}`" | ||
v-bind="field?.meta?.display_options" | ||
:type="field?.type" | ||
:value="fieldValue" | ||
/> | ||
</header> | ||
<main class="paginate-units"> | ||
<paginate-unit | ||
v-for="page in pages" | ||
:key="page" | ||
:page="page" | ||
:collection-key="collectionKey" | ||
:field="field" | ||
:field-value="fieldValue" | ||
:layout-options="layoutOptions" | ||
:filter="filter" | ||
:search="search" | ||
@hasNextPage="hundleHasNextPage" | ||
/> | ||
</main> | ||
</section> | ||
</template> | ||
<script lang="ts"> | ||
import { Field, Filter, LogicalFilterAND } from "@directus/shared/types"; | ||
import { computed, defineComponent, PropType, ref, toRefs, watch } from "vue"; | ||
import { LayoutOptions } from "../types"; | ||
import PaginateUnit from "./paginateUnit.vue"; | ||
export default defineComponent({ | ||
components: { PaginateUnit }, | ||
inheritAttrs: false, | ||
props: { | ||
collection: { type: String, required: true }, | ||
field: { type: Object as PropType<Field> }, | ||
fieldValue: { type: String }, | ||
layoutOptions: { type: Object as PropType<LayoutOptions> }, | ||
filter: { | ||
type: Object as PropType<Filter | null>, | ||
default: null, | ||
}, | ||
search: { | ||
type: String as PropType<string | null>, | ||
default: null, | ||
}, | ||
}, | ||
setup(props) { | ||
const { | ||
fieldValue, | ||
field, | ||
filter: originFilter, | ||
collection: collectionKey, | ||
search, | ||
layoutOptions, | ||
} = toRefs(props); | ||
const pages = ref([1]) | ||
const filter = computed<LogicalFilterAND>(() => ({ | ||
_and: [ | ||
{ [field.value!.field]: { _eq: fieldValue.value } }, | ||
originFilter.value || {}, | ||
], | ||
})); | ||
const sort = computed(() => layoutOptions.value?.sort); | ||
watch([filter, sort, search], (after, before) => { | ||
if (JSON.stringify(after) != JSON.stringify(before)) { | ||
pages.value = [1]; | ||
} | ||
}); | ||
function hundleHasNextPage(page: number) { | ||
pages.value = [...new Set([...pages.value, page])]; | ||
} | ||
return { pages, collectionKey, hundleHasNextPage }; | ||
}, | ||
}); | ||
</script> | ||
<style scoped> | ||
section { | ||
background-color: var(--background-subdued); | ||
border-radius: var(--border-radius); | ||
flex: 0 0 320px; | ||
display: flex; | ||
flex-flow: column nowrap; | ||
align-items: stretch; | ||
} | ||
header { | ||
padding: 16px 16px 0 16px; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
.paginate-units { | ||
padding: 16px; | ||
flex-grow: 1; | ||
display: flex; | ||
flex-flow: column nowrap; | ||
} | ||
.paginate-units > * { | ||
flex: 0 0 auto; | ||
} | ||
.paginate-units > *:last-child { | ||
flex-grow: 1; | ||
} | ||
</style> |
Oops, something went wrong.