Browse Source

refactor(theme-shared): change td element to div

#2537
pull/2605/head
mehmet-erim 7 years ago
parent
commit
49a14b999e
  1. 6
      npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html
  2. 23
      npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts
  3. 2
      npm/ng-packs/packages/theme-shared/src/lib/tests/pagination.component.spec.ts

6
npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html

@ -69,9 +69,9 @@
</ng-template> </ng-template>
<ng-template #emptyTemplate> <ng-template #emptyTemplate>
<tr> <tr class="empty-row" #emptyRow>
<td class="text-center" [attr.colspan]="colspan"> <div [style.width.px]="emptyRow.offsetWidth">
{{ emptyMessage | abpLocalization }} {{ emptyMessage | abpLocalization }}
</td> </div>
</tr> </tr>
</ng-template> </ng-template>

23
npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts

@ -1,5 +1,4 @@
import { import {
AfterViewInit,
Component, Component,
ElementRef, ElementRef,
EventEmitter, EventEmitter,
@ -9,7 +8,10 @@ import {
TrackByFunction, TrackByFunction,
ViewChild, ViewChild,
ViewEncapsulation, ViewEncapsulation,
AfterViewInit,
} from '@angular/core'; } from '@angular/core';
import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators';
@Component({ @Component({
selector: 'abp-table', selector: 'abp-table',
@ -20,6 +22,15 @@ import {
.ui-table .ui-table-tbody > tr:hover { .ui-table .ui-table-tbody > tr:hover {
background-color: #eaeaea; background-color: #eaeaea;
} }
.ui-table .ui-table-tbody > tr.empty-row:hover {
background-color: transparent;
}
.ui-table .ui-table-tbody > tr.empty-row > div {
margin: 10px;
text-align: center;
}
`, `,
], ],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
@ -64,7 +75,7 @@ export class TableComponent implements AfterViewInit {
bodyScrollLeft = 0; bodyScrollLeft = 0;
colspan = 0; colspan: number;
trackByFn: TrackByFunction<any> = (_, value) => { trackByFn: TrackByFunction<any> = (_, value) => {
return typeof value === 'object' ? value[this.trackingProp] || value : value; return typeof value === 'object' ? value[this.trackingProp] || value : value;
@ -89,7 +100,7 @@ export class TableComponent implements AfterViewInit {
} }
get slicedValue(): any[] { get slicedValue(): any[] {
if (!this.rows || this.rows > this.value.length) { if (!this.rows || this.rows >= this.value.length) {
return this.value; return this.value;
} }
@ -97,9 +108,9 @@ export class TableComponent implements AfterViewInit {
return this.value.slice(start, start + this.rows); return this.value.slice(start, start + this.rows);
} }
constructor() {}
ngAfterViewInit() { ngAfterViewInit() {
this.colspan = this.wrapperRef.nativeElement.querySelectorAll('th').length; setTimeout(() => {
this.colspan = this.wrapperRef.nativeElement.querySelectorAll('th').length;
}, 0);
} }
} }

2
npm/ng-packs/packages/theme-shared/src/lib/tests/pagination.component.spec.ts

@ -32,7 +32,7 @@ describe('PaginationComponent', () => {
'7', '7',
]); ]);
spectator.setHostInput({ value: 2 }); spectator.click('.ui-paginator-first');
expect(spectator.queryAll('.ui-paginator-page').map(node => node.textContent)).toEqual([ expect(spectator.queryAll('.ui-paginator-page').map(node => node.textContent)).toEqual([
'1', '1',

Loading…
Cancel
Save