-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix pagination after increasing items per page #8854
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Bugfix: Pagination after increasing items per page | ||
|
||
An issue where the file list incorrectly showed no items after paginating and increasing the amount of items per page has been fixed. | ||
|
||
https://github.com/owncloud/web/issues/6768 | ||
https://github.com/owncloud/web/pull/8854 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ | |
v-if="viewModes.includes(ViewModeConstants.tilesView)" | ||
class="files-view-options-list-item oc-visible@s oc-flex oc-flex-between oc-flex-middle" | ||
> | ||
<label for="tiles-size-slider" v-text="resizeTilesLabel" /> | ||
<label for="tiles-size-slider" v-text="$gettext('Tile size')" /> | ||
<input | ||
v-model="viewSizeCurrent" | ||
type="range" | ||
|
@@ -89,9 +89,16 @@ | |
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, PropType, ref, unref, watch } from 'vue' | ||
import { computed, defineComponent, PropType, ref, unref, watch } from 'vue' | ||
import { mapMutations, mapState } from 'vuex' | ||
import { queryItemAsString, useRouteQueryPersisted } from 'web-pkg/src/composables' | ||
import { useGettext } from 'vue3-gettext' | ||
import { | ||
queryItemAsString, | ||
useRoute, | ||
useRouteQuery, | ||
useRouteQueryPersisted, | ||
useRouter | ||
} from 'web-pkg/src/composables' | ||
import { ViewMode } from 'web-pkg/src/ui/types' | ||
import { PaginationConstants, ViewModeConstants } from '../../composables' | ||
|
||
|
@@ -106,8 +113,19 @@ export default defineComponent({ | |
} | ||
}, | ||
setup() { | ||
const router = useRouter() | ||
const currentRoute = useRoute() | ||
const { $gettext } = useGettext() | ||
|
||
const queryParamsLoading = ref(false) | ||
|
||
const currentPageQuery = useRouteQuery('page') | ||
const currentPage = computed(() => { | ||
if (!unref(currentPageQuery)) { | ||
return 1 | ||
} | ||
return parseInt(queryItemAsString(unref(currentPageQuery))) | ||
}) | ||
const itemsPerPageQuery = useRouteQueryPersisted({ | ||
name: PaginationConstants.perPageQueryName, | ||
defaultValue: PaginationConstants.perPageDefault | ||
|
@@ -130,6 +148,21 @@ export default defineComponent({ | |
} | ||
} | ||
|
||
const setItemsPerPage = (itemsPerPage: string) => { | ||
const resetPagination = itemsPerPage > unref(itemsPerPageQuery) && unref(currentPage) > 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO we should go back to page 1 whenever the items per page change. So not only if the items per page increase, but instead on any change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought we already had this kind of reset in the past. Don't know if it got lost when we moved the pagination params from the store into the composable+query. 🤔 do you know or did you find any orphaned code fragments regarding the page reset? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good as well 👍
I didn't see anything regarding this. Where could such code be located? AFAIK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't find anything either |
||
return router.replace({ | ||
query: { | ||
...unref(currentRoute).query, | ||
'items-per-page': itemsPerPage, | ||
...(resetPagination && { page: '1' }) | ||
} | ||
}) | ||
} | ||
|
||
const setViewMode = (mode: ViewMode) => { | ||
viewModeQuery.value = mode.name | ||
} | ||
|
||
watch( | ||
[itemsPerPageQuery, viewModeQuery, viewSizeQuery], | ||
(params) => { | ||
|
@@ -154,19 +187,15 @@ export default defineComponent({ | |
viewSizeCurrent: viewSizeQuery, | ||
itemsPerPageCurrent: itemsPerPageQuery, | ||
queryParamsLoading, | ||
setTilesViewSize | ||
setTilesViewSize, | ||
setItemsPerPage, | ||
setViewMode, | ||
viewOptionsButtonLabel: $gettext('Display customization options of the files list') | ||
} | ||
}, | ||
computed: { | ||
...mapState('Files', ['areHiddenFilesShown', 'areFileExtensionsShown']), | ||
|
||
viewOptionsButtonLabel() { | ||
return this.$gettext('Display customization options of the files list') | ||
}, | ||
resizeTilesLabel() { | ||
return this.$gettext('Tile size') | ||
}, | ||
|
||
hiddenFilesShownModel: { | ||
get() { | ||
return this.areHiddenFilesShown | ||
|
@@ -189,12 +218,7 @@ export default defineComponent({ | |
methods: { | ||
queryItemAsString, | ||
...mapMutations('Files', ['SET_HIDDEN_FILES_VISIBILITY', 'SET_FILE_EXTENSIONS_VISIBILITY']), | ||
setViewMode(mode) { | ||
this.viewModeCurrent = mode.name | ||
}, | ||
setItemsPerPage(itemsPerPage) { | ||
this.itemsPerPageCurrent = itemsPerPage | ||
}, | ||
|
||
updateHiddenFilesShownModel(event) { | ||
this.hiddenFilesShownModel = event | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was about to do the same, but the bug report is still right though, no? The issue only occurred when increasing the amount of items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes :D fine by me either way