refactor(theme-shared): change the table row hover style

#2537
pull/2605/head
mehmet-erim 6 years ago
parent 1b2476ad7b
commit 4f3df423ab

@ -11,6 +11,8 @@ export class PaginationComponent implements OnInit {
return this._value; return this._value;
} }
set value(newValue: number) { set value(newValue: number) {
if (this._value === newValue) return;
this._value = newValue; this._value = newValue;
this.valueChange.emit(newValue); this.valueChange.emit(newValue);
} }

@ -6,7 +6,8 @@
<abp-pagination <abp-pagination
*ngIf="rows" *ngIf="rows"
[totalPages]="totalPages" [totalPages]="totalPages"
(valueChange)="page = $event; pageChange.emit($event)" [(value)]="page"
(valueChange)="pageChange.emit($event)"
></abp-pagination> ></abp-pagination>
</div> </div>
</div> </div>
@ -60,9 +61,9 @@
<ng-container *ngIf="value && value.length; else emptyTemplate"> <ng-container *ngIf="value && value.length; else emptyTemplate">
<ng-template <ng-template
#bodyTemplateWrapper #bodyTemplateWrapper
*ngFor="let val of slicedValue; trackBy: trackByFn" *ngFor="let val of slicedValue; let index = index; trackBy: trackByFn"
[ngTemplateOutlet]="bodyTemplate" [ngTemplateOutlet]="bodyTemplate"
[ngTemplateOutletContext]="{ $implicit: val }" [ngTemplateOutletContext]="{ $implicit: val, rowIndex: index }"
></ng-template> ></ng-template>
</ng-container> </ng-container>
</tbody> </tbody>

@ -1,4 +1,5 @@
import { import {
AfterViewInit,
Component, Component,
ElementRef, ElementRef,
EventEmitter, EventEmitter,
@ -8,10 +9,7 @@ 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,11 +18,11 @@ import { delay } from 'rxjs/operators';
` `
.ui-table .ui-table-tbody > tr:nth-child(even):hover, .ui-table .ui-table-tbody > tr:nth-child(even):hover,
.ui-table .ui-table-tbody > tr:hover { .ui-table .ui-table-tbody > tr:hover {
background-color: #eaeaea; filter: brightness(90%);
} }
.ui-table .ui-table-tbody > tr.empty-row:hover { .ui-table .ui-table-tbody > tr.empty-row:hover {
background-color: transparent; filter: none;
} }
.ui-table .ui-table-tbody > tr.empty-row > div { .ui-table .ui-table-tbody > tr.empty-row > div {
@ -35,8 +33,9 @@ import { delay } from 'rxjs/operators';
], ],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
}) })
export class TableComponent implements AfterViewInit { export class TableComponent {
private _totalRecords: number; private _totalRecords: number;
bodyScrollLeft = 0;
@Input() @Input()
value: any[]; value: any[];
@ -59,6 +58,9 @@ export class TableComponent implements AfterViewInit {
@Input() @Input()
rows: number; rows: number;
@Input()
page = 1;
@Input() @Input()
trackingProp = 'id'; trackingProp = 'id';
@ -71,16 +73,6 @@ export class TableComponent implements AfterViewInit {
@ViewChild('wrapper', { read: ElementRef, static: false }) @ViewChild('wrapper', { read: ElementRef, static: false })
wrapperRef: ElementRef<HTMLDivElement>; wrapperRef: ElementRef<HTMLDivElement>;
page = 1;
bodyScrollLeft = 0;
colspan: number;
trackByFn: TrackByFunction<any> = (_, value) => {
return typeof value === 'object' ? value[this.trackingProp] || value : value;
};
@Input() @Input()
get totalRecords(): number { get totalRecords(): number {
return this._totalRecords || this.value.length; return this._totalRecords || this.value.length;
@ -108,9 +100,7 @@ export class TableComponent implements AfterViewInit {
return this.value.slice(start, start + this.rows); return this.value.slice(start, start + this.rows);
} }
ngAfterViewInit() { trackByFn: TrackByFunction<any> = (_, value) => {
setTimeout(() => { return typeof value === 'object' ? value[this.trackingProp] || value : value;
this.colspan = this.wrapperRef.nativeElement.querySelectorAll('th').length; };
}, 0);
}
} }

Loading…
Cancel
Save