[ACA-1746] Preview - favorite action UI state does not change (#597)

This commit is contained in:
Cilibiu Bogdan
2018-09-03 21:35:27 +03:00
committed by Denys Vuika
parent fa0d10c419
commit a9402bef00

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Component } from '@angular/core'; import { Component, ChangeDetectorRef } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppStore } from '../../../store/states'; import { AppStore } from '../../../store/states';
import { appSelection } from '../../../store/selectors/app.selectors'; import { appSelection } from '../../../store/selectors/app.selectors';
@@ -36,6 +36,7 @@ import { SelectionState } from '@alfresco/adf-extensions';
<button <button
mat-menu-item mat-menu-item
#favorites="adfFavorite" #favorites="adfFavorite"
(toggle)="onToggleEvent()"
[adf-node-favorite]="(selection$ | async).nodes"> [adf-node-favorite]="(selection$ | async).nodes">
<mat-icon *ngIf="favorites.hasFavorites()">star</mat-icon> <mat-icon *ngIf="favorites.hasFavorites()">star</mat-icon>
<mat-icon *ngIf="!favorites.hasFavorites()">star_border</mat-icon> <mat-icon *ngIf="!favorites.hasFavorites()">star_border</mat-icon>
@@ -47,7 +48,14 @@ export class ToggleFavoriteComponent {
selection$: Observable<SelectionState>; selection$: Observable<SelectionState>;
constructor(private store: Store<AppStore>) { constructor(
private store: Store<AppStore>,
private changeDetection: ChangeDetectorRef) {
this.selection$ = this.store.select(appSelection); this.selection$ = this.store.select(appSelection);
} }
onToggleEvent() {
this.changeDetection.detectChanges();
}
} }