How to hide Attachment tab in task type activity while showing my own case attachment tab or in general how can i programmatically hide a toggle tab in freedom ui .
I want to hide the attachment toggle tab and show case attachment which is created by be , also want to programmatically trigger their visibility , please refer below image for reference
Like
I was able to achieve this using only DOM. To do this - two buttons were created: clicking the first button will trigger the usr.HideButtonRequest request, clicking the second button will trigger the usr.ShowAttachmentsRequest. Here is the code of schema handlers:
handlers: /**SCHEMA_HANDLERS*/[ { request: "usr.HideButtonRequest", handler: async (request, next) => { let savedAttachmentsElement = document.querySelectorAll('[data-item-marker="Attachments"]')[0]; request.$context.AttachmentToggleItem = savedAttachmentsElement; request.$context.AttachmentToggleItemParentNode = savedAttachmentsElement.parentNode; savedAttachmentsElement.parentNode.removeChild(savedAttachmentsElement); return next?.handle(request); } }, { request: "usr.ShowAttachmentsRequest", handler: async (request, next) => { let attachmentToggleContainer = request.$context.AttachmentToggleItemParentNode; let attachmentsToogleItem = request.$context.AttachmentToggleItem; attachmentToggleContainer.appendChild(attachmentsToogleItem); return next?.handle(request); } }, ]/**SCHEMA_HANDLERS*/,
And also two attributes were added to the viewModelConfig property of the schema (in case you don't have it in the schema - create it):
viewModelConfig: { attributes: { "AttachmentToggleItem": {}, "AttachmentToggleItemParentNode": {} } },
As a result the "Attachments" toggle item is removed when the first button is clicked and then displayed when the second button is clicked. What is left to be done is add and test this approach with handlers like HandleViewModelAttributeChangeRequest.