import { NameColumnComponent } from '@alfresco/adf-content-services' ; import { AlfrescoApiService } from '@alfresco/adf-core' ; import { ChangeDetectorRef , Component , ElementRef , OnDestroy , OnInit , ViewEncapsulation } from '@angular/core' ; import { Actions , ofType } from '@ngrx/effects' ; import { Subject } from 'rxjs' ; import { filter , takeUntil } from 'rxjs/operators' ; import { NodeActionTypes } from '@alfresco/aca-shared/store' ; import { isLocked } from '@alfresco/aca-shared' ; @ Component ( { selector : 'aca-custom-name-column' , templateUrl : './name-column.component.html' , styleUrls : [ './name-column.component.scss' ] , encapsulation : ViewEncapsulation . None , host : { class : 'adf-datatable-content-cell adf-datatable-link adf-name-column aca-custom-name-column' } } ) export class CustomNameColumnComponent extends NameColumnComponent implements OnInit , OnDestroy { private onDestroy$$ = new Subject < boolean > ( ) ; constructor ( element , private cd , private actions$ , private apiService ) { super ( element , apiService ) ; } ngOnInit ( ) { this . updateValue ( ) ; this . apiService . nodeUpdated . pipe ( takeUntil ( this . onDestroy$$ ) ) . subscribe ( ( node ) => { const row = this . context . row ; if ( row ) { const { entry } = row . node ; const currentId = entry . nodeId || entry . id ; const updatedId = node . nodeId || node . id ; if ( currentId === updatedId ) { entry . name = node . name ; row . node = { entry } ; this . updateValue ( ) ; } } } ) ; this . actions$ . pipe ( ofType < any > ( NodeActionTypes . EditOffline ) , filter ( ( val ) => { return this . node . entry . id === val . payload . entry . id ; } ) , takeUntil ( this . onDestroy$$ ) ) . subscribe ( ( ) => { this . cd . detectChanges ( ) ; } ) ; } onLinkClick ( event ) { event . stopPropagation ( ) ; this . onClick ( ) ; } ngOnDestroy ( ) { super . ngOnDestroy ( ) ; this . onDestroy$$ . next ( true ) ; this . onDestroy$$ . complete ( ) ; } get isFile ( ) : boolean { return this . node && this . node . entry && ! this . node . entry . isFolder ; } get isFileWriteLocked ( ) : boolean { return isLocked ( this . node ) ; } }