alfresco-ng2-components/docs/core/directives/node-favorite.directive.md
Andy Stark 5fc05da7aa [ADF-4152] Updated folder structure of core docs (#4415)
* [ADF-4152] Moved core library docs into subfolders

* [ADF-4152] Moved core library docs into subfolders

* [ADF-4152] Manual fixes to core doc file links

* [ADF-4152] Further automatic + manual link tidying
2019-03-12 14:20:20 +00:00

2.2 KiB

Title, Added, Status, Last reviewed
Title Added Status Last reviewed
Node Favorite directive v2.0.0 Active 2018-11-13

Node Favorite directive

Selectively toggles nodes as favorites.

Basic Usage

<adf-toolbar>
    <button mat-icon-button
            (toggle)="done()"
            [adf-node-favorite]="documentList.selection">
    </button>
</adf-toolbar>

<adf-document-list #documentList ...>
 ...
</adf-document-list>
@Component({
    selector: 'my-component'
})
export class MyComponent {

    done() {
        // ...
    }

}

Class members

Properties

Name Type Default value Description
selection NodeEntry[] [] Array of nodes to toggle as favorites.

Events

Name Type Description
error EventEmitter<any> Emitted when the favorite setting fails.
toggle EventEmitter<any> Emitted when the favorite setting is complete.

Details

You can bind the directive instance to a template variable through the adfFavorite reference, which also lets you add extra styling to the element:

<button
    mat-menu-item
    #selection="adfFavorite"
    [ngClass]="{ 'icon-highlight': selection.hasFavorites() }"
    [adf-node-favorite]="documentList.selection">
    <mat-icon [ngClass]="{ 'icon-highlight': selection.hasFavorites() }">
        {{ selection.hasFavorites() ? 'star' : 'star_border' }}
    </mat-icon>
</button>

The directive behaves as follows:

  • If there are no favorite nodes in the selection, then all are marked as favorites
  • If there are one or more favorite nodes in the selection, then only those that are not favorites are marked
  • If all nodes in the selection are favorites, then they all have their favorite status removed

See the Demo Shell for examples of usage.