mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Fix Like component to be reactive on change of nodeId parameter (#2717)
This commit is contained in:
committed by
Eugenio Romano
parent
16428a8109
commit
a2e6ee4c95
@@ -60,6 +60,8 @@ describe('Like component', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('should load the likes by default on onChanges', async(() => {
|
it('should load the likes by default on onChanges', async(() => {
|
||||||
|
component.ngOnChanges();
|
||||||
|
|
||||||
simulateResponseWithLikes(2);
|
simulateResponseWithLikes(2);
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { RatingService } from './services/rating.service';
|
import { RatingService } from './services/rating.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -25,7 +25,7 @@ import { RatingService } from './services/rating.service';
|
|||||||
providers: [RatingService],
|
providers: [RatingService],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class LikeComponent implements OnInit {
|
export class LikeComponent implements OnChanges {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
nodeId: string;
|
nodeId: string;
|
||||||
@@ -39,7 +39,7 @@ export class LikeComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private ratingService: RatingService) {}
|
constructor(private ratingService: RatingService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnChanges() {
|
||||||
this.clean();
|
this.clean();
|
||||||
|
|
||||||
this.ratingService.getRating(this.nodeId, this.ratingType).subscribe(
|
this.ratingService.getRating(this.nodeId, this.ratingType).subscribe(
|
||||||
|
Reference in New Issue
Block a user