controls/script-tags-remove-modal.ps1

function New-RemoveScriptTagModal 
{
    param (
        [Parameter(Mandatory = $true)]
        $Tag,
        $Script
    
    )

    
    Show-UDModal -Content {
        if (!$Script -or $Script -eq "" -or $null -eq $Script) { $isScriptTag = $false }else { $isScriptTag = $true }
        
        if($isScriptTag -eq $true)
        {
            New-UDPageHeader -Text ("Removing Tag: $($Tag.Name) from $($Script.Name)")
            New-UDParagraph -Text "Are you sure you wish to remove this Tag from the Script?"
        }
        else {
            New-UDPageHeader -Text ("Removing Tag: $($Tag.Name)")
            New-UDParagraph -Text "Are you sure you wish to remove this Tag?"
        }
              
        
        New-UDElement -Tag div -Attributes @{
            style = @{
                textAlign = "right"
            }
        } -Content {
        
            New-UDButton -Text "Confirm" -Icon check -OnClick {
                if(!$Script)
                {
                    Remove-UATag -Tag $Tag
                }
                else {
                    Remove-UAScriptTag -Script $Script -Tag $Tag    
                }
                
                Sync-UDElement -Id "ScriptsGrid" -Broadcast
                Sync-UDElement -Id "ScriptPageHeader" -Broadcast
                Sync-UDElement -Id "ScriptPageTagDiv" -Broadcast
                Sync-UDElement -Id "TagGrid" -Broadcast
                Hide-UDModal
            }

        }

    } -Width '50%'

}