AnsweredAssumed Answered

DocumentListComponent action handler customization not working

Question asked by jameswu1818 on Sep 6, 2018
Latest reply on Sep 7, 2018 by dvuika

Someone please help us. In DocumentListComponent, we want to run our customized code for download action. so that we can run our code before calling the default ‘download’ handler; or not calling the default handler at all.

 

According to documents

https://alfresco.github.io/adf-component-catalog/components/ContentActionComponent.html

https://alfresco.github.io/adf-component-catalog/injectables/DocumentActionsService.html

 

, it is possible to register a new customized action to replace default ‘download’ action handler. But it does not work for us. Following is excerpt of our code, that is very similar to samples provided. Neither myDocumentActionHandler() nor customDownloadBehavior() is called when the actions are selected from the three dot action menu.

 

============= html ===========

<adf-document-list
 
#documentList

  [multiselect]=
true
 
[allowDropFiles]="false"
 
[navigationMode]="'dblclick'"
 
[contextMenuActions]="true"
 
[contentActions]="true"
 
[selectionMode]="'multiple'"
 
currentFolderId={{parentFolder.folderId}}
 
(preview)="showPreview($event)"
 
[sorting]="['name', 'ASC']">

  <
content-actions>

   
<content-action
     
target="document"
     
title="APP.ACTIONS.DOWNLOAD"
     
handler="download" >
    </
content-action>

    <
content-action
     
target="document"
     
title="My Handler"
     
handler="my-handler" >
    </
content-action>     <!- - other actions - - >
  </content-actions>     <!- - other column defs - -></adf-document-list>

 

============= controller ===========

// other imports …
import { DocumentListComponent, DocumentActionsService } from '@alfresco/adf-content-services';


@Component({
selector: 'app-doc-list',
 
templateUrl: './doc-list.component.html',
 
styleUrls: ['./doc-list.component.scss']
})
export class DocListComponent extends BrowseResult {


 
// other properteis …

 
originalDownloadHandler;

 
constructor(documentActions: DocumentActionsService,
              //

) {
   
super(peopleApi, rfsDocumentService);

    documentActions.
setHandler(
     
'my-handler',
     
this.myDocumentActionHandler.bind(this)
    );

   
this.originalDownloadHandler = documentActions.getHandler('download');
    documentActions.
setHandler(
     
'download',
     
this.customDownloadBehavior.bind(this)
    );

  }

 
myDocumentActionHandler(obj: any) {
   
console.log('my custom action handler is never called');
  }

 
customDownloadBehavior(obj: any) {
   
console.log('my custom download behavior is never called');
   
this.originalDownloadHandler(obj);
  }

 

  // other functions …
}

Outcomes