Skip to content

Commit e562e9d

Browse files
committed
feat: standardize pagination
1 parent 7228832 commit e562e9d

File tree

4 files changed

+54
-15
lines changed

4 files changed

+54
-15
lines changed

src/components/layout/SimplePagination.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export default {
123123
margin: 0;
124124
padding: 0;
125125
list-style-type: none;
126+
li { flex: 1; }
126127
}
127128
128129
.pagination-control {
@@ -135,7 +136,7 @@ export default {
135136
display: block;
136137
width: 18px;
137138
height: 18px;
138-
margin: 0 2px;
139+
margin: 0 auto;
139140
fill: $border-color;
140141
&:hover { fill: $border-color; }
141142
&-active {

src/components/settings/IgnoredSettingsPartial.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@
4343
</tbody>
4444
</table>
4545

46-
<div class="pagination-simple">
47-
<button @click="pullPage(-1)" :disabled="!ignored?.prev">&#10094; Prev</button>
48-
<button @click="pullPage(1)" :disabled="!ignored?.next">Next &#10095;</button>
46+
<div class="pagination-slide mobile-grid">
47+
<div class="pagination-controls">
48+
<button @click="pullPage(-1)" :disabled="!ignored?.prev">&#10094; Prev</button>
49+
<div class="page">{{currentPage}}</div>
50+
<button @click="pullPage(1)" :disabled="!ignored?.next">Next &#10095;</button>
51+
</div>
4952
</div>
5053
</div>
5154
</template>
5255

5356
<script>
54-
import { reactive, inject, onBeforeMount, toRefs } from 'vue'
57+
import { reactive, inject, onBeforeMount, toRefs, computed } from 'vue'
5558
import { usersApi } from '@/api'
5659
import Multiselect from '@vueform/multiselect'
5760
@@ -85,6 +88,7 @@ export default {
8588
8689
const v = reactive({
8790
ignoredInput: null,
91+
currentPage: computed(() => v.ignored?.page),
8892
ignored: {},
8993
defaultAvatar: window.default_avatar,
9094
defaultAvatarShape: window.default_avatar_shape,
@@ -114,7 +118,7 @@ export default {
114118
}
115119
</script>
116120
117-
<style lang="scss">
121+
<style lang="scss" scoped>
118122
.multiselect { margin: 0; }
119123
.input-button-wrap { margin-top: .25rem; }
120124
table.striped.ignored-users {
@@ -151,4 +155,8 @@ table.striped.ignored-users {
151155
.no-data { display: none; }
152156
}
153157
}
158+
159+
160+
.pagination-slide { grid-template-columns: 1fr; }
161+
154162
</style>

src/views/MemberSearch.vue

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,32 @@
4040
</table>
4141
</div>
4242
</div>
43-
<div class="sidebar">
44-
<div class="sidebar-block" v-if="searchData?.page_count > 1">
43+
<div class="sidebar" v-if="searchData?.page_count > 1">
44+
<div class="sidebar-block">
4545
<pagination :page="searchData.page" :limit="searchData.limit" :count="searchData.count" />
4646
</div>
47+
<div class="pagination-wrap">
48+
<simple-pagination
49+
v-model="currentPage"
50+
:pages="pages"
51+
:range-size="1"
52+
@update:modelValue="pageResults"
53+
/>
54+
</div>
4755
</div>
4856
</template>
4957

5058
<script>
51-
import { reactive, toRefs, nextTick } from 'vue'
59+
import { reactive, toRefs, nextTick, computed } from 'vue'
5260
import { usersApi } from '@/api'
5361
import Pagination from '@/components/layout/Pagination.vue'
5462
import { useRoute, useRouter } from 'vue-router'
5563
import humanDate from '@/composables/filters/humanDate'
64+
import SimplePagination from '@/components/layout/SimplePagination.vue'
5665
5766
export default {
5867
name: 'MemberSearch',
59-
components: { Pagination },
68+
components: { Pagination, SimplePagination },
6069
beforeRouteEnter(to, from, next) {
6170
const query = {
6271
limit: 10,
@@ -79,6 +88,13 @@ export default {
7988
next()
8089
},
8190
setup() {
91+
const pageResults = page => {
92+
let query = { ...$route.query, page: page }
93+
if (query.page === 1 || !query.page) delete query.page
94+
if ($route.query.page !== v.currentPage)
95+
$router.replace({ name: $route.name, params: $route.params, query: query })
96+
}
97+
8298
const searchUsers = () => {
8399
let query = { ...$route.query, search: v.search }
84100
delete query.field
@@ -135,6 +151,7 @@ export default {
135151
136152
const v = reactive({
137153
currentPage: Number($route.query.page) || 1,
154+
pages: computed(() => Math.ceil(v.searchData?.count / v.searchData?.limit)),
138155
searchData: null,
139156
search: $route.query.search,
140157
searchInput: null,
@@ -144,7 +161,7 @@ export default {
144161
145162
nextTick(() => v.searchInput.focus())
146163
147-
return { ...toRefs(v), searchUsers, clearSearch, setSortField, getSortClass, humanDate }
164+
return { ...toRefs(v), pageResults, searchUsers, clearSearch, setSortField, getSortClass, humanDate }
148165
}
149166
}
150167
</script>
@@ -159,17 +176,30 @@ export default {
159176
"sidebar sidebar";
160177
}
161178
}
162-
.user-search { grid-area: main; }
179+
.user-search { grid-area: main; width: 100%; }
163180
.sidebar {
164181
grid-area: sidebar;
165-
166182
.sidebar-block {
167183
display: block;
168184
position: sticky;
169185
top: $header-offset;
170186
}
187+
.pagination-wrap { display: none; }
188+
@include break-mobile-sm {
189+
border-top: 1px solid $border-color;
190+
position: fixed;
191+
bottom: 0;
192+
right: 0;
193+
left: 0;
194+
background: $base-background-color;
195+
padding: 0.75rem;
196+
z-index: 1000;
197+
margin: 0 auto;
198+
width: 100vw;
199+
.sidebar-block { display: none; }
200+
.pagination-wrap { display: block; }
201+
}
171202
}
172-
173203
.members td {
174204
height: 6.25rem;
175205
padding-left: 0;

src/views/Watchlist.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
</div>
8989

90-
<div class="actions-bottom">
90+
<div class="actions-bottom" v-if="watchlistData?.has_more_threads || watchlistData?.page > 1">
9191
<div class="pagination-slide">
9292
<div class="pagination-controls">
9393
<button @click="pageResults(-1)" :disabled="watchlistData?.page === 1">&#10094; Prev</button>

0 commit comments

Comments
 (0)