-
Notifications
You must be signed in to change notification settings - Fork 159
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 #5470 from owncloud/feat/page-size
feat: add page size
- Loading branch information
Showing
30 changed files
with
401 additions
and
265 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: add page size view option | ||
|
||
We've added a new item into the view options which can be used to set the number of items displayed per page. | ||
This value is persisted in the local storage so that the user doesn't have to update it every time he visits the app. | ||
|
||
https://github.com/owncloud/web/pull/5470 |
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
115 changes: 115 additions & 0 deletions
115
packages/web-app-files/src/components/AppBar/ViewOptions.vue
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,115 @@ | ||
<template> | ||
<div> | ||
<oc-button | ||
id="files-view-options-btn" | ||
key="files-view-options-btn" | ||
data-testid="files-view-options-btn" | ||
:aria-label="viewButtonAriaLabel" | ||
variation="passive" | ||
appearance="raw" | ||
size="small" | ||
gap-size="xsmall" | ||
> | ||
<oc-icon name="tune" size="small" /> | ||
<translate>View</translate> | ||
</oc-button> | ||
<oc-drop | ||
drop-id="files-view-options-drop" | ||
toggle="#files-view-options-btn" | ||
mode="click" | ||
class="uk-width-auto" | ||
> | ||
<oc-list> | ||
<li class="files-view-options-list-item"> | ||
<oc-switch | ||
v-model="hiddenFilesShownModel" | ||
data-testid="files-switch-hidden-files" | ||
:label="$gettext('Show hidden files')" | ||
/> | ||
</li> | ||
<li class="files-view-options-list-item"> | ||
<oc-page-size | ||
v-model="pageItemsLimit" | ||
data-testid="files-pagination-size" | ||
:label="$gettext('Items per page')" | ||
:options="[100, 500, 1000, $gettext('All')]" | ||
class="files-pagination-size" | ||
/> | ||
</li> | ||
</oc-list> | ||
</oc-drop> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapMutations, mapState } from 'vuex' | ||
export default { | ||
computed: { | ||
...mapState('Files', ['areHiddenFilesShown', 'filesPageLimit']), | ||
viewButtonAriaLabel() { | ||
return this.$gettext('Display customization options of the files list') | ||
}, | ||
hiddenFilesShownModel: { | ||
get() { | ||
return this.areHiddenFilesShown | ||
}, | ||
set(value) { | ||
this.SET_HIDDEN_FILES_VISIBILITY(value) | ||
} | ||
}, | ||
pageItemsLimit: { | ||
get() { | ||
return this.filesPageLimit | ||
}, | ||
set(value) { | ||
this.updateQuery(value) | ||
} | ||
} | ||
}, | ||
watch: { | ||
$route: { | ||
handler(route) { | ||
if (Object.prototype.hasOwnProperty.call(route.query, 'items-limit')) { | ||
this.SET_FILES_PAGE_LIMIT(route.query['items-limit']) | ||
return | ||
} | ||
this.updateQuery() | ||
}, | ||
immediate: true | ||
} | ||
}, | ||
methods: { | ||
...mapMutations('Files', ['SET_HIDDEN_FILES_VISIBILITY', 'SET_FILES_PAGE_LIMIT']), | ||
updateQuery(limit = this.pageItemsLimit) { | ||
const query = { ...this.$route.query, 'items-limit': limit } | ||
this.SET_FILES_PAGE_LIMIT(limit) | ||
this.$router.replace({ query }).catch(() => {}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.files-view-options-list-item { | ||
& > * { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
& + & { | ||
margin-top: var(--oc-space-small); | ||
} | ||
} | ||
</style> |
21 changes: 21 additions & 0 deletions
21
packages/web-app-files/src/components/FilesList/Pagination.vue
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,21 @@ | ||
<template> | ||
<oc-pagination | ||
v-if="pages > 1" | ||
:pages="pages" | ||
:current-page="currentPage" | ||
:max-displayed="3" | ||
:current-route="$route" | ||
class="files-pagination uk-flex uk-flex-center oc-my-s" | ||
/> | ||
</template> | ||
|
||
<script> | ||
import { mapState, mapGetters } from 'vuex' | ||
export default { | ||
computed: { | ||
...mapState('Files', ['currentPage']), | ||
...mapGetters('Files', ['pages']) | ||
} | ||
} | ||
</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
Oops, something went wrong.