-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
313 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 8 additions & 10 deletions
18
projects/data-grid/src/lib/components/grid-header/grid-header.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
projects/data-grid/src/lib/components/grid-row/grid-row.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
projects/data-grid/src/lib/components/row-select/row-select.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="data-grid-checkbox-wrapper data-grid-checkbox"> | ||
<ng-container *ngIf="isCheckbox()"> | ||
<input | ||
type="checkbox" | ||
[checked]="isSelected" | ||
(change)="selected.emit()" | ||
[id]="inputId" | ||
class="data-grid-input"/> | ||
<label class="data-grid-label" [for]="inputId"></label> | ||
</ng-container> | ||
|
||
<input | ||
*ngIf="isRadio()" | ||
type="radio" | ||
name="radioSelection" | ||
[id]="inputId" | ||
[checked]="isSelected" | ||
(change)="select()" /> | ||
</div> |
1 change: 1 addition & 0 deletions
1
projects/data-grid/src/lib/components/row-select/row-select.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import "../../../styles/checkbox"; |
69 changes: 69 additions & 0 deletions
69
projects/data-grid/src/lib/components/row-select/row-select.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { GridTranslateService } from '../../services/grid-translate.service'; | ||
import { RowSelectComponent } from './row-select.component'; | ||
import { SelectionType } from '../../config'; | ||
|
||
describe('RowSelectComponent', () => { | ||
let component: RowSelectComponent; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
RowSelectComponent | ||
], | ||
providers: [ | ||
GridTranslateService | ||
], | ||
schemas: [ | ||
NO_ERRORS_SCHEMA | ||
] | ||
}).compileComponents(); | ||
|
||
component = TestBed.createComponent(RowSelectComponent).componentInstance; | ||
spyOn(component.selected, 'emit'); | ||
}); | ||
|
||
it('should create the component', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should return true for checkbox selection', () => { | ||
// given | ||
component.type = SelectionType.Checkbox; | ||
|
||
// then | ||
expect(component.isCheckbox()).toBeTruthy(); | ||
}); | ||
|
||
it('should return true for radio selection', () => { | ||
// given | ||
component.type = SelectionType.Radio; | ||
|
||
// then | ||
expect(component.isRadio()).toBeTruthy(); | ||
}); | ||
|
||
it('should dispatch select action if the component is not selected', () => { | ||
// given | ||
component.isSelected = false; | ||
|
||
// when | ||
component.select(); | ||
|
||
// then | ||
expect(component.selected.emit).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not dispatch select action if the component is already selected', () => { | ||
// given | ||
component.isSelected = true; | ||
|
||
// when | ||
component.select(); | ||
|
||
// then | ||
expect(component.selected.emit).not.toHaveBeenCalled(); | ||
}); | ||
|
||
}); |
35 changes: 35 additions & 0 deletions
35
projects/data-grid/src/lib/components/row-select/row-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { SelectionType } from '../../config'; | ||
import { isCheckboxSelection, isRadioSelection } from '../../util/selection'; | ||
|
||
@Component({ | ||
selector: 'ngrx-row-select', | ||
templateUrl: 'row-select.component.html', | ||
styleUrls: ['./row-select.component.scss'] | ||
}) | ||
export class RowSelectComponent { | ||
@Input() isSelected = false; | ||
@Input() id: any; | ||
@Input() type: SelectionType; | ||
|
||
@Output() selected = new EventEmitter(); | ||
|
||
get inputId() { | ||
return `${this.id}-${this.type}`; | ||
} | ||
|
||
isCheckbox() { | ||
return isCheckboxSelection(this.type); | ||
} | ||
|
||
isRadio() { | ||
return isRadioSelection(this.type); | ||
} | ||
|
||
select() { | ||
if (!this.isSelected) { | ||
this.selected.emit(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.