Skip to content

Instantly share code, notes, and snippets.

@evgenyfedorenko
Created July 30, 2019 16:01
Show Gist options
  • Save evgenyfedorenko/0fd22bb7cd3fa468b76a979ba3f2e4e4 to your computer and use it in GitHub Desktop.
Save evgenyfedorenko/0fd22bb7cd3fa468b76a979ba3f2e4e4 to your computer and use it in GitHub Desktop.
...
@Component({
selector: 'list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ListComponent implements OnChanges {
@Input() rows: Transaction[];
private _rows: {[key: string]: Transaction} = {};
public rowClasses: {[key: string]: any} = {};
...
ngOnChanges() {
this.rows.forEach((row) => {
if (!this._rows[row.id] || this._rows[row.id].version !== row.version) {
this._rows[row.id] = row;
this.setRowClasses(row);
}
});
}
private setRowClasses(row) {
this.rowClasses[row.id] = {
'active': this.trService.isActive(row),
'rejected': this.trService.isRejected(row),
'accepted': this.trService.isAccepted(row)
};
}
public getRowClasses(row: Transaction) {
return this.rowClasses[row.id];
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment