Switch the Widgets on click of tabs in Service Portal

anupraheja
Tera Expert

Switch the Widgets on click of tabs in Service Portal

I want to display close and open incident on same page. i created two widgets (Simple list with two in) one is for open incident and another is for close. Now i want only Open incident widget should be there when i clicked on open incident tab and close incident widget should be there when i clicked on close incident tab.

HTML Code:

<div class="container">

  <ul class="nav nav-pills">

      <li class="active"><a data-toggle="pill" href="#home">Open Incident</a></li>

      <li><a data-toggle="pill" href="#menu1">Close Incident</a></li>    

  </ul>

  <div class="tab-content">

      <div id="home" class="tab-pane fade in active">

          <h3>Open Incident</h3>

          <p>Display Open Incident in simple List widget .</p>

      </div>

      <div id="menu1" class="tab-pane fade">

          <h3>Close Incident</h3>

          <p>   Display Close Incident in simple List widget   </p>

      </div>

  </div>

</div>


Tab.PNG

Can any one help on this.

Thanks in advance.

Best Regards,

Anup

4 REPLIES 4

Karina15
Giga Contributor

Hi Anup,



Were you able to resolve this?



Thank you.


Karina


Hi Karina,
Yes,i was able to do that. Let me know if need any help.



Thank you.
Anup Raheja





HTML


<!-- your widget template -->


  <div class=" pill-background row">


      <div class="enlpill" ng-class="{'active':c.selectedPill == 'myhrc'}" ng-click="selectPill('myhrc')">


          <p class="remove-margin">${My HR Cases}</p>


      </div>      


    <div class="enlpill" ng-class="{'active':c.selectedPill == 'mydoc'}" ng-click="selectPill('mydoc')">


          <p class="remove-margin">${My Documents}</p>


      </div>


  </div>


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Client script


function($rootScope,$scope,$timeout,$window,$location) {


                              var c = this;


//check value of data.parm then call selectedPill to have correct tab display.                                                              


                              switch($scope.data.parm)


                                                              {


case "myhrc":


                                                                                              c.selectedPill = "myhrc";


                                                                                              break;



                                                                                              case "mydoc":


                                                                                              c.selectedPill = "mydoc";


                                                                                              break;



                                                                                              default:


                                                                                              c.selectedPill = "myhrc";


                                                                                              break;


                                                              }


                              /*broadcast to other widgets after waiting for 500 milliseconds,


    just to make sure other widgets are loaded and ready to listen when we broadcast.         */          


                                                              $timeout(function(){


                                                              $rootScope.$broadcast('showHideWidget', $scope.data.parm);


                              },500);



                              //broadcast the selection when ever cliked on each pill


                              $scope.selectPill = function(selection){


                                                              c.selectedPill = selection;


                                                              $rootScope.$broadcast('showHideWidget', selection);


                              };


                              $rootScope.$on('showHideWidget', function(event,data) {


                                                              $timeout(function(){


                                                                                              $scope.showWidgetc = data;


                                                                                              c.selectedPill = data;


                                                              });


                              });


                              $rootScope.$on('showHideWidgetbrgp', function(event,data) {


                                                              $timeout(function(){


                                                                                              $scope.showWidgetc = data;


                                                                                              c.selectedPill = data;


                                                              });


                              });


}



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Server Script


(function() {


  /* populate the 'data' object */


                              //check if url contains the tab parameter.   If no, set data.parm to myhrc tab as default tab, else, set data.parm to value of parameter.


                              if($sp.getParameter('tab') != '' && $sp.getParameter('tab') != null)


                                                              {


                                                                                              data.parm = $sp.getParameter('tab');


                                                              }


                              else


                                                              {


                                                                                              data.parm = myhrc;


                                                              }


})();


Hi Anup,



Thank you for your prompt answer. I'm working on the prototypes. Once they are approved, I will give it a try and let you know if I need help.



Thanks again.


Karina


Gurpreet07
Mega Sage

If you are still looking for the solution then please go through below Blog post



Service Portal - Tabbed List Widget ( Hi Portal - My Issues ) (Up to 5 tabs supported)