cancel
Showing results for 
Search instead for 
Did you mean: 

How to restrict menu option only for folders in alfresco Search using Aikau

shyam2016
Champ in-the-making
Champ in-the-making

Hi,

we have implemented one functionality to calculate the size of assets in search component.

So if user select folder in search result page then only calculate size option should display, but problem is even if user selects the file or document calculate size option is displaying.

below is the sample code.

faceted-search.get.js

var calCulateSizewidget = {

   name: "alfresco/menus/AlfSelectedItemsMenuItem",

   config: {

  label: msg.get("calculate.size.folders"),

  clearSelectedItemsOnClick: true,

  publishTopic: "CUSTOM_CALCULATE_SIZE"

   

  }

    };

var widget2 = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_SEARCH_RESULT");

var widget3 = widgetUtils.findObject(model.jsonModel.widgets, "id", "CUSTOM_SELECTED_MENU");

function  showCalculateSizeforGroup(group,calCulateSizewidget){

if(widget2.config.onFolderSelection === true)

{

  widget3.config.widgets.push(calCulateSizewidget);

  }

}

I have tried extending the AlfSelectedItemmenuItem.js

onItemsSelected: function alfresco_menus_AlfSelectedItemsMenuItem__onItemsSelected(payload) {

   alert(" payload "+payload);

         if (payload.selectedItems)

         {

            if (!this.publishPayload)

            {

               this.publishPayload = {};

            }

  var records = payload.selectedItems;

  var newPayload = [];

  for(var i = 0; i < records.length; i++)

  {

  if(records[i].type == "folder")

  {

  onFolderSelection = true;

  console.log("record payload"+records[i]);

  newPayload.push(records[i]);

  }

  }

            this.publishPayload.selectedItems = newPayload;

         }

      },

Please let me know if i am missing anything.

Thanks !

3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator

So if I understand the problem correctly you only want the calculate menu item to appear when documents are selected rather than folders?

I think you'll want something more like the AlfDocumentActionMenuItem widget (which extends AlfFilteringMenuItem). This is used in the Aikau Document Library to filter out menu items that don't match the the display criteria. Note that you'll need to create a custom widget extending AlfFilteringMenuItem and configure the "filterTopic" attribute and override the "filter" function. Also, your menu items will need to be placed in an AlfSelectedItemsMenuBarPopup​.

Your other alternative would be to configure the visibilityConfig on your menu item (see example in the Sandpit) however I don't think that it currently supports rules as complex as you'd require for interpreting multiple selected items.

shyam2016
Champ in-the-making
Champ in-the-making

Thank you Dave Draper

yes actually i want to display calculate size menu ONLY for Folders not for documents.

so basically when user search some assets

and in search result page if user selects folder - display calculate size menu in selected item drop down

if user selects documents/text/html or any other content - do not display calculate size menu n selected item drop down

ddraper
World-Class Innovator
World-Class Innovator

OK... but my previous answer would still be appropriate - it's just that the logic would be reversed, did you have any success following my suggestion?