Created
July 30, 2019 16:01
-
-
Save evgenyfedorenko/0fd22bb7cd3fa468b76a979ba3f2e4e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@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