Skip to content

Commit

Permalink
feat(components/forms): change SkyCheckboxChange type to an interfa…
Browse files Browse the repository at this point in the history
…ce (#597)

BREAKING CHANGE: This change updates the `SkyCheckboxChange` type to be an interface instead of a
class. To address this, remove any instances of instantiating the `SkyCheckboxChange` class and
instead create an object that uses the interface type.
  • Loading branch information
Blackbaud-ErikaMcVey authored Oct 4, 2022
1 parent 097d598 commit 2c3c1e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
SkyDataViewConfig,
SkyDataViewState,
} from '@skyux/data-manager';
import { SkyCheckboxChange } from '@skyux/forms';
import { SkyModalService } from '@skyux/modals';

import { Subject } from 'rxjs';
Expand Down Expand Up @@ -328,12 +327,11 @@ describe('SkyDataManagerToolbarComponent', () => {
it('should update the data state when the only show selected checkbox state changes', () => {
dataManagerToolbarFixture.detectChanges();

const event = { checked: true } as SkyCheckboxChange;
const updatedDataState = dataManagerToolbarComponent.dataState;
updatedDataState.onlyShowSelected = true;
spyOn(dataManagerService, 'updateDataState');

dataManagerToolbarComponent.onOnlyShowSelected(event);
dataManagerToolbarComponent.onOnlyShowSelected({ checked: true });

expect(dataManagerToolbarComponent.dataState.onlyShowSelected).toBeTrue();
expect(dataManagerService.updateDataState).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SkyCheckboxComponent } from './checkbox.component';
/**
* Fires when users select or deselect the checkbox.
*/
export class SkyCheckboxChange {
public source: SkyCheckboxComponent | undefined;
public checked: boolean | undefined;
export interface SkyCheckboxChange {
source?: SkyCheckboxComponent;
checked?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,8 @@ export class SkyCheckboxComponent implements ControlValueAccessor, OnInit {
#controlValueAccessorChangeFn: (value: any) => void = (value) => {};

#emitChangeEvent(): void {
const event = new SkyCheckboxChange();
event.source = this;
event.checked = this.#_checked;

this.#controlValueAccessorChangeFn(this.#_checked);
this.change.emit(event);
this.#controlValueAccessorChangeFn(this.checked);
this.change.emit({ source: this, checked: this.checked });
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, Inject, ViewChild } from '@angular/core';
import { SkyCheckboxChange } from '@skyux/forms';

import { SkyListViewChecklistComponent } from '../list-view-checklist.component';

Expand Down Expand Up @@ -32,8 +31,6 @@ export class ListViewChecklistToolbarTestComponent {
}

public changeVisibleItems(checked: boolean): void {
const checkbox = new SkyCheckboxChange();
checkbox.checked = checked;
this.checklist.changeVisibleItems(checkbox);
this.checklist.changeVisibleItems({ checked });
}
}

0 comments on commit 2c3c1e9

Please sign in to comment.