import { Component , Input , ViewEncapsulation , OnInit , OnDestroy } from '@angular/core' ; import { MinimalNodeEntryEntity } from '@alfresco/js-api' ; import { NodePermissionService , isLocked , AppExtensionService } from '@alfresco/aca-shared' ; import { AppStore , infoDrawerMetadataAspect } from '@alfresco/aca-shared/store' ; import { AppConfigService , NotificationService } from '@alfresco/adf-core' ; import { Observable , Subject } from 'rxjs' ; import { Store } from '@ngrx/store' ; import { ContentMetadataService } from '@alfresco/adf-content-services' ; import { takeUntil } from 'rxjs/operators' ; @ Component ( { selector : 'app-metadata-tab' , template : `
    <adf-content-metadata-card [readOnly]="!canUpdateNode" [preset]="'custom'" [node]="node" [displayAspect]="displayAspect$ | async">
    </adf-content-metadata-card>
  ` , encapsulation : ViewEncapsulation . None , host : { class : 'app-metadata-tab' } } ) export class MetadataTabComponent implements OnInit , OnDestroy { protected onDestroy$ = new Subject < boolean > ( ) ; @ Input ( ) node : MinimalNodeEntryEntity ; displayAspect$ : Observable < string > ; constructor ( private permission , protected extensions , private appConfig , private store , private notificationService , private contentMetadataService ) { if ( this . extensions . contentMetadata ) { this . appConfig . config [ 'content-metadata' ] . presets = this . extensions . contentMetadata . presets ; } this . displayAspect$ = this . store . select ( infoDrawerMetadataAspect ) ; } get canUpdateNode ( ) : boolean { if ( this . node && ! isLocked ( { entry : this . node } ) ) { return this . permission . check ( this . node , [ 'update' ] ) ; } return false ; } ngOnInit ( ) { this . contentMetadataService . error . pipe ( takeUntil ( this . onDestroy$ ) ) . subscribe ( ( err ) => { this . notificationService . showError ( err . message ) ; } ) ; } ngOnDestroy ( ) { this . onDestroy$ . next ( true ) ; this . onDestroy$ . complete ( ) ; } }