-
Notifications
You must be signed in to change notification settings - Fork 1
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
Issue #1 Fix: Case Insensitivity #3
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
} from './mat-table-filter-triggerer'; | ||
import {MatTableDefaultFilterSelection} from './models'; | ||
import {MatTableHeaderType} from './models/header-type'; | ||
import {CaseSensitivityType} from './models/case-sensivity'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
|
@@ -27,6 +28,7 @@ import {MatTableHeaderType} from './models/header-type'; | |
export class MatTableFilterHeader implements AfterViewInit { | ||
@Input({required: false}) matTableFilterHeaderType: MatTableHeaderType = | ||
'string'; | ||
@Input({required: false}) isHeaderCaseSensitive: CaseSensitivityType = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming is important here. To infer the developer that this field is coming from |
||
private triggererComponentType = inject(MAT_TABLE_TRIGGERER_TYPE); | ||
private triggererInstance?: MatTableTriggerer<MatTableDefaultFilterSelection>; | ||
|
||
|
@@ -58,6 +60,7 @@ export class MatTableFilterHeader implements AfterViewInit { | |
); | ||
this.triggererInstance = this._triggererComponentRef.instance; | ||
this.triggererInstance.headerType = this.matTableFilterHeaderType; | ||
this.triggererInstance.sensitivityType = this.isHeaderCaseSensitive; | ||
} | ||
|
||
get selectedFilter$(): Observable<MatTableDefaultFilterSelection> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,14 @@ import {Observable, Subject} from 'rxjs'; | |
import {MatTableFilterButtonComponent} from './mat-table-filter-button/mat-table-filter-button.component'; | ||
import {MatTableDefaultFilterSelection} from './models'; | ||
import {MatTableHeaderType} from './models/header-type'; | ||
import {CaseSensitivityType} from './models/case-sensivity'; | ||
|
||
export class MatTableTriggerer<T extends MatTableDefaultFilterSelection> { | ||
protected matColumnDef = inject(MatColumnDef); | ||
protected selectedFilterSubject = new Subject<T>(); | ||
|
||
public headerType!: MatTableHeaderType; | ||
public sensitivityType!: CaseSensitivityType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With my suggestion on holding this field as just plain |
||
public parentHovered!: boolean; | ||
|
||
public get columnKey() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type CaseSensitivityType = true | false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is no need to create a type for sensitivity state. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,7 +42,14 @@ export class MatTableFilterService { | |||||||||||||||||||||||||||
const value = data[filter.key] as string | number | boolean; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (value !== undefined) { | ||||||||||||||||||||||||||||
return this.operators[filter.operator](value, filter.input); | ||||||||||||||||||||||||||||
if (filter.isCaseSensitive == false) { | ||||||||||||||||||||||||||||
return this.operators[filter.operator]( | ||||||||||||||||||||||||||||
value.toString().toLowerCase(), | ||||||||||||||||||||||||||||
filter.input?.toString().toLowerCase() | ||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||
return this.operators[filter.operator](value, filter.input); | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
Comment on lines
+45
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a suggestion for this code block;
Suggested change
|
||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to have another field to hold case sensitivity state. You can just use
sensitivityType