Starts in:
1 DAY
16 HRS
19 MIN
43 SEC
Starts in:
1 D
16 H
19 M
43 S
Open Closed

Bug when add action with ToolbarAction in FileManagement module #1320


User avatar
0
devteam created

Dear support team,

I want to Get ID of current folder, but when I add action "Sign All", i have error when click "Sign All" button like this

Please show me how to get ID current folder when click action.

  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

2 Answer(s)
  • User Avatar
    0
    bunyamin created

    Hello,

    Let's talk about the hierarchy of FileManagementModule components.

    The root component is FileManagementComponent which contains abp-page, file-management-buttons, file-management-directory-tree, file-management-folder-panel . FileManagementFolderContentComponent lies within file-management-folder-panel and many more.

    So, the component tree looks like the following:

    FileManagementComponent

    • PageComponent
      • FileManagementButtonsComponent
      • FileManagementDirectoryTreeComponent
      • FileManagementFolderPanelComponent
        • FileManagementFolderContentComponent

    Now, let's look at your problem. The action you provided is being used in FileManagementComponent and passed to the PageComponent which means at that level, you can only inject PageComponent or FileManagementComponent. Other components are stored in lower level of the tree and not available to you.

    To get the content of the current folder, here is what you can do

    {
      text: 'FileManagement::Sign All',
      action: (data) => {
        const component = data.getInjected(FileManagementComponent);
        const navigator = data.getInjected(NavigatorService);
    
        // component.currentContent => holds the list of current content, files & folders
        // navigator.getCurrentFolderId() => returns ID of the current folder, null if it is the root folder
      } 
    }
    
  • User Avatar
    0
    devteam created

    Thanks bunyamin ,

    Your answer is very clear.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06