Remove Favorites - SC / RO
Dear All,
I would like to do the following:
Remove the favorites from the Service Catalog / Request offering.
Set it so that when someone clicks on the picture (icon) and text of a item on the Service Catalog it opens up a request offering.
Can anyone help me with this?
Daniel
Answers
Hi @CaterhamITSupport
I am not sure I am following, because this sounds like the other thread you posted for removing the favourites button!
Can you share a screenshot of where you are referring to?
Thanks,
Shane
Hi Shane/Justin,
You both are right and i can see what you mean now.
My only issue with this is that it shows for a second then goes still.
Dependent on the form and how much is on there as well.
I set it to 500 at the moment, do you have any other ways of doing this?
Daniel
sorry comment above is for another.
Hi Shane,
Here is a picture attached, so I wanted to disable the favorites and icon. Also wanted when you click on the icon it opens the request offering.
Daniel
Hi Shane,
I tried the following code and the clicking on icon doesnt work:
$(document).ready(function(){
//Since this uses a mutationobserver against a guaranteed-to-exist object, make sure we are only on the Home alternate page.
if (document.URL.indexOf("/View/02efdc70-55c7-4ba8-9804-ca01631c1a54") === -1) {
return;
}
//The service catalog and request offerings don't load immediately. So wait until it does load.
var mainPageNode = document.getElementById('main_wrapper');
// create an observer instance
var observer = new MutationObserver(function(mutations) {
//The page changed. See if any RO descriptions exist yet.
var titleElements = $(".sc-item-title");
if (titleElements.length > 0) {
fn_SetRequestOfferingImagesToOpenROs();
observer.disconnect();
}
});
// configure the observer. For our purposes, subtree is required.
var observerConfig = { attributes: true, childList: true, subtree: true, characterData: true };
// pass in the node, and our mutationobserver options.
observer.observe(mainPageNode, observerConfig);
//Create the function to add our click event.
function fn_SetRequestOfferingImagesToOpenROs() {
//hide all star icons so that you cannot set favorites. This would interfere with clicking on the request offering images.
var favoriteIconElements = $('.fa-star-o');
favoriteIconElements.hide();
function clickChildRequestOffering(event) {
console.log("clicked!");
var parentAElement = event.target;
//call the click event of the child img element.
var childImgElement = $(parentAElement).find("img")
childImgElement.click();
};
//For every icon, there's a sibling img element. Get it since it contains our click() event, which opens up the RO. We need to apply this to the parent <a>.
for (var i = 0; i < favoriteIconElements.length; i++) {
var siblingImgElement = $(favoriteIconElements[i]).parent().find("img")
var parentAElement = siblingImgElement.parent();
//Add our custom event to our img element, which will just end up calling the click event of the child <i>
parentAElement.click(clickChildRequestOffering);
//Change the hover event on this sibling img element.
parentAElement.css('cursor', 'pointer');
}
}
});
Any further help with this?