User preferences for dashboard entries location


Problem Statement :

Dashboards are intended to give business critical information to the User. When a User has more than one Dashboard entries then he/she may like to have a particular Dashboard item in a particular place on the landing page.

For Example,  one executive in a company prefers to have “Invoice Dashboard” as a first entry, “Purchase Dashboard”as a second entry just below the “Invoice Dashboard”. But Another Executive may want to see Invoice Dashboard and Purchase Dashboard side by side. That means Every User may change (drag and drop) Dashboard item’s locations. These locations should be saved and applicable only to Current User, who dragged and dropped Dashboard on Desktop. It becomes easy to set Dashboards locations according to User interest.

This functionality is not implicitly supported by ADempiere. But having this functionality will improve end user experience with application in a significant way.

Scope of This Article :

In this article we will learn how User can define place of his/her Dashboard entries in application desktop. We assume that Custom Dashboards are already created in System and We will discuss about how to place these Dashboards permanently on Desktop according to User choice .

Example :

In a any business,  we have Sales,Purchase Orders, Invoices, Contacts,etc. The Dashboard entries are displayed according to user interest and user can arrange Dashboards in a particular place as shown below.

DashboardExample

In this diagram User One and User Two have arranged their Dashboards items according to their interest.

User One can also change the order of Sales Dashboard, Partners Dashboard, Stock Dashboard to Partners Dashboard, Stock Dashboard, Sales Dashboard. So whenever the User One logins into the application, the Dashboards will be visible in Partners Dashboard, Stock Dashboard, Sales Dashboard order.

Similarly, the User Two can also change the order of his/her Dashboards by drag and drop and these changes will be saved automatically. The saved changes will be available during subsequent access to the application.

Changes:

  1. To achieve this functionality in Adempiere we need to make code changes in the following files
    • DefaultDesktop.java

      /*
      * 1823
      * Catch the Portal Move and perform the next required steps.
      */
      else if(eventName.equals(“onPortalMove”))
      {
      if (comp instanceof Portallayout) {
      PortalMoveEvent portalMoveEvent = (PortalMoveEvent) event;
      Portallayout layout = (Portallayout) comp;
      Portalchildren from = portalMoveEvent.getFrom();
      Portalchildren to = portalMoveEvent.getTo();
      /*
      * Do not allow to drag if source and Destination items have different
      * width. This logic is not required, Draggable false logic works properly
      * ZK 3.6 has bug, so we need to have this logic.
      */
      if( !from.getWidth().equalsIgnoreCase(to.getWidth())){
      FDialog.error(1, “DRAG_NOT_ALLOWED”);
      /*
      * As Items are already moved in Dashboard, reload the dashboard
      */
      initDashboard();
      return;
      }
      Panel panel = portalMoveEvent.getDragged();
      int contentID = Integer.parseInt(panel.getId());
      MUserDashBoard content = new MUserDashBoard(Env.getCtx(),
      contentID, null);
      int oldRow = content.getColumnNo();

      int row = portalLayout.getPosition(panel)[1]+1;
      String toIDString = to.getId();
      BigDecimal toID = new BigDecimal(toIDString);
      toID = toID.setScale(0);
      String fromIDString = from.getId();
      BigDecimal fromID = new BigDecimal(fromIDString);
      fromID = fromID.setScale(0);
      int userId = Env.getAD_User_ID(Env.getCtx());

      /*
      * If Source and Destination Panel Childrens are same then you
      * just need to update the order of Rendering, else you need to
      * update the Panel Parent as well as the order of the rendering
      */
      boolean next= true;

      if (from != to) {
      content.setLine(toID);
      next = true;
      content.save();
      /*
      * Rearrnage the panels Source Portal Children
      */
      MUserDashBoard[] panels = MUserDashBoard.getNextPanels(userId,
      fromID, oldRow,contentID,next);
      for (int i = 0; i < panels.length; i++) {

      panels[i].setColumnNo(oldRow++);

      panels[i].save();
      }

      }
      else{
      if (oldRow <= row){
      next = false;
      }
      else{
      next = true;

      }
      }

      content.setColumnNo(row);
      content.save();
      /*
      * Rearrnage the panels Destination Portal Children
      */
      MUserDashBoard[] panels = MUserDashBoard.getNextPanels(userId,
      toID, row,contentID,next);
      // int rowCopy = row;
      for (int i = 0; i < panels.length; i++) {

      if (next == true){

      panels[i].setColumnNo(++row);

      }else{

      panels[i].setColumnNo(–row);

      }
      panels[i].save();
      }

      }
      }

    • MDashboardContent.java

      protected boolean afterSave (boolean newRecord, boolean success)
      {

      if (newRecord) // Add to all automatic roles
      {

      MUser[] users = MUser.getOf(getCtx(), null,this.get_TrxName());
      for (int i = 0; i < users.length; i++)
      {
      MUserDashBoard udb = new MUserDashBoard(this, users[i].getAD_User_ID());
      udb.save();
      }

      }
      return success;
      } // afterSave

  2. Make following DB changes
    • Add new tables PA_User_DashBoard to persist user preferences
    • Make changes in PA_DashBoardContent to store generic preferences

   Detail :

  1. Login with Santhi and change the order of Santhi’s Dashboards SanthiLogin
  2. Look at Santhi’s Default Dashboards order in following screen.SanthiDashboard
  3. Now “Santhi” wants to arrange Dashboards according to her interest by drag and drop of Dashboards. She moved Invoice Dashboard to Top and Purchase Dashboard to bottom.SanthiDBPrefernceChange
  4. Log-out and login with Same user to check Dashboard locations, whether they are visible in modified locations or default locations.SanthiRelogin
  5. Dashboards are visible in new locations to Santhi. Check following screen.SanthiReloginDashboard
  6. Now login with another User into System.TarunLogin
  7. Tarun is able to see by default both Dashboards are side-by-side.TarunDefaultDashboard
  8. Now “Tarun” has been changed the Dashboard locations.TarunDBPreference
  9. Log-out and login with Same user to check Dashboard locations, whether they are visible in modified locations or default locations.TarunRelogin
  10. Now Tarun is able to see Dashboards in new locations according to his need.TarunReloginDashboard

Summary:

As a part of this article we learned about how End User can change the Dashboard’s display order permanently on desktop according to User interest from one location to another location at any time. It gives more flexibility to Users to change the Order.

Walking Tree promotes Adempiere and we support the users as well as the developers to ensure that the business is able to take complete advantage of Adempiere’s wonderful capability. In case you are looking for a professional assistance then do visit our website to get in touch with us.

References:

  1. http://www.adempiere.com/ManPageW_DashboardContentEdit
  2. http://www.zkoss.org/zkdemo/layout/business_portal
Tagged with: , , ,
Posted in ADempiere, EagleRP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Recent Publication
%d bloggers like this: