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

Angular column placeholder #1966

Merged
merged 5 commits into from
Mar 28, 2024
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 @@ -31,6 +31,14 @@ export class NimbleTableColumnAnchorDirective extends NimbleTableColumnBaseDirec
this.renderer.setProperty(this.elementRef.nativeElement, 'hrefFieldName', value);
}

public get placeholder(): string | undefined {
return this.elementRef.nativeElement.placeholder;
}

@Input() public set placeholder(value: string | undefined) {
this.renderer.setProperty(this.elementRef.nativeElement, 'placeholder', value);
}

public get appearance(): AnchorAppearance {
return this.elementRef.nativeElement.appearance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ describe('Nimble anchor table column', () => {
expect(directive.groupingDisabled).toBeFalse();
expect(nativeElement.groupingDisabled).toBeFalse();
});

it('has expected defaults for placeholder', () => {
expect(directive.placeholder).toBeUndefined();
expect(nativeElement.placeholder).toBeUndefined();
});
});

describe('with template string values', () => {
Expand Down Expand Up @@ -187,6 +192,7 @@ describe('Nimble anchor table column', () => {
min-pixel-width="40"
group-index="0"
grouping-disabled
placeholder="Custom placeholder"
>
</nimble-table-column-anchor>
`
Expand Down Expand Up @@ -315,6 +321,11 @@ describe('Nimble anchor table column', () => {
expect(directive.groupingDisabled).toBeTrue();
expect(nativeElement.groupingDisabled).toBeTrue();
});

it('will use template string values for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');
});
});

describe('with property bound values', () => {
Expand Down Expand Up @@ -342,6 +353,7 @@ describe('Nimble anchor table column', () => {
[min-pixel-width]="minPixelWidth"
[group-index]="groupIndex"
[grouping-disabled]="groupingDisabled"
[placeholder]="placeholder"
>
</nimble-table-column-anchor>
`
Expand Down Expand Up @@ -370,6 +382,7 @@ describe('Nimble anchor table column', () => {
public minPixelWidth: number | null = 40;
public groupIndex: number | null = 0;
public groupingDisabled = false;
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -661,6 +674,17 @@ describe('Nimble anchor table column', () => {
expect(directive.groupingDisabled).toBeTrue();
expect(nativeElement.groupingDisabled).toBeTrue();
});

it('can be configured with property binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});

describe('with attribute bound values', () => {
Expand Down Expand Up @@ -688,6 +712,7 @@ describe('Nimble anchor table column', () => {
[attr.min-pixel-width]="minPixelWidth"
[attr.group-index]="groupIndex"
[attr.grouping-disabled]="groupingDisabled"
[attr.placeholder]="placeholder"
>
</nimble-table-column-anchor>
`
Expand Down Expand Up @@ -716,6 +741,7 @@ describe('Nimble anchor table column', () => {
public minPixelWidth: number | null = 40;
public groupIndex: number | null = 0;
public groupingDisabled = false;
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -1007,5 +1033,16 @@ describe('Nimble anchor table column', () => {
expect(directive.groupingDisabled).toBe(true);
expect(nativeElement.groupingDisabled).toBe(true);
});

it('can be configured with attribute binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export class NimbleTableColumnDateTextDirective extends NimbleTableColumnBaseDir
this.renderer.setProperty(this.elementRef.nativeElement, 'fieldName', value);
}

public get placeholder(): string | undefined {
return this.elementRef.nativeElement.placeholder;
}

@Input() public set placeholder(value: string | undefined) {
this.renderer.setProperty(this.elementRef.nativeElement, 'placeholder', value);
}

public get format(): DateTextFormat {
return this.elementRef.nativeElement.format;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('NimbleTableColumnDateText', () => {
custom-date-style="medium"
custom-time-style="full"
custom-hour-cycle="h23"
placeholder="Custom placeholder"
></nimble-table-column-date-text>
</nimble-table>
`
Expand Down Expand Up @@ -293,6 +294,11 @@ describe('NimbleTableColumnDateText', () => {
expect(directive.customHourCycle).toBe('h23');
expect(nativeElement.customHourCycle).toBe('h23');
});

it('will use template string values for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');
});
});

describe('with property bound values', () => {
Expand Down Expand Up @@ -332,6 +338,7 @@ describe('NimbleTableColumnDateText', () => {
[custom-date-style]="customDateStyle"
[custom-time-style]="customTimeStyle"
[custom-hour-cycle]="customHourCycle"
[placeholder]="placeholder"
></nimble-table-column-date-text>
</nimble-table>
`
Expand Down Expand Up @@ -370,6 +377,7 @@ describe('NimbleTableColumnDateText', () => {
public customDateStyle: DateStyle = 'medium';
public customTimeStyle: TimeStyle = 'full';
public customHourCycle: HourCycleFormat = 'h23';
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -980,6 +988,17 @@ describe('NimbleTableColumnDateText', () => {
expect(directive.customHourCycle).toBeUndefined();
expect(nativeElement.customHourCycle).toBeUndefined();
});

it('can be configured with property binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});

describe('with attribute bound values', () => {
Expand Down Expand Up @@ -1019,6 +1038,7 @@ describe('NimbleTableColumnDateText', () => {
[attr.custom-date-style]="customDateStyle"
[attr.custom-time-style]="customTimeStyle"
[attr.custom-hour-cycle]="customHourCycle"
[attr.placeholder]="placeholder"
></nimble-table-column-date-text>
</nimble-table>
`
Expand Down Expand Up @@ -1057,6 +1077,7 @@ describe('NimbleTableColumnDateText', () => {
public customDateStyle: DateStyle = 'medium';
public customTimeStyle: TimeStyle = 'full';
public customHourCycle: HourCycleFormat = 'h23';
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -1667,5 +1688,16 @@ describe('NimbleTableColumnDateText', () => {
expect(directive.customHourCycle).toBeNull();
expect(nativeElement.customHourCycle).toBeNull();
});

it('can be configured with attribute binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export class NimbleTableColumnDurationTextDirective extends NimbleTableColumnBas
this.renderer.setProperty(this.elementRef.nativeElement, 'fieldName', value);
}

public get placeholder(): string | undefined {
return this.elementRef.nativeElement.placeholder;
}

@Input() public set placeholder(value: string | undefined) {
this.renderer.setProperty(this.elementRef.nativeElement, 'placeholder', value);
}

public get fractionalWidth(): number | null | undefined {
return this.elementRef.nativeElement.fractionalWidth;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('NimbleTableColumnDurationText', () => {
sort-index="0"
group-index="0"
grouping-disabled
placeholder="Custom placeholder"
></nimble-table-column-duration-text>
</nimble-table>
`
Expand Down Expand Up @@ -113,6 +114,11 @@ describe('NimbleTableColumnDurationText', () => {
expect(directive.groupingDisabled).toBeTrue();
expect(nativeElement.groupingDisabled).toBeTrue();
});

it('will use template string values for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');
});
});

describe('with property bound values', () => {
Expand All @@ -132,6 +138,7 @@ describe('NimbleTableColumnDurationText', () => {
[sort-index]="sortIndex"
[group-index]="groupIndex"
[grouping-disabled]="groupingDisabled"
[placeholder]="placeholder"
></nimble-table-column-duration-text>
</nimble-table>
`
Expand All @@ -150,6 +157,7 @@ describe('NimbleTableColumnDurationText', () => {
public sortIndex: number | null = 0;
public groupIndex: number | null = 0;
public groupingDisabled = false;
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -331,6 +339,17 @@ describe('NimbleTableColumnDurationText', () => {
expect(directive.groupingDisabled).toBeTrue();
expect(nativeElement.groupingDisabled).toBeTrue();
});

it('can be configured with property binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});

describe('with attribute bound values', () => {
Expand All @@ -350,6 +369,7 @@ describe('NimbleTableColumnDurationText', () => {
[attr.sort-index]="sortIndex"
[attr.group-index]="groupIndex"
[attr.grouping-disabled]="groupingDisabled"
[attr.placeholder]="placeholder"
></nimble-table-column-duration-text>
</nimble-table>
`
Expand All @@ -368,6 +388,7 @@ describe('NimbleTableColumnDurationText', () => {
public sortIndex: number | null = 0;
public groupIndex: number | null = 0;
public groupingDisabled = false;
public placeholder = 'Custom placeholder';
}

let fixture: ComponentFixture<TestHostComponent>;
Expand Down Expand Up @@ -549,5 +570,16 @@ describe('NimbleTableColumnDurationText', () => {
expect(directive.groupingDisabled).toBe(true);
expect(nativeElement.groupingDisabled).toBe(true);
});

it('can be configured with attribute binding for placeholder', () => {
expect(directive.placeholder).toBe('Custom placeholder');
expect(nativeElement.placeholder).toBe('Custom placeholder');

fixture.componentInstance.placeholder = 'Updated placeholder';
fixture.detectChanges();

expect(directive.placeholder).toBe('Updated placeholder');
expect(nativeElement.placeholder).toBe('Updated placeholder');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export class NimbleTableColumnNumberTextDirective extends NimbleTableColumnBaseD
this.renderer.setProperty(this.elementRef.nativeElement, 'fieldName', value);
}

public get placeholder(): string | undefined {
return this.elementRef.nativeElement.placeholder;
}

@Input() public set placeholder(value: string | undefined) {
this.renderer.setProperty(this.elementRef.nativeElement, 'placeholder', value);
}

public get format(): NumberTextFormat {
return this.elementRef.nativeElement.format;
}
Expand Down
Loading
Loading