Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(components/forms): change SkyCheckboxChange type to an interface #597

Merged
merged 3 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 });
}
}