File tree Expand file tree Collapse file tree 6 files changed +28
-2
lines changed Expand file tree Collapse file tree 6 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ const mode = {
1717 Button : 'button' ,
1818 Select : 'select' ,
1919 Input : 'input' ,
20+ Arrows : 'arrows' ,
2021 } ,
2122 default : '' ,
2223} ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ angular.module('myModule', ['oui.pagination'])
3434
3535| Attribute | Type | Binding | One-time Binding | Values | Default | Description
3636| ---- | ---- | ---- | ---- | ---- | ---- | ----
37+ | ` mode ` | string | @? | no | n/a | n/a | Set the pagination mode. It can be one these values : ` button ` , ` select ` , ` input ` or ` arrows `
3738| ` current-offset ` | number | < | no | n/a | n/a | offset of the current page first item
3839| ` page-size ` | number | <? | no | n/a | ` 25 ` | number of items per page
3940| ` page-size-max ` | number | <? | no | n/a | n/a | max page size of the page sizes list
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Dropdown from '@ovh-ux/ui-kit.dropdown';
33import Pagination from './js/pagination.component' ;
44import PaginationConfigurationProvider from './js/pagination.provider' ;
55
6+
67const moduleName = 'oui.pagination' ;
78
89angular
@@ -12,4 +13,5 @@ angular
1213 . component ( 'ouiPagination' , Pagination )
1314 . provider ( 'ouiPaginationConfiguration' , PaginationConfigurationProvider ) ;
1415
16+ export { MODES } from './js/pagination.controller' ;
1517export default moduleName ;
Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ import { addDefaultParameter } from '@ovh-ux/ui-kit.core/src/js/component-utils'
22import clamp from 'lodash/clamp' ;
33import range from 'lodash/range' ;
44
5- const MODES = [
5+ export const MODES = [
66 'button' ,
77 'select' ,
88 'input' ,
9+ 'arrows' ,
910] ;
1011
1112const MAX_THRESHOLD_MODE = {
@@ -23,6 +24,10 @@ export default class {
2324 this . config = ouiPaginationConfiguration ;
2425 }
2526
27+ get isArrowsMode ( ) {
28+ return this . mode === 'arrows' ;
29+ }
30+
2631 getCurrentPage ( ) {
2732 return Math . floor ( ( this . currentOffset - 1 ) / this . currentPageSize ) + 1 ;
2833 }
Original file line number Diff line number Diff line change 1- < div class ="oui-pagination-result ">
1+ < div class ="oui-pagination-result "
2+ ng-if ="!$ctrl.isArrowsMode ">
23 < label class ="oui-select oui-select_inline ">
34 < select class ="oui-pagination-result__selector oui-select__input "
45 ng-change ="$ctrl.onPageSizeChange($ctrl.currentPageSize) "
6061
6162 <!-- Input -->
6263 < form class ="oui-pagination-items oui-pagination-items_input "
64+ ng-if ="!$ctrl.isArrowsMode "
6365 ng-switch-default
6466 novalidate >
6567 < span aria-hidden ="true "
Original file line number Diff line number Diff line change @@ -283,6 +283,21 @@ describe('ouiPagination', () => {
283283 expect ( items . hasClass ( 'oui-pagination-items_input' ) ) . toBe ( true ) ;
284284 } ) ;
285285
286+ it ( 'should display items in arrows mode' , ( ) => {
287+ const element = TestUtils . compileTemplate ( `
288+ <oui-pagination
289+ mode="arrows"
290+ current-offset="1"
291+ total-items="100">
292+ </oui-pagination>
293+ ` ) ;
294+
295+ expect ( getPaginationNavPrevious ( element ) ) . toBeDefined ( ) ;
296+ expect ( getPaginationNavNext ( element ) ) . toBeDefined ( ) ;
297+ expect ( getPaginationResult ( element ) ) . toBeFalsy ( ) ;
298+ expect ( getPaginationItems ( element ) ) . toBeFalsy ( ) ;
299+ } ) ;
300+
286301 it ( 'should change the mode automatically based on the pageCount' , ( ) => {
287302 let items ;
288303 const element = TestUtils . compileTemplate ( `
You can’t perform that action at this time.
0 commit comments