cancel
Showing results for 
Search instead for 
Did you mean: 

Limit nuxeo-document-create-button visibility to folderish documents?

Phil_Ludlow
Star Contributor
Star Contributor

Is there an easy way to hide the nuxeo-document-create-button element so that it only shows when viewing a folderish document? We would like to disable the element in WebUI so that it doesn't show for other types of documents as it can sometimes obscure information, and that it really isn't needed for our users unless they are in a "folder" (or something with a similar view).

This element seems to reside in https://github.com/nuxeo/nuxeo-web-ui/blob/master/elements/nuxeo-app.js, and I'm not sure if I'm able to override that or not (probably isn't recommended to do so anyway). We are using LTS 2021 latest hotfix as well.

Overlay issue example

1 ACCEPTED ANSWER

Phil_Ludlow
Star Contributor
Star Contributor

Posting a solution, in case anyone also would like to do this. Support came up with a script that I modified slightly and it seems to be working well so far (at least in development). Add the following code in your custom-bundle:

<script>
  const app = document.querySelector('nuxeo-app');
  app.$.pages.addEventListener('iron-select', () => { 
    app.root.querySelector('nuxeo-document-create-button').hidden = (app.page === 'home') || (app.page === 'search') ? true : app.currentDocument && (!app.currentDocument.facets.includes('Folderish') || app.currentDocument.facets.includes('Collection')); 
  });
</script>

This will hide the document-create-button on the following pages in WebUI:

  • Home Page
  • Search Page
  • Any doctypes that do not have the Folderish facet
  • Doctypes that have the Collection facet

The goal we had was to hide the button on any page that could not directly have documents created in it. This code satisfies those conditions.

View answer in original post

2 REPLIES 2

Phil_Ludlow
Star Contributor
Star Contributor

Note, I added some padding-bottom to the card in the screenshot to account for the document create button (so that it doesn't cover download options). That helps a bit, but we still are looking to disable/hide the button except on folderish document views.

Phil_Ludlow
Star Contributor
Star Contributor

Posting a solution, in case anyone also would like to do this. Support came up with a script that I modified slightly and it seems to be working well so far (at least in development). Add the following code in your custom-bundle:

<script>
  const app = document.querySelector('nuxeo-app');
  app.$.pages.addEventListener('iron-select', () => { 
    app.root.querySelector('nuxeo-document-create-button').hidden = (app.page === 'home') || (app.page === 'search') ? true : app.currentDocument && (!app.currentDocument.facets.includes('Folderish') || app.currentDocument.facets.includes('Collection')); 
  });
</script>

This will hide the document-create-button on the following pages in WebUI:

  • Home Page
  • Search Page
  • Any doctypes that do not have the Folderish facet
  • Doctypes that have the Collection facet

The goal we had was to hide the button on any page that could not directly have documents created in it. This code satisfies those conditions.