64
64
</tbody >
65
65
</table >
66
66
</div >
67
- <div class =" sidebar" >
67
+ <div class =" sidebar" v-if = " threadData?.count > threadData?.limit " >
68
68
<div class =" sidebar-block" v-if =" threadData?.threads" >
69
69
<pagination :page =" threadData.page" :limit =" threadData.limit" :count =" threadData.count" ></pagination >
70
70
</div >
71
+ <div class =" pagination-wrap" >
72
+ <simple-pagination
73
+ v-model =" currentPage"
74
+ :pages =" pages"
75
+ :range-size =" 1"
76
+ @update:modelValue =" pageResults"
77
+ />
78
+ </div >
71
79
</div >
72
80
</template >
73
81
74
82
<script >
75
83
import Pagination from ' @/components/layout/Pagination.vue'
76
84
import humanDate from ' @/composables/filters/humanDate'
77
- import { reactive , toRefs } from ' vue'
85
+ import { reactive , computed , toRefs } from ' vue'
86
+ import { useRouter , useRoute } from ' vue-router'
78
87
import { threadsApi } from ' @/api'
79
88
import { localStoragePrefs } from ' @/composables/stores/prefs'
89
+ import SimplePagination from ' @/components/layout/SimplePagination.vue'
80
90
81
91
export default {
82
92
name: ' ThreadsPostedIn' ,
83
- components: { Pagination },
93
+ components: { Pagination, SimplePagination },
84
94
beforeRouteEnter (to , from , next ) {
85
95
const params = {
86
96
limit: localStoragePrefs ().data .threads_per_page ,
@@ -96,13 +106,26 @@ export default {
96
106
threadsApi .postedIn (params).then (data => this .threadData = data )
97
107
},
98
108
setup () {
109
+ const pageResults = page => {
110
+ console .log (page)
111
+ let query = { ... $route .query , page: page }
112
+ if (query .page === 1 || ! query .page ) delete query .page
113
+ if ($route .query .page !== v .currentPage )
114
+ $router .replace ({ name: $route .name , params: $route .params , query: query })
115
+ }
116
+
117
+ const $route = useRoute ()
118
+ const $router = useRouter ()
119
+
99
120
/* View Data */
100
121
const v = reactive ({
122
+ currentPage: Number ($route .query .page ) || 1 ,
123
+ pages: computed (() => Math .ceil (v .threadData ? .count / v .threadData ? .limit )),
101
124
defaultAvatar: window .default_avatar ,
102
125
defaultAvatarShape: window .default_avatar_shape ,
103
126
threadData: null
104
127
})
105
- return { ... toRefs (v), humanDate }
128
+ return { ... toRefs (v), pageResults, humanDate }
106
129
}
107
130
}
108
131
< / script>
@@ -117,5 +140,20 @@ export default {
117
140
position: sticky;
118
141
top: $header- offset;
119
142
}
143
+ .pagination - wrap { display: none; }
144
+ @include break - mobile- sm {
145
+ border- top: 1px solid $border- color;
146
+ position: fixed;
147
+ bottom: 0 ;
148
+ right: 0 ;
149
+ left: 0 ;
150
+ background: $base- background- color;
151
+ padding: 0 .75rem ;
152
+ z- index: 1000 ;
153
+ margin: 0 auto;
154
+ width: 100vw ;
155
+ .sidebar - block { display: none; }
156
+ .pagination - wrap { display: block; }
157
+ }
120
158
}
121
159
< / style>
0 commit comments