Skip to content

Commit 3f9468b

Browse files
authored
Merge pull request #3185 from Akshat55/pagination-control
feat: allow more fine grained control over next/prev buttons
2 parents 7ff54e7 + b2ecdeb commit 3f9468b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/pagination/pagination.component.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ export interface PaginationTranslations {
161161
iconOnly="true"
162162
class="cds--pagination__button cds--pagination__button--backward"
163163
[ngClass]="{
164-
'cds--pagination__button--no-index': currentPage <= 1 || disabled
164+
'cds--pagination__button--no-index': currentPage <= 1 || backwardDisabled
165165
}"
166166
tabindex="0"
167167
[attr.aria-label]="backwardText.subject | async"
168168
(click)="selectPage.emit(previousPage)"
169-
[disabled]="(currentPage <= 1 || disabled ? true : null)">
169+
[disabled]="(currentPage <= 1 || backwardDisabled ? true : null)">
170170
<svg cdsIcon="caret--left" size="16" class="cds--btn__icon"></svg>
171171
</button>
172172
@@ -177,12 +177,12 @@ export interface PaginationTranslations {
177177
cds--pagination__button
178178
cds--pagination__button--forward"
179179
[ngClass]="{
180-
'cds--pagination__button--no-index': currentPage >= lastPage || disabled
180+
'cds--pagination__button--no-index': currentPage >= lastPage || forwardDisabled
181181
}"
182182
tabindex="0"
183183
[attr.aria-label]="forwardText.subject | async"
184184
(click)="selectPage.emit(nextPage)"
185-
[disabled]="(currentPage >= lastPage || disabled ? true : null)">
185+
[disabled]="(currentPage >= lastPage || forwardDisabled ? true : null)">
186186
<svg cdsIcon="caret--right" size="16" class="cds--btn__icon"></svg>
187187
</button>
188188
</div>
@@ -204,7 +204,10 @@ export class Pagination {
204204
/**
205205
* Set to `true` to disable the backward/forward buttons.
206206
*/
207-
@Input() disabled = false;
207+
@Input() set disabled(value: boolean) {
208+
this.backwardDisabled = value;
209+
this.forwardDisabled = value;
210+
}
208211
/**
209212
* Set to `true` to disable the select box that changes the page.
210213
*/
@@ -219,6 +222,9 @@ export class Pagination {
219222
@Input() pagesUnknown = false;
220223
@Input() pageSelectThreshold = 1000;
221224

225+
@Input() backwardDisabled = false;
226+
@Input() forwardDisabled = false;
227+
222228
/**
223229
* Expects an object that contains some or all of:
224230
* ```

src/pagination/pagination.stories.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const Template = (args) => ({
3232
[pagesUnknown]="pagesUnknown"
3333
[totalDataLength]="totalDataLength"
3434
[showPageInput]="showPageInput"
35+
[backwardDisabled]="backwardDisabled"
36+
[forwardDisabled]="forwardDisabled"
3537
[skeleton]="skeleton">
3638
</app-pagination>
3739
`
@@ -40,8 +42,10 @@ export const Basic = Template.bind({});
4042
Basic.args = {
4143
disabled: false,
4244
pageInputDisabled: false,
43-
pageUnknown: false,
45+
pagesUnknown: false,
4446
totalDataLength: 105,
4547
showPageInput: true,
46-
skeleton: false
48+
skeleton: false,
49+
backwardDisabled: false,
50+
forwardDisabled: false
4751
};

src/pagination/stories/pagination.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { PaginationModel } from "..";
1616
[pagesUnknown]="pagesUnknown"
1717
[showPageInput]="showPageInput"
1818
[skeleton]="skeleton"
19+
[backwardDisabled]="backwardDisabled"
20+
[forwardDisabled]="forwardDisabled"
1921
(selectPage)="selectPage($event)">
2022
</cds-pagination>
2123
`
@@ -27,6 +29,8 @@ export class PaginationStory implements OnInit {
2729
@Input() pageInputDisabled = false;
2830
@Input() pagesUnknown = false;
2931
@Input() showPageInput = true;
32+
@Input() backwardDisabled = false;
33+
@Input() forwardDisabled = false;
3034

3135
@Input() get totalDataLength() {
3236
return this.model.totalDataLength;

0 commit comments

Comments
 (0)