cancel
Showing results for 
Search instead for 
Did you mean: 

Reordering header menu

nikes
Champ on-the-rise
Champ on-the-rise
Hello ,

I am trying to reorder menus in header bar, but did not find any api for the same.

Possible way I found is to,
Take reference of the menu item:
var sharedMenu =   widgetUtils.findObject(model.jsonModel, "id", "HEADER_SHARED_FILES");
.
.

Remove all header menu items using following example,
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SHARED_FILES");
.
.
.

then add
var testHeaderMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_APP_MENU_BAR");
testHeaderMenu.config.widgets.push(sharedMenu);


Doing this way, it works for an admin user, but for non-admin, menu bar disappears.

Has anyone done this before and have better way to do this ?

Thanks in advance,
Nikesh
3 REPLIES 3

malliswar
Champ in-the-making
Champ in-the-making
hi nikes,


       i had the same kind of requirement to add/remove and change menu items in share header

the way i did it is

i extended the file share-header.get.js under the below directory into shared folder

alfresco-5.0.adsgsgsdg/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/header/share-header.get.js


function generateAppItems() {

//New header tabs are added and linked with respective sites
   var appItems = [
      {
         id: "HEADER_HOME",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_HOME",
            label: "header.menu.home.label",
            targetUrl: "site/home/dashboard"
         }
      },

      {
         id: "HEADER_HR_DESK",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_HR_DESK",
            label: "header.menu.hrdesk.label",
            targetUrl: "site/hr-desk/dashboard"
         }
      },

      {
         id: "HEADER_Mobility_Desk",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_Mobility_Desk",
            label: "header.menu.monilityedesk.label",
            targetUrl: "site/mobility-desk/dashboard"
         }
      }, 

      {
         id: "HEADER_Finance_Desk",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_Finance_Desk",
            label: "header.menu.financedesk.label",
            targetUrl: "site/finance-desk/dashboard"
         }
      },

       {
         id: "HEADER_GALLERY",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_GALLERY",
            label: "header.menu.gallery.label",
            targetUrl: "site/gallery/dashboard"
         }
      },

       {
         id: "HEADER_LEAP",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_LEAP",
            label: "header.menu.leap.label",
            targetUrl: "site/leap/dashboard"
         }
      },

       {
         id: "HEADER_ISMS",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_ISMS",
            label: "header.menu.isms.label",
            targetUrl: "site/isms/dashboard"
         }
      },

      {
         id: "HEADER_TASKS",
         name: "alfresco/header/AlfMenuBarPopup",
         config: {
            id: "HEADER_TASKS",
            label: "header.menu.tasks.label",
            widgets: [
               {  
                  name: "alfresco/menus/AlfMenuGroup",
                  config: {
                     widgets: [
                        {
                           id: "HEADER_MY_TASKS",
                           name: "alfresco/header/AlfMenuItem",
                           config:
                           {
                              id: "HEADER_MY_TASKS",
                              label: "header.menu.mytasks.label",
                              iconClass: "alf-mytasks-icon",
                              targetUrl: "my-tasks#filter=workflows|active"
                           }
                        },
                     ]
                  }
               }
            ]
         }
      },

   ];

      appItems.push({
         id: "HEADER_SITES_MENU",
         name: "alfresco/header/AlfSitesMenu",
         config: {
            id: "HEADER_SITES_MENU",
            label: "header.menu.sites.label",
            currentSite: page.url.templateArgs.site,
            currentUser: user.name
         }
      });


   //if (user.isAdmin || showRepositoryLink == "true")
//Added if condition so that only admin has permissions over repository
   if (user.isAdmin)
   {
      appItems.push({
         id: "HEADER_REPOSITORY",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_REPOSITORY",
            label: "header.menu.repository.label",
            targetUrl: "repository"
         }
      });
   }
   if (user.isAdmin)
   {
      appItems.push({
         id: "HEADER_ADMIN_CONSOLE",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_ADMIN_CONSOLE",
            label: "header.menu.admin.label",
            targetUrl: "console/admin-console/application"
         }
      });
   }
   else
   {
      appItems.push({
         id: "HEADER_ADMIN_CONSOLE",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_SITES_CONSOLE",
            label: "header.menu.admin.sites.label",
            targetUrl: "console/sites-console/manage-sites",
            renderFilter: [
               {
                  property: "user.groups.GROUP_SITE_ADMINISTRATORS",
                  values: [true]
               }
            ]
         }
      });
   }

   //help dropdown to iconnect users and managers

   appItems.push(   {
         id: "HEADER_HELP",
         name: "alfresco/header/AlfMenuBarPopup",
         config: {
            id: "HEADER_HELP",
            label: "Help",
            widgets: [
               {  
                  name: "alfresco/menus/AlfMenuGroup",
                  config: {
                     widgets: [
                        {
                           id: "HEADER_HELP_USER_MANUAL",
                           name: "alfresco/header/AlfMenuItem",
                           config:
                           {
                              id: "HEADER_HELP_USER_MANUAL",
                              label: "User-Manual",
                                targetUrl: "http://is-0548/iconnect/proxy/alfresco/api/node/content/workspace/SpacesStore/214378ac-4e1d-44fd-ae2...",
          targetUrlType: "FULL_PATH",
                          targetUrlLocation: "NEW"  
                             
                           }
                        },
                        {
                           id: "HEADER_HELP_MANGER_MANUAL",
                           name: "alfresco/header/AlfMenuItem",
                           config:
                           {
                              id: "HEADER_HELP_MANGER_MANUAL",
                              label: "Manager-Manual",
                              targetUrl: "http://is-0548/iconnect/proxy/alfresco/api/node/content/workspace/SpacesStore/91c54ade-90ad-4cfb-b7e...",
                   targetUrlType: "FULL_PATH",
                   targetUrlLocation: "NEW"  
                          
                           }
                        }
                     ]
                  }
               }
            ]
         }
      });
   return appItems;
}



as you can see i ahve added few menus and removed some for consumers like wise you can change the order of display of app-items

take a look the image i atached to see the changes in share-header

//mark this post useful if it solved your problem

nikes
Champ on-the-rise
Champ on-the-rise
Hi Malliswar,

Thanks for this feedback.

Actually I am able to do it without copying original share-header.lib.js.


I created extension module, and in that .js i did below,


Remove all header menus,
widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_SHARED_FILES");


Get reference of app header menu bar
var headerAppMenuBar = widgetUtils.findObject(model.jsonModel, "id", "HEADER_APP_MENU_BAR");

Add back required widgets,

testHeaderMenu.config.widgets.push({
         id: "HEADER_REPOSITORY",
         name: "alfresco/menus/AlfMenuBarItem",
         config: {
            id: "HEADER_REPOSITORY",
            label: "header.menu.repository.label",
            targetUrl: "repository"
         }
      });

testHeaderMenu.config.widgets.push({
         id: "HEADER_SITES_MENU",
         name: "alfresco/header/AlfSitesMenu",
         config: {
            id: "HEADER_SITES_MENU",
            label: "header.menu.sites.label",
            currentSite: page.url.templateArgs.site,
            currentUser: user.name
         }
      });


and so on..


-Nikesh

malliswar
Champ in-the-making
Champ in-the-making
hi Nikes,

         the way you did the changes to share header, reduces code redundency.

            thanks for sharing the solution.