diff options
Diffstat (limited to 'client/src/app/shared/shared-main/angular')
-rw-r--r-- | client/src/app/shared/shared-main/angular/auto-colspan.directive.ts | 22 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/angular/index.ts | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts b/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts new file mode 100644 index 000000000..8da89b668 --- /dev/null +++ b/client/src/app/shared/shared-main/angular/auto-colspan.directive.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { AfterViewInit, Directive, ElementRef, Renderer2 } from '@angular/core' | ||
2 | |||
3 | @Directive({ | ||
4 | selector: '[myAutoColspan]' | ||
5 | }) | ||
6 | export class AutoColspanDirective implements AfterViewInit { | ||
7 | |||
8 | constructor ( | ||
9 | private host: ElementRef, | ||
10 | private renderer: Renderer2 | ||
11 | ) { } | ||
12 | |||
13 | ngAfterViewInit () { | ||
14 | const el = this.host.nativeElement as HTMLElement | ||
15 | const table = el.closest('table') | ||
16 | if (!table) throw new Error('table element not found') | ||
17 | |||
18 | const th = table.querySelectorAll('th') | ||
19 | |||
20 | this.renderer.setAttribute(el, 'colspan', th.length + '') | ||
21 | } | ||
22 | } | ||
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts index f72d60313..6ea494129 100644 --- a/client/src/app/shared/shared-main/angular/index.ts +++ b/client/src/app/shared/shared-main/angular/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './auto-colspan.directive' | ||
1 | export * from './autofocus.directive' | 2 | export * from './autofocus.directive' |
2 | export * from './bytes.pipe' | 3 | export * from './bytes.pipe' |
3 | export * from './defer-loading.directive' | 4 | export * from './defer-loading.directive' |