Skip to content

Commit

Permalink
Merge branch '8.2.x' into dmdimitrov/issue4158-8.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
DiyanDimitrov authored Apr 15, 2020
2 parents cf12b49 + f79941d commit cd97ca4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
[indeterminate]="item.indeterminate"
[disableTransitions]="true"
(change)="onCheckboxChange($event)">
{{ column.formatter && !item.isSpecial ? column.formatter(item.label) : column.dataType === 'number' ? (item.label | igxdecimal:
column.grid.locale) : column.dataType === 'date' ? (item.label | igxdate: column.grid.locale) : item.label }}
{{ item.label }}
</igx-checkbox>
</igx-list-item>
</div>

<ng-template igxDataLoading>
<ng-template igxDataLoading>
<div class="igx-excel-filter__loading">
<ng-container *ngTemplateOutlet="valuesLoadingTemplate">
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export class IgxExcelStyleSearchFilterPipe implements PipeTransform {

searchText = searchText.toLowerCase();
const result = items.filter((it, i) => (i === 0 && it.isSpecial) ||
(it.value !== null && it.value !== undefined) &&
it.value.toString().toLowerCase().indexOf(searchText) > -1);
(it.label !== null && it.label !== undefined) &&
!it.isBlanks &&
it.label.toString().toLowerCase().indexOf(searchText) > -1);

// If 'result' contains the 'Select All' item and at least one more - we use it, otherwise we use an empty array.
return result.length > 1 ? result : [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { IgxExcelStyleSortingComponent } from './excel-style-sorting.component';
import { takeUntil } from 'rxjs/operators';
import { ISelectionEventArgs, IgxDropDownComponent } from '../../../drop-down';
import { IgxColumnComponent } from '../../column.component';
import { IgxDatePipeComponent, IgxDecimalPipeComponent } from '../../grid.common';

/**
*@hidden
Expand All @@ -48,6 +49,7 @@ export class FilterListItem {
public isSelected: boolean;
public indeterminate: boolean;
public isSpecial = false;
public isBlanks = false;
}

@Directive({
Expand Down Expand Up @@ -486,6 +488,10 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, OnInit, A
private addItems(shouldUpdateSelection: boolean) {
this.selectAllSelected = true;
this.selectAllIndeterminate = false;

const numberPipe = new IgxDecimalPipeComponent(this.column.grid.locale);
const datePipe = new IgxDatePipeComponent(this.column.grid.locale);

this.uniqueValues.forEach(element => {
if (element !== undefined && element !== null && element !== '') {
const filterListItem = new FilterListItem();
Expand All @@ -505,12 +511,29 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, OnInit, A
filterListItem.isSelected = true;
}
if (this.column.dataType === DataType.Date) {
filterListItem.value = new Date(element);
filterListItem.label = new Date(element);
const date = new Date(element);

filterListItem.value = date;

filterListItem.label = this.column.formatter ?
this.column.formatter(date) :
datePipe.transform(date, this.column.grid.locale);

} else if (this.column.dataType === DataType.Number) {
filterListItem.value = element;

filterListItem.label = this.column.formatter ?
this.column.formatter(element) :
numberPipe.transform(element, this.column.grid.locale);

} else {
filterListItem.value = element;
filterListItem.label = element;

filterListItem.label = this.column.formatter ?
this.column.formatter(element) :
element;
}

filterListItem.indeterminate = false;
this.listData.push(filterListItem);
} else {
Expand Down Expand Up @@ -546,6 +569,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, OnInit, A
blanks.label = this.grid.resourceStrings.igx_grid_excel_blanks;
blanks.indeterminate = false;
blanks.isSpecial = true;
blanks.isBlanks = true;
this.listData.unshift(blanks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5801,6 +5801,34 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
expect(pinButton.classList.contains('igx-button--disabled')).toBe(true,
'pinButton in header area should be disabled');
}));

it('Should filter date by input string', fakeAsync(() => {
GridFunctions.clickExcelFilterIcon(fix, 'ReleaseDate');
tick(100);
fix.detectChanges();

const searchComponent = GridFunctions.getExcelStyleSearchComponent(fix);
let listItems = searchComponent.querySelectorAll('igx-list-item');
const inputNativeElement = searchComponent.querySelector('.igx-input-group__input');

const todayDateFull = SampleTestData.today;
const todayDate = todayDateFull.getDate().toString();
const dayOfWeek = todayDateFull.toString().substring(0, 3);

sendInputNativeElement(inputNativeElement, todayDate, fix);
tick(100);
fix.detectChanges();

listItems = searchComponent.querySelectorAll('igx-list-item');
expect(listItems.length).toBe(4, 'incorrect rendered list items count');

sendInputNativeElement(inputNativeElement, dayOfWeek, fix);
tick(100);
fix.detectChanges();

listItems = searchComponent.querySelectorAll('igx-list-item');
expect(listItems.length).toBe(0, 'incorrect rendered list items count');
}));
});

describe(null, () => {
Expand Down

0 comments on commit cd97ca4

Please sign in to comment.