Customize Menu tree to remove a tab

We can customize the menu tree to remove , add and rename the tabs in the tree.

We are here adding the code to remove the “Existing Request” tab from the menu tree

	_.extend(MenuTreeView.prototype, {
					//This view is extended to hide existing request from the support section.
					getContext: _.wrap(MenuTreeView.prototype.getContext, function (fn) {
						try {
							var original = fn.apply(this, _.toArray(arguments).slice(1));
							var restrictExistingRequest =SC.CONFIGURATION.get('Restrict Existing Requests in support');
							if(restrictExistingRequest === true){
								var menuItem = original.menuItems;
								for (let i = 0; i < menuItem.length; i++) {
									//console.log("menuItem[i].name", menuItem[i].name);
									if (menuItem[i].id === "cases") {
										if (menuItem[i].children && menuItem[i].children.length > 0) {
											for (let j = 0; j < menuItem[i].children.length; j++) {
												if (menuItem[i].children[j].name === 'Existing Requests') {
													menuItem[i].children.splice(j, 1); // Remove the item from the array
													break; // Exit the inner loop once found
												}
											}
										}
									}
								}
							}		
						} catch (e) {
							console.log("err@MenuTreeView", e);
						}
						return original;
					})
				});

Leave a comment

Your email address will not be published. Required fields are marked *