Skip to content

Commit

Permalink
fix(pagination): after rebase pagination event
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 authored and dpellier committed Jul 29, 2024
1 parent 34ad35b commit c13fec8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OdsSelectEventChangeDetail } from '../../../../select/src';
import type { OdsSelectChangeEventDetail } from '../../../../select/src';
import type { OdsPaginationChangedEventDetail, OdsPaginationItemPerPageChangedEventDetail } from '../../interfaces/events';
import type { OdsPaginationPageList } from '../../interfaces/pagination-page-list';
import type { EventEmitter, Fragment, FunctionalComponent } from '@stencil/core';
Expand Down Expand Up @@ -36,11 +36,11 @@ export class OdsPagination {
@Prop({ reflect: true }) public totalItems?: number;
@Prop({ reflect: true }) public totalPages: number = 1;

@Event() odsPaginationChanged!: EventEmitter<OdsPaginationChangedEventDetail>;
@Event() odsPaginationItemPerPageChanged!: EventEmitter<OdsPaginationItemPerPageChangedEventDetail>;
@Event() odsChanged!: EventEmitter<OdsPaginationChangedEventDetail>;
@Event() odsItemPerPageChanged!: EventEmitter<OdsPaginationItemPerPageChangedEventDetail>;

@Listen('odsChange')
odsValueChangeHandler(event: CustomEvent<OdsSelectEventChangeDetail>): void {
odsValueChangeHandler(event: CustomEvent<OdsSelectChangeEventDetail>): void {
event.preventDefault();
event.stopPropagation();

Expand Down Expand Up @@ -75,7 +75,7 @@ export class OdsPagination {
async onItemPerPageChange(): Promise<void> {
await this.updatePagination();

this.odsPaginationItemPerPageChanged.emit({
this.odsItemPerPageChanged.emit({
current: this.itemPerPage,
currentPage: this.current,
totalPages: this.actualTotalPages,
Expand Down Expand Up @@ -118,7 +118,7 @@ export class OdsPagination {
}

private emitChange(current: number, oldCurrent?: number): void {
this.odsPaginationChanged.emit({
this.odsChanged.emit({
current: current,
itemPerPage: this.itemPerPage,
oldCurrent: oldCurrent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ods-pagination navigation', () => {
it('should emit event when current page changes', async() => {
await setup('<ods-pagination default-current-page="2" total-pages="5"></ods-pagination>');
const buttonList = await page.findAll('ods-pagination >>> li >>> ods-button');
const odsPaginationChanged = await el.spyOnEvent('odsPaginationChanged');
const odsChanged = await el.spyOnEvent('odsChanged');

// There is the "previous" arrow that also counts as a button
await buttonList[4].click();
Expand All @@ -36,8 +36,8 @@ describe('ods-pagination navigation', () => {
oldCurrent: 2,
};

expect(odsPaginationChanged).toHaveReceivedEventDetail(expected);
expect(odsPaginationChanged).toHaveReceivedEventTimes(1);
expect(odsChanged).toHaveReceivedEventDetail(expected);
expect(odsChanged).toHaveReceivedEventTimes(1);
});

it('should not allow to go to next page if current page is the last one', async() => {
Expand All @@ -57,7 +57,7 @@ describe('ods-pagination navigation', () => {
it('should change items per page and emit event', async() => {
await setup('<ods-pagination default-current-page="2" total-items="60"></ods-pagination>');
const perPageSelectElement = await page.find('ods-pagination >>> ods-select');
const odsPaginationItemPerPageChanged = await el.spyOnEvent('odsPaginationItemPerPageChanged');
const odsItemPerPageChanged = await el.spyOnEvent('odsItemPerPageChanged');
perPageSelectElement.setAttribute('value', '50');
await page.waitForChanges();

Expand All @@ -67,7 +67,7 @@ describe('ods-pagination navigation', () => {
totalPages: 2,
};

expect(odsPaginationItemPerPageChanged).toHaveReceivedEventDetail(expected);
expect(odsPaginationItemPerPageChanged).toHaveReceivedEventTimes(1);
expect(odsItemPerPageChanged).toHaveReceivedEventDetail(expected);
expect(odsItemPerPageChanged).toHaveReceivedEventTimes(1);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AttachInternals, Component, Event, type EventEmitter, type FunctionalComponent, Host, Method, Prop, Watch, h } from '@stencil/core';
import { PhoneNumberUtil } from 'google-libphonenumber';
import { type OdsInput, type OdsInputChangeEvent } from '../../../../input/src';
import { type OdsSelectCustomRendererData, type OdsSelectEventChange } from '../../../../select/src';
import { type OdsSelectChangeEvent, type OdsSelectCustomRendererData } from '../../../../select/src';
import { type OdsPhoneNumberCountryIsoCode } from '../../constants/phone-number-country-iso-code';
import { type OdsPhoneNumberCountryPreset } from '../../constants/phone-number-country-preset';
import { type OdsPhoneNumberLocale } from '../../constants/phone-number-locale';
Expand Down Expand Up @@ -124,7 +124,7 @@ export class OdsPhoneNumber {
});
}

private onSelectChange(event: OdsSelectEventChange): void {
private onSelectChange(event: OdsSelectChangeEvent): void {
this.isoCode = event.detail.value as OdsPhoneNumberCountryIsoCode;
}

Expand Down Expand Up @@ -153,7 +153,7 @@ export class OdsPhoneNumber {
isDisabled={ this.isDisabled }
isReadonly={ this.isReadonly }
name="iso-code"
onOdsChange={ (e: OdsSelectEventChange) => this.onSelectChange(e) }
onOdsChange={ (e: OdsSelectChangeEvent) => this.onSelectChange(e) }
part="select"
value={ this.isoCode }>
{
Expand Down
8 changes: 4 additions & 4 deletions packages/ods/src/components/tag/src/controller/ods-tag.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { type OdsTagEventRemoveDetail } from '../interfaces/events';
import { type OdsTagRemoveEventDetail } from '../interfaces/events';

function emit(tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagEventRemoveDetail) => CustomEvent }): void {
function emit(tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagRemoveEventDetail) => CustomEvent }): void {
if (!isDisabled) {
eventEmitter.emit({
id: tag.id,
});
}
}

function handleClick(tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagEventRemoveDetail) => CustomEvent }): void {
function handleClick(tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagRemoveEventDetail) => CustomEvent }): void {
emit(tag, isDisabled, eventEmitter);
}

Expand All @@ -19,7 +19,7 @@ function handleKeyDown(event: KeyboardEvent): void {
}
}

function handleKeyUp(event: KeyboardEvent, tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagEventRemoveDetail) => CustomEvent }): void {
function handleKeyUp(event: KeyboardEvent, tag: HTMLElement, isDisabled: boolean, eventEmitter: { emit: (data: OdsTagRemoveEventDetail) => CustomEvent }): void {
switch (event.key) {
case ' ':
case 'Enter':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class OdsTimepicker {
has-error={ this.hasError }
is-disabled={ this.isDisabled }
is-readonly={ this.isReadonly }
onOdsChange={ (event: OdsSelectEventChange) => this.onOdsChange(event, true) }
onOdsChange={ (event: OdsSelectChangeEvent) => this.onOdsChange(event, true) }
onOdsClear={ (event: CustomEvent<void>) => event.stopPropagation() }
onOdsReset={ (event: CustomEvent<void>) => event.stopPropagation() }
name={ this.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ We went through each component to update:

**Pagination**

* Add `odsPaginationItemPerPageChanged` when the item per page select change
* Add `odsItemPerPageChanged` when the item per page select change

### Bug fixes:

Expand Down Expand Up @@ -296,7 +296,7 @@ We went through each component to update:

\*\* Pagination \*\*

* Add `itemPerPage` in payload event `odsPaginationChanged`
* Add `itemPerPage` in payload event `odsChanged`
* Watch `totalPages` & update it

\*\* PhoneNumber \*\*
Expand Down

0 comments on commit c13fec8

Please sign in to comment.