Skip to content

Commit c08a8fc

Browse files
authored
Fix exports & datatable error handling (#15)
* Add missing export * Improve datatable styling * Test custom html in datatable column * Add exception handling when datatable has no template given
1 parent 950c779 commit c08a8fc

File tree

8 files changed

+21
-3
lines changed

8 files changed

+21
-3
lines changed

projects/angular-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@frankframework/angular-components",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A collection of reusable components designed for use in Frank!Framework projects",
55
"main": "",
66
"author": "Vivy Booman",

projects/angular-components/src/lib/datatable/datatable.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
</ng-container>
3131
<ng-template #htmlBody>
3232
<ng-container
33+
*ngIf="content; else noTemplate"
3334
[ngTemplateOutlet]="content.templateReference"
3435
[ngTemplateOutletContext]="{ rowElement: element }"
3536
></ng-container>
37+
<ng-template #noTemplate><small>No template with DtContent found in datatable body</small></ng-template>
3638
</ng-template>
3739
</td>
3840
</ng-container>

projects/angular-components/src/lib/datatable/datatable.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
table {
66
margin-bottom: 10px;
7+
width: 100%;
78
}
89

910
.dt-options {

projects/angular-components/src/lib/datatable/datatable.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class DatatableComponent<T> implements AfterViewInit, OnDestroy {
5959
@Input({ required: true }) public datasource!: DataTableDataSource<T>;
6060
@Input({ required: true }) public displayColumns: DataTableColumn<T>[] = [];
6161

62-
@ContentChild(DtContentDirective) protected content!: DtContentDirective<T>;
62+
@ContentChild(DtContentDirective) protected content?: DtContentDirective<T>;
6363
protected totalFilteredEntries: number = 0;
6464
protected totalEntries: number = 0;
6565
protected minPageEntry: number = 0;

projects/angular-components/src/lib/library.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { AlertComponent } from './alert/alert.component';
55
import { ChipComponent } from './chip/chip.component';
66
import { DatatableComponent } from './datatable/datatable.component';
77
import { CheckboxComponent } from './checkbox/checkbox.component';
8+
import { DtContentDirective } from './datatable/dt-content.directive';
9+
import { ThSortableDirective } from './th-sortable.directive';
810

911
const components = [
1012
ButtonComponent,
@@ -13,6 +15,8 @@ const components = [
1315
ChipComponent,
1416
DatatableComponent,
1517
CheckboxComponent,
18+
DtContentDirective,
19+
ThSortableDirective,
1620
];
1721

1822
@NgModule({

projects/angular-components/src/public_api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export * from './lib/search/search.component';
55
export * from './lib/alert/alert.component';
66
export * from './lib/chip/chip.component';
77
export * from './lib/datatable/datatable.component';
8-
export * from './lib/th-sortable.directive';
98
export * from './lib/checkbox/checkbox.component';
109

10+
export * from './lib/th-sortable.directive';
11+
export * from './lib/datatable/dt-content.directive';
12+
1113
// helper classes
1214
export * from './lib/icons/icon-base';

src/app/app.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ <h2>Chip</h2>
7878
</li>
7979
<li>
8080
<h2>Datatable</h2>
81+
<div class="components">
82+
<ff-datatable [datasource]="datasource" [displayColumns]="displayedColumns">
83+
<ng-template appDtContent>
84+
<span><button>Something</button></span>
85+
</ng-template>
86+
</ff-datatable>
87+
</div>
88+
<p>Without template:</p>
8189
<div class="components">
8290
<ff-datatable [datasource]="datasource" [displayColumns]="displayedColumns"></ff-datatable>
8391
</div>

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class AppComponent implements OnInit {
2525
{ name: 'title', displayName: 'Title', property: 'title' },
2626
{ name: 'description', displayName: 'Description', property: 'description' },
2727
{ name: 'genre', displayName: 'Genre', property: 'genre' },
28+
{ name: 'actions', displayName: 'Actions', property: null, html: true },
2829
];
2930

3031
constructor() {}

0 commit comments

Comments
 (0)