@blueprint-ts/core 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +508 -508
- package/CHANGELOG.md +68 -0
- package/LICENSE +20 -20
- package/docs/.vitepress/config.ts +7 -10
- package/examples/index.html +14 -14
- package/examples/js/app.js +8 -8
- package/examples/js/router.js +21 -21
- package/examples/js/view/App.vue +48 -48
- package/examples/js/view/layout/DemoPage.vue +27 -27
- package/examples/js/view/pagination/Pagination.vue +27 -27
- package/examples/js/view/pagination/components/errorPagination/ErrorPagination.vue +70 -70
- package/examples/js/view/pagination/components/errorPagination/GetProductsRequest.ts +53 -53
- package/examples/js/view/pagination/components/infiniteScrolling/GetProductsRequest.ts +49 -49
- package/examples/js/view/pagination/components/infiniteScrolling/InfiniteScrolling.vue +56 -56
- package/examples/js/view/pagination/components/tablePagination/GetProductsRequest.ts +49 -49
- package/examples/js/view/pagination/components/tablePagination/TablePagination.vue +62 -62
- package/examples/js/view/requests/Requests.vue +33 -33
- package/examples/js/view/requests/components/abortableRequest/AbortableRequest.vue +35 -35
- package/examples/js/view/requests/components/abortableRequest/GetProductsRequest.ts +24 -24
- package/examples/js/view/requests/components/fileDownloadRequest/DownloadFileRequest.ts +14 -14
- package/examples/js/view/requests/components/fileDownloadRequest/FileDownloadRequest.vue +43 -43
- package/examples/js/view/requests/components/getRequestWithDynamicParams/GetProductsRequest.ts +33 -33
- package/examples/js/view/requests/components/getRequestWithDynamicParams/GetRequestWithDynamicParams.vue +58 -58
- package/examples/js/view/requests/components/serverErrorRequest/ServerErrorRequest.ts +20 -20
- package/examples/js/view/requests/components/serverErrorRequest/ServerErrorRequest.vue +52 -52
- package/package.json +3 -2
- package/src/helpers.ts +78 -78
- package/src/service/pagination/InfiniteScroller.ts +21 -21
- package/src/service/pagination/Paginator.ts +149 -149
- package/src/service/pagination/contracts/PaginatorLoadDataOptions.ts +4 -4
- package/src/service/pagination/contracts/ViewDriverContract.ts +12 -12
- package/src/service/pagination/contracts/ViewDriverFactoryContract.ts +5 -5
- package/src/service/pagination/dtos/PaginationDataDto.ts +14 -14
- package/src/service/pagination/factories/VuePaginationDriverFactory.ts +9 -9
- package/src/service/pagination/frontendDrivers/VuePaginationDriver.ts +61 -61
- package/src/service/pagination/index.ts +16 -16
- package/src/service/requests/ErrorHandler.ts +64 -64
- package/src/service/requests/contracts/RequestDriverContract.ts +15 -15
- package/src/service/requests/exceptions/NoResponseReceivedException.ts +3 -3
- package/src/service/requests/exceptions/NotFoundException.ts +3 -3
- package/src/service/requests/exceptions/PageExpiredException.ts +3 -3
- package/src/service/requests/exceptions/ServerErrorException.ts +3 -3
- package/src/service/requests/exceptions/UnauthorizedException.ts +3 -3
- package/src/service/requests/exceptions/ValidationException.ts +3 -3
- package/src/service/requests/exceptions/index.ts +19 -19
- package/src/service/requests/index.ts +50 -50
- package/src/service/requests/responses/BlobResponse.ts +19 -19
- package/src/service/requests/responses/JsonResponse.ts +15 -15
- package/src/service/requests/responses/PlainTextResponse.ts +15 -15
- package/src/vue/composables/useIsOpen.ts +37 -37
- package/src/vue/composables/useIsOpenFromVar.ts +61 -61
- package/src/vue/composables/useModelWrapper.ts +24 -24
- package/src/vue/composables/useOnOpen.ts +34 -34
- package/src/vue/forms/BaseForm.ts +10 -11
- package/src/vue/forms/validation/rules/ConfirmedRule.ts +1 -1
- package/src/vue/index.ts +14 -14
- package/src/vue/router/{routeModelBinding/RouteModelRequestResolver.ts → routeResourceBinding/RouteResourceRequestResolver.ts} +1 -1
- package/src/vue/router/{routeModelBinding → routeResourceBinding}/index.ts +4 -2
- package/src/vue/router/{routeModelBinding → routeResourceBinding}/installRouteInjection.ts +32 -12
- package/src/vue/router/{routeModelBinding → routeResourceBinding}/types.ts +3 -1
- package/src/vue/router/routeResourceBinding/useRouteResource.ts +14 -0
- package/src/vue/state/State.ts +1 -0
- /package/docs/vue/requests/{route-model-binding.md → route-resource-binding.md} +0 -0
- /package/src/vue/router/{routeModelBinding → routeResourceBinding}/defineRoute.ts +0 -0
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
-
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
-
|
|
4
|
-
export interface ProductResource {
|
|
5
|
-
id: number
|
|
6
|
-
title: string
|
|
7
|
-
description: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ProductPaginationResource {
|
|
11
|
-
products: ProductResource[]
|
|
12
|
-
total: number
|
|
13
|
-
limit: number
|
|
14
|
-
skip: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
-
public getData() {
|
|
19
|
-
return this.data
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getTotal(): number {
|
|
23
|
-
return this.body.total
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public dataHandler(data) {
|
|
27
|
-
return data.products
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
-
method() {
|
|
33
|
-
return 'GET'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
url() {
|
|
37
|
-
return 'https://dummyjson.com/http/500'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
-
return this.withParams({
|
|
42
|
-
skip: (page - 1) * size,
|
|
43
|
-
limit: size,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public getCorsWithCredentials(): boolean {
|
|
48
|
-
return false
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected getResponse() {
|
|
52
|
-
return new GetProductsRequestResponse
|
|
53
|
-
}
|
|
1
|
+
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
+
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
+
|
|
4
|
+
export interface ProductResource {
|
|
5
|
+
id: number
|
|
6
|
+
title: string
|
|
7
|
+
description: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ProductPaginationResource {
|
|
11
|
+
products: ProductResource[]
|
|
12
|
+
total: number
|
|
13
|
+
limit: number
|
|
14
|
+
skip: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
+
public getData() {
|
|
19
|
+
return this.data
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getTotal(): number {
|
|
23
|
+
return this.body.total
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public dataHandler(data) {
|
|
27
|
+
return data.products
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
+
method() {
|
|
33
|
+
return 'GET'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
url() {
|
|
37
|
+
return 'https://dummyjson.com/http/500'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
+
return this.withParams({
|
|
42
|
+
skip: (page - 1) * size,
|
|
43
|
+
limit: size,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public getCorsWithCredentials(): boolean {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected getResponse() {
|
|
52
|
+
return new GetProductsRequestResponse
|
|
53
|
+
}
|
|
54
54
|
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
-
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
-
|
|
4
|
-
export interface ProductResource {
|
|
5
|
-
id: number
|
|
6
|
-
title: string
|
|
7
|
-
description: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ProductPaginationResource {
|
|
11
|
-
products: ProductResource[]
|
|
12
|
-
total: number
|
|
13
|
-
limit: number
|
|
14
|
-
skip: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
-
public getData() {
|
|
19
|
-
return this.data
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getTotal(): number {
|
|
23
|
-
return this.body.total
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public dataHandler(data) {
|
|
27
|
-
return data.products
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
-
method() {
|
|
33
|
-
return 'GET'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
url() {
|
|
37
|
-
return 'https://dummyjson.com/products'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
-
return this.withParams({
|
|
42
|
-
skip: (page - 1) * size,
|
|
43
|
-
limit: size,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected getResponse() {
|
|
48
|
-
return new GetProductsRequestResponse
|
|
49
|
-
}
|
|
1
|
+
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
+
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
+
|
|
4
|
+
export interface ProductResource {
|
|
5
|
+
id: number
|
|
6
|
+
title: string
|
|
7
|
+
description: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ProductPaginationResource {
|
|
11
|
+
products: ProductResource[]
|
|
12
|
+
total: number
|
|
13
|
+
limit: number
|
|
14
|
+
skip: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
+
public getData() {
|
|
19
|
+
return this.data
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getTotal(): number {
|
|
23
|
+
return this.body.total
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public dataHandler(data) {
|
|
27
|
+
return data.products
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
+
method() {
|
|
33
|
+
return 'GET'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
url() {
|
|
37
|
+
return 'https://dummyjson.com/products'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
+
return this.withParams({
|
|
42
|
+
skip: (page - 1) * size,
|
|
43
|
+
limit: size,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected getResponse() {
|
|
48
|
+
return new GetProductsRequestResponse
|
|
49
|
+
}
|
|
50
50
|
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container" @scroll="scroll">
|
|
3
|
-
<div class="item" v-for="row in paginator.getPageData()">
|
|
4
|
-
{{ row }}
|
|
5
|
-
<br>
|
|
6
|
-
</div>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script setup lang="ts">
|
|
11
|
-
import {GetProductsRequest} from "./GetProductsRequest";
|
|
12
|
-
import {InfiniteScroller, RequestDriver, VuePaginationDriverFactory, Paginator} from '@hank-it/ui/service/pagination'
|
|
13
|
-
import {VueLoaderDriverFactory, BaseRequest, FetchDriver} from '@hank-it/ui/service/requests'
|
|
14
|
-
import {isAtBottom} from '@hank-it/ui/service/helpers'
|
|
15
|
-
import { debounce } from 'lodash'
|
|
16
|
-
|
|
17
|
-
function scroll(event) {
|
|
18
|
-
console.log("scroll")
|
|
19
|
-
|
|
20
|
-
if (isAtBottom(event.target.scrollHeight, event.target.scrollTop, event.target.clientHeight)) {
|
|
21
|
-
loadNextDebounced()
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const loadNextDebounced = debounce(event => {
|
|
26
|
-
paginator.toNextPage()
|
|
27
|
-
}, 100)
|
|
28
|
-
|
|
29
|
-
/* Booting */
|
|
30
|
-
BaseRequest.setRequestDriver(new FetchDriver)
|
|
31
|
-
BaseRequest.setLoaderStateFactory(new VueLoaderDriverFactory)
|
|
32
|
-
Paginator.setViewDriverFactory(new VuePaginationDriverFactory())
|
|
33
|
-
|
|
34
|
-
/* component */
|
|
35
|
-
const getProductsRequest = new GetProductsRequest
|
|
36
|
-
|
|
37
|
-
const paginator = new InfiniteScroller(new RequestDriver(getProductsRequest))
|
|
38
|
-
|
|
39
|
-
paginator.init(1, 10)
|
|
40
|
-
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<style scoped>
|
|
44
|
-
.container {
|
|
45
|
-
overflow: auto;
|
|
46
|
-
border-style: solid;
|
|
47
|
-
border-color: red;
|
|
48
|
-
height: 400px;
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-direction: column;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.item {
|
|
54
|
-
margin-top: 10px;
|
|
55
|
-
margin-bottom: 10px;
|
|
56
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container" @scroll="scroll">
|
|
3
|
+
<div class="item" v-for="row in paginator.getPageData()">
|
|
4
|
+
{{ row }}
|
|
5
|
+
<br>
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import {GetProductsRequest} from "./GetProductsRequest";
|
|
12
|
+
import {InfiniteScroller, RequestDriver, VuePaginationDriverFactory, Paginator} from '@hank-it/ui/service/pagination'
|
|
13
|
+
import {VueLoaderDriverFactory, BaseRequest, FetchDriver} from '@hank-it/ui/service/requests'
|
|
14
|
+
import {isAtBottom} from '@hank-it/ui/service/helpers'
|
|
15
|
+
import { debounce } from 'lodash'
|
|
16
|
+
|
|
17
|
+
function scroll(event) {
|
|
18
|
+
console.log("scroll")
|
|
19
|
+
|
|
20
|
+
if (isAtBottom(event.target.scrollHeight, event.target.scrollTop, event.target.clientHeight)) {
|
|
21
|
+
loadNextDebounced()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const loadNextDebounced = debounce(event => {
|
|
26
|
+
paginator.toNextPage()
|
|
27
|
+
}, 100)
|
|
28
|
+
|
|
29
|
+
/* Booting */
|
|
30
|
+
BaseRequest.setRequestDriver(new FetchDriver)
|
|
31
|
+
BaseRequest.setLoaderStateFactory(new VueLoaderDriverFactory)
|
|
32
|
+
Paginator.setViewDriverFactory(new VuePaginationDriverFactory())
|
|
33
|
+
|
|
34
|
+
/* component */
|
|
35
|
+
const getProductsRequest = new GetProductsRequest
|
|
36
|
+
|
|
37
|
+
const paginator = new InfiniteScroller(new RequestDriver(getProductsRequest))
|
|
38
|
+
|
|
39
|
+
paginator.init(1, 10)
|
|
40
|
+
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style scoped>
|
|
44
|
+
.container {
|
|
45
|
+
overflow: auto;
|
|
46
|
+
border-style: solid;
|
|
47
|
+
border-color: red;
|
|
48
|
+
height: 400px;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.item {
|
|
54
|
+
margin-top: 10px;
|
|
55
|
+
margin-bottom: 10px;
|
|
56
|
+
}
|
|
57
57
|
</style>
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
-
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
-
|
|
4
|
-
export interface ProductResource {
|
|
5
|
-
id: number
|
|
6
|
-
title: string
|
|
7
|
-
description: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ProductPaginationResource {
|
|
11
|
-
products: ProductResource[]
|
|
12
|
-
total: number
|
|
13
|
-
limit: number
|
|
14
|
-
skip: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
-
public getData() {
|
|
19
|
-
return this.data
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getTotal(): number {
|
|
23
|
-
return this.body.total
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public dataHandler(data) {
|
|
27
|
-
return data.products
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
-
method() {
|
|
33
|
-
return 'GET'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
url() {
|
|
37
|
-
return 'https://dummyjson.com/products'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
-
return this.withParams({
|
|
42
|
-
skip: (page - 1) * size,
|
|
43
|
-
limit: size,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected getResponse() {
|
|
48
|
-
return new GetProductsRequestResponse
|
|
49
|
-
}
|
|
1
|
+
import {BaseRequest, type Paginatable, JsonResponse } from '@hank-it/ui/service/requests'
|
|
2
|
+
import type {PaginationResponseContract} from '@hank-it/ui/service/pagination'
|
|
3
|
+
|
|
4
|
+
export interface ProductResource {
|
|
5
|
+
id: number
|
|
6
|
+
title: string
|
|
7
|
+
description: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ProductPaginationResource {
|
|
11
|
+
products: ProductResource[]
|
|
12
|
+
total: number
|
|
13
|
+
limit: number
|
|
14
|
+
skip: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class GetProductsRequestResponse extends JsonResponse implements PaginationResponseContract {
|
|
18
|
+
public getData() {
|
|
19
|
+
return this.data
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getTotal(): number {
|
|
23
|
+
return this.body.total
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public dataHandler(data) {
|
|
27
|
+
return data.products
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class GetProductsRequest extends BaseRequest implements Paginatable {
|
|
32
|
+
method() {
|
|
33
|
+
return 'GET'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
url() {
|
|
37
|
+
return 'https://dummyjson.com/products'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setPaginationParams(page: number, size: number): BaseRequest {
|
|
41
|
+
return this.withParams({
|
|
42
|
+
skip: (page - 1) * size,
|
|
43
|
+
limit: size,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected getResponse() {
|
|
48
|
+
return new GetProductsRequestResponse
|
|
49
|
+
}
|
|
50
50
|
}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<table>
|
|
3
|
-
<tr>
|
|
4
|
-
<th>ID</th>
|
|
5
|
-
<th>Title</th>
|
|
6
|
-
<th>Description</th>
|
|
7
|
-
</tr>
|
|
8
|
-
<tr v-for="row in paginator.getPageData()">
|
|
9
|
-
<td>{{ row.id }}</td>
|
|
10
|
-
<td>{{ row.title }}</td>
|
|
11
|
-
<td>{{ row.description }}</td>
|
|
12
|
-
</tr>
|
|
13
|
-
</table>
|
|
14
|
-
|
|
15
|
-
Current page: {{ paginator.getCurrentPage() }}
|
|
16
|
-
<br>
|
|
17
|
-
Pages: {{ paginator.getPages() }}
|
|
18
|
-
<br>
|
|
19
|
-
Page Size: <input v-model="pageSize" />
|
|
20
|
-
<br>
|
|
21
|
-
Back Page <button @click="paginator.toPreviousPage()">Back</button>
|
|
22
|
-
<br>
|
|
23
|
-
Next Page <button @click="paginator.toNextPage()">Next</button>
|
|
24
|
-
<br>
|
|
25
|
-
Showing {{ paginator.getFromItemNumber() }} to {{ paginator.getToItemNumber() }} of {{ paginator.getTotal() }} items.
|
|
26
|
-
|
|
27
|
-
{{ displayablePages }}
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script setup lang="ts">
|
|
31
|
-
import {GetProductsRequest} from "./GetProductsRequest";
|
|
32
|
-
import {Paginator, RequestDriver, VuePaginationDriverFactory} from '@hank-it/ui/service/pagination'
|
|
33
|
-
import {VueLoaderDriverFactory, BaseRequest, FetchDriver} from '@hank-it/ui/service/requests'
|
|
34
|
-
import {computed} from 'vue'
|
|
35
|
-
import {getDisplayablePages} from '@hank-it/ui/service/helpers'
|
|
36
|
-
|
|
37
|
-
/* Booting */
|
|
38
|
-
BaseRequest.setRequestDriver(new FetchDriver)
|
|
39
|
-
BaseRequest.setLoaderStateFactory(new VueLoaderDriverFactory)
|
|
40
|
-
Paginator.setViewDriverFactory(new VuePaginationDriverFactory())
|
|
41
|
-
|
|
42
|
-
/* component */
|
|
43
|
-
const getProductsRequest = new GetProductsRequest
|
|
44
|
-
|
|
45
|
-
const paginator = new Paginator(new RequestDriver(getProductsRequest))
|
|
46
|
-
|
|
47
|
-
paginator.init(1, 10)
|
|
48
|
-
|
|
49
|
-
const pageSize = computed({
|
|
50
|
-
set(value) {
|
|
51
|
-
paginator.setPageSize(value)
|
|
52
|
-
},
|
|
53
|
-
get() {
|
|
54
|
-
return paginator.getPageSize()
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const displayablePages = computed(() => {
|
|
59
|
-
console.log(paginator.getPages())
|
|
60
|
-
|
|
61
|
-
return getDisplayablePages(paginator.getPages().length, paginator.getCurrentPage())
|
|
62
|
-
})
|
|
1
|
+
<template>
|
|
2
|
+
<table>
|
|
3
|
+
<tr>
|
|
4
|
+
<th>ID</th>
|
|
5
|
+
<th>Title</th>
|
|
6
|
+
<th>Description</th>
|
|
7
|
+
</tr>
|
|
8
|
+
<tr v-for="row in paginator.getPageData()">
|
|
9
|
+
<td>{{ row.id }}</td>
|
|
10
|
+
<td>{{ row.title }}</td>
|
|
11
|
+
<td>{{ row.description }}</td>
|
|
12
|
+
</tr>
|
|
13
|
+
</table>
|
|
14
|
+
|
|
15
|
+
Current page: {{ paginator.getCurrentPage() }}
|
|
16
|
+
<br>
|
|
17
|
+
Pages: {{ paginator.getPages() }}
|
|
18
|
+
<br>
|
|
19
|
+
Page Size: <input v-model="pageSize" />
|
|
20
|
+
<br>
|
|
21
|
+
Back Page <button @click="paginator.toPreviousPage()">Back</button>
|
|
22
|
+
<br>
|
|
23
|
+
Next Page <button @click="paginator.toNextPage()">Next</button>
|
|
24
|
+
<br>
|
|
25
|
+
Showing {{ paginator.getFromItemNumber() }} to {{ paginator.getToItemNumber() }} of {{ paginator.getTotal() }} items.
|
|
26
|
+
|
|
27
|
+
{{ displayablePages }}
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import {GetProductsRequest} from "./GetProductsRequest";
|
|
32
|
+
import {Paginator, RequestDriver, VuePaginationDriverFactory} from '@hank-it/ui/service/pagination'
|
|
33
|
+
import {VueLoaderDriverFactory, BaseRequest, FetchDriver} from '@hank-it/ui/service/requests'
|
|
34
|
+
import {computed} from 'vue'
|
|
35
|
+
import {getDisplayablePages} from '@hank-it/ui/service/helpers'
|
|
36
|
+
|
|
37
|
+
/* Booting */
|
|
38
|
+
BaseRequest.setRequestDriver(new FetchDriver)
|
|
39
|
+
BaseRequest.setLoaderStateFactory(new VueLoaderDriverFactory)
|
|
40
|
+
Paginator.setViewDriverFactory(new VuePaginationDriverFactory())
|
|
41
|
+
|
|
42
|
+
/* component */
|
|
43
|
+
const getProductsRequest = new GetProductsRequest
|
|
44
|
+
|
|
45
|
+
const paginator = new Paginator(new RequestDriver(getProductsRequest))
|
|
46
|
+
|
|
47
|
+
paginator.init(1, 10)
|
|
48
|
+
|
|
49
|
+
const pageSize = computed({
|
|
50
|
+
set(value) {
|
|
51
|
+
paginator.setPageSize(value)
|
|
52
|
+
},
|
|
53
|
+
get() {
|
|
54
|
+
return paginator.getPageSize()
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const displayablePages = computed(() => {
|
|
59
|
+
console.log(paginator.getPages())
|
|
60
|
+
|
|
61
|
+
return getDisplayablePages(paginator.getPages().length, paginator.getCurrentPage())
|
|
62
|
+
})
|
|
63
63
|
</script>
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DemoPage :components="components" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import GetRequestWithDynamicParams from './components/getRequestWithDynamicParams/GetRequestWithDynamicParams.vue'
|
|
7
|
-
import AbortableRequest from './components/abortableRequest/AbortableRequest.vue'
|
|
8
|
-
import ServerErrorRequest from './components/serverErrorRequest/ServerErrorRequest.vue'
|
|
9
|
-
import FileDownloadRequest from './components/fileDownloadRequest/FileDownloadRequest.vue'
|
|
10
|
-
import DemoPage from '../layout/DemoPage.vue'
|
|
11
|
-
|
|
12
|
-
const components = {
|
|
13
|
-
'get-request-with-dynamic-params': {
|
|
14
|
-
name: 'Get request with dynamic params',
|
|
15
|
-
component: GetRequestWithDynamicParams,
|
|
16
|
-
route: { name: 'requests', params: { component: 'get-request-with-dynamic-params' } },
|
|
17
|
-
},
|
|
18
|
-
'abortable-request': {
|
|
19
|
-
name: 'Abortable request',
|
|
20
|
-
component: AbortableRequest,
|
|
21
|
-
route: { name: 'requests', params: { component: 'abortable-request' } },
|
|
22
|
-
},
|
|
23
|
-
'server-error-request': {
|
|
24
|
-
name: 'Server error request',
|
|
25
|
-
component: ServerErrorRequest,
|
|
26
|
-
route: { name: 'requests', params: { component: 'server-error-request' } },
|
|
27
|
-
},
|
|
28
|
-
'file-download-request': {
|
|
29
|
-
name: 'File download request',
|
|
30
|
-
component: FileDownloadRequest,
|
|
31
|
-
route: { name: 'requests', params: { component: 'file-download-request' } },
|
|
32
|
-
},
|
|
33
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<DemoPage :components="components" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import GetRequestWithDynamicParams from './components/getRequestWithDynamicParams/GetRequestWithDynamicParams.vue'
|
|
7
|
+
import AbortableRequest from './components/abortableRequest/AbortableRequest.vue'
|
|
8
|
+
import ServerErrorRequest from './components/serverErrorRequest/ServerErrorRequest.vue'
|
|
9
|
+
import FileDownloadRequest from './components/fileDownloadRequest/FileDownloadRequest.vue'
|
|
10
|
+
import DemoPage from '../layout/DemoPage.vue'
|
|
11
|
+
|
|
12
|
+
const components = {
|
|
13
|
+
'get-request-with-dynamic-params': {
|
|
14
|
+
name: 'Get request with dynamic params',
|
|
15
|
+
component: GetRequestWithDynamicParams,
|
|
16
|
+
route: { name: 'requests', params: { component: 'get-request-with-dynamic-params' } },
|
|
17
|
+
},
|
|
18
|
+
'abortable-request': {
|
|
19
|
+
name: 'Abortable request',
|
|
20
|
+
component: AbortableRequest,
|
|
21
|
+
route: { name: 'requests', params: { component: 'abortable-request' } },
|
|
22
|
+
},
|
|
23
|
+
'server-error-request': {
|
|
24
|
+
name: 'Server error request',
|
|
25
|
+
component: ServerErrorRequest,
|
|
26
|
+
route: { name: 'requests', params: { component: 'server-error-request' } },
|
|
27
|
+
},
|
|
28
|
+
'file-download-request': {
|
|
29
|
+
name: 'File download request',
|
|
30
|
+
component: FileDownloadRequest,
|
|
31
|
+
route: { name: 'requests', params: { component: 'file-download-request' } },
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
34
|
</script>
|