Service Portal (Helsinki): How to prevent confirmation messages from disappearing after a few seconds.

artsupsiri
Tera Contributor

I see the code in /scripts/js_includes_sp.jsx. I'd like to modify the function addNotification() in the Angular directive spNotifications so that non-trivial messages don't fade away.

Is there a way to change or extend the JavaScript?

1 ACCEPTED SOLUTION

artsupsiri
Tera Contributor

I discovered that decorating the directive spNotifications allows you to extend or overwrite the directive any way you want. In this case, I overrode two controller functions:



/* Override spNotificationsDirective controller */



angular.module('sn.$sp').config(function($provide) {


  $provide.decorator('spNotificationsDirective', function($delegate, $controller) {


    var directive = $delegate[0];



    var controllerName = directive.controller;


    directive.controller = function($scope) {


    var controller = $controller(controllerName, {$scope: $scope});



    // Override functions getMilliSeconds and areTrivial


 


    controller.getMilliSeconds = function() {


    var seconds = (areTrivial(controller.notifications)) ? 10 : 3000;


    return seconds * 1000;


    };



    function areTrivial(input) {


    return input.length >= 1 && input.every(function(item) {


    return item && item.type === 'trivial';


    });


    }



    return controller;


    };



    return $delegate;


  });


});


View solution in original post

12 REPLIES 12

Where are you doing this?


Mihir Mohanta
Kilo Sage

Hi,



Can you describe some more briefly where you have added the script to prevent info message disapearing in few seconds.



I have added the script in client controller of "SC Catalog Item" but it is not working.


Mihir,



Try placing the code into a new UI Script. Create a JS include for the Service Portal Theme you're using, set the Source to "UI Script", and select the UI script you created.


david_hreben
Giga Expert

Hello Artsupsiri,

Where in the Service Portal would you add that code? Thanks!

Try placing the code into a new UI Script. Create a JS include for the Service Portal Theme you're using, set the Source to "UI Script", and select the UI script you created.