From 2c92abcf561ab8a00bf6a786de0361561aaae01a Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 01/15] Revert "Update" This reverts commit 3e79447859d4674121bc90828c46107fb571b62e. --- Examples/Example32-Gage/Example32-01.html | 143 +++++++++++----------- Private/Parameters.Configuration.ps1 | 9 +- 2 files changed, 77 insertions(+), 75 deletions(-) diff --git a/Examples/Example32-Gage/Example32-01.html b/Examples/Example32-Gage/Example32-01.html index 0aade6b3..db592bcd 100644 --- a/Examples/Example32-Gage/Example32-01.html +++ b/Examples/Example32-Gage/Example32-01.html @@ -1,6 +1,6 @@  -This is a test
IdNamePriorityClassProductVersionCompanyPathDescription
245521PasswordNormal7.6.780AgileBits Inc.C:\Users\przemyslaw.klys\AppData\Local\1password\app\7\1Password.exe1Password for Windows desktop
4308aesm_service
7756ApplicationFrameHostNormal10.0.19041.1Microsoft CorporationC:\WINDOWS\system32\ApplicationFrameHost.exeApplication Frame Host
23696AppVShNotify
39292AppVShNotifyNormal5.2.158.0Microsoft CorporationC:\Program Files\Common Files\Microsoft Shared\ClickToRun\AppVShNotify.exeAppVShNotify
6692armsvc
8340audiodg
1916browser_brokerNormal11.00.19041.1Microsoft CorporationC:\WINDOWS\system32\browser_broker.exeBrowser_Broker
39908CalculatorNormal10.2005.23.0Microsoft CorporationC:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.2005.23.0_x64__8wekyb3d8bbwe\Calculator.exeCalculator.exe
1528CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
9136CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
16756CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
25664CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
32800CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
34376CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37152CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37392CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
40184CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
2156CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
24524CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
245521PasswordNormal7.6.780AgileBits Inc.C:\Users\przemyslaw.klys\AppData\Local\1password\app\7\1Password.exe1Password for Windows desktop
4308aesm_service
7756ApplicationFrameHostNormal10.0.19041.1Microsoft CorporationC:\WINDOWS\system32\ApplicationFrameHost.exeApplication Frame Host
23696AppVShNotify
39292AppVShNotifyNormal5.2.158.0Microsoft CorporationC:\Program Files\Common Files\Microsoft Shared\ClickToRun\AppVShNotify.exeAppVShNotify
6692armsvc
8340audiodg
1916browser_brokerNormal11.00.19041.1Microsoft CorporationC:\WINDOWS\system32\browser_broker.exeBrowser_Broker
39908CalculatorNormal10.2005.23.0Microsoft CorporationC:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.2005.23.0_x64__8wekyb3d8bbwe\Calculator.exeCalculator.exe
1528CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
9136CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
16756CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
25664CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
32800CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
34376CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37152CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37392CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
40184CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
2156CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
24524CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
245521PasswordNormal7.6.780AgileBits Inc.C:\Users\przemyslaw.klys\AppData\Local\1password\app\7\1Password.exe1Password for Windows desktop
4308aesm_service
7756ApplicationFrameHostNormal10.0.19041.1Microsoft CorporationC:\WINDOWS\system32\ApplicationFrameHost.exeApplication Frame Host
23696AppVShNotify
39292AppVShNotifyNormal5.2.158.0Microsoft CorporationC:\Program Files\Common Files\Microsoft Shared\ClickToRun\AppVShNotify.exeAppVShNotify
6692armsvc
8340audiodg
1916browser_brokerNormal11.00.19041.1Microsoft CorporationC:\WINDOWS\system32\browser_broker.exeBrowser_Broker
39908CalculatorNormal10.2005.23.0Microsoft CorporationC:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.2005.23.0_x64__8wekyb3d8bbwe\Calculator.exeCalculator.exe
1528CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
9136CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
16756CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
25664CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
32800CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
34376CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37152CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
37392CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
40184CodeNormal1.47.3Microsoft CorporationC:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\Code.exeVisual Studio Code
2156CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
24524CodeHelperNormal1.0.0.0Microsoft Corporationc:\Users\przemyslaw.klys\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\platform\files\node\watcher\win32\CodeHelper.exeCodeHelper
IdNamePriorityClassProductVersionCompanyPathDescription
+} + ); + + + });
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
diff --git a/Examples/Example39-TableColumnOption/Example39_01.ps1 b/Examples/Example39-TableColumnOption/Example39_01.ps1 index 2efd285b..b3d36714 100644 --- a/Examples/Example39-TableColumnOption/Example39_01.ps1 +++ b/Examples/Example39-TableColumnOption/Example39_01.ps1 @@ -1,4 +1,4 @@ -Import-Module "$PSSCriptRoot\..\..\PSWriteHTML.psd1" -Force +Import-Module "$($PSSCriptRoot)\..\..\PSWriteHTML.psd1" -Force $Process = Get-Process | Select-Object -First 20 $ProcessesLimited = $Process | Select-Object -Property Id, Name, PriorityClass, ProductVersion, Company, Path, Description @@ -6,21 +6,21 @@ $ProcessesLimited = $Process | Select-Object -Property Id, Name, PriorityClass, New-HTML -TitleText 'My title' -Online -FilePath $PSScriptRoot\Example39_01.html { New-HTMLContent -HeaderText 'Test' { New-HTMLTable -DataTable $ProcessesLimited -PagingOptions @(5, 10, 50, 100) { - New-TableColumnOption -ColumnIndex 0, 1 -Hidden $false - New-TableColumnOption -AllColumns -Hidden $true + New-TableColumnOption -ColumnIndex 0,1 -Hidden $false + New-TableColumnOption -AllColumns -Hidden $true } } New-HTMLContent -HeaderText 'Test' { New-HTMLTable -DataTable $ProcessesLimited -PagingOptions @(5, 10, 50, 100) -DefaultSortColumn 'Id' { New-TableColumnOption -ColumnIndex (0..5) -Width 50 New-TableColumnOption -ColumnIndex 1 -Sortable $true - New-TableColumnOption -ColumnIndex 1, 3, 4 -Searchable $true + New-TableColumnOption -ColumnIndex 1,3,4 -Searchable $true New-TableColumnOption -AllColumns -Sortable $false -Searchable $false } } New-HTMLTable -DataTable $ProcessesLimited -DefaultSortIndex 0 -OrderMulti { - New-TableColumnOption -ColumnIndex 0 -Sortable $true + New-TableColumnOption -ColumnIndex 0 -Sortable $true New-TableColumnOption -AllColumns -Sortable $false } } -ShowHTML diff --git a/PSWriteHTML.psd1 b/PSWriteHTML.psd1 index 5b162625..08ff990f 100644 --- a/PSWriteHTML.psd1 +++ b/PSWriteHTML.psd1 @@ -3,7 +3,7 @@ # # Generated by: Przemyslaw Klys # -# Generated on: 27.07.2020 +# Generated on: 23.07.2020 # @{ @@ -12,7 +12,7 @@ RootModule = 'PSWriteHTML.psm1' # Version number of this module. - ModuleVersion = '0.0.90' + ModuleVersion = '0.0.89' # Supported PSEditions CompatiblePSEditions = 'Desktop', 'Core' @@ -51,7 +51,7 @@ # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @(@{ModuleName = 'PSSharedGoods'; GUID = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'; ModuleVersion = '0.0.161'; }) + RequiredModules = @(@{ModuleName = 'PSSharedGoods'; GUID = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'; ModuleVersion = '0.0.160'; }) # Assemblies that must be loaded prior to importing this module # RequiredAssemblies = @() @@ -92,9 +92,9 @@ 'New-HTMLTimelineItem', 'New-HTMLToast', 'New-HTMLTree', 'New-TableButtonCopy', 'New-TableButtonCSV', 'New-TableButtonExcel', 'New-TableButtonPageLength', 'New-TableButtonPDF', - 'New-TableButtonPrint', 'New-TableColumnOption', 'New-TableCondition', - 'New-TableContent', 'New-TableHeader', 'New-TableReplace', - 'New-TableRowGrouping', 'New-TreeNode', 'Out-HtmlView', 'Save-HTML' + 'New-TableButtonPrint', 'New-TableCondition', 'New-TableContent', + 'New-TableHeader', 'New-TableReplace', 'New-TableRowGrouping', + 'New-TreeNode', 'Out-HtmlView', 'Save-HTML' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() @@ -123,14 +123,13 @@ 'New-HTMLTableButtonPageLength', 'TableButtonPDF', 'EmailTableButtonPDF', 'New-HTMLTableButtonPDF', 'TableButtonPrint', 'EmailTableButtonPrint', 'New-HTMLTableButtonPrint', - 'EmailTableColumnOption', 'TableColumnOption', - 'New-HTMLTableColumnOption', 'EmailTableCondition', - 'TableConditionalFormatting', 'New-HTMLTableCondition', - 'TableCondition', 'TableContent', 'EmailTableContent', - 'New-HTMLTableContent', 'TableHeader', 'EmailTableHeader', - 'New-HTMLTableHeader', 'TableReplace', 'EmailTableReplace', - 'New-HTMLTableReplace', 'TableRowGrouping', 'EmailTableRowGrouping', - 'New-HTMLTableRowGrouping', 'Out-GridHtml', 'ohv' + 'EmailTableCondition', 'TableConditionalFormatting', + 'New-HTMLTableCondition', 'TableCondition', 'TableContent', + 'EmailTableContent', 'New-HTMLTableContent', 'TableHeader', + 'EmailTableHeader', 'New-HTMLTableHeader', 'TableReplace', + 'EmailTableReplace', 'New-HTMLTableReplace', 'TableRowGrouping', + 'EmailTableRowGrouping', 'New-HTMLTableRowGrouping', 'Out-GridHtml', + 'ohv' # DSC resources to export from this module # DscResourcesToExport = @() diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index 6e884115..a9befdc3 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -463,18 +463,18 @@ function New-HTMLTable { } # The table column options also adds to the columnDefs parameter - If ($TableColumnOptions.Count -gt 0) { - foreach ($_ in $TableColumnOptions) { + If ($TableColumnOptions.Count -gt 0) { + foreach ($_ in $TableColumnOptions) { $ColumnDefinitionList.Add($_) } } # If we have a column definition list defined, then set the columnDefs option - If ($ColumnDefinitionList.Count -gt 0) { + If ($ColumnDefinitionList.Count -gt 0) { $Options.columnDefs = $ColumnDefinitionList.ToArray() } - If ($DisableAutoWidthOptimization) { + If ($DisableAutoWidthOptimization) { $Options.autoWidth = $false } diff --git a/Public/New-TableColumnOption.ps1 b/Public/New-TableColumnOption.ps1 index 9895a481..5e5826ce 100644 --- a/Public/New-TableColumnOption.ps1 +++ b/Public/New-TableColumnOption.ps1 @@ -1,96 +1,97 @@ -function New-TableColumnOption { - <# - .SYNOPSIS - Allows for certain modification of options within DataTable's columnDefs parameter. You can set visibility, searchability, sortability, and width for specific columns - .DESCRIPTION - Allows for certain modification of options within DataTable's columnDefs parameter. - See: https://datatables.net/reference/option/columnDefs +<# +.SYNOPSIS + Allows for certain modification of options within DataTable's columnDefs parameter. You can set visibility, searchability, sortability, and width for specific columns +.DESCRIPTION + Allows for certain modification of options within DataTable's columnDefs parameter. + See: https://datatables.net/reference/option/columnDefs - New-HTMLTable has parameters for -ResponsivePriorityOrder and -ResponsivePriorityOrderIndex and these are set at a higher precedent than options specified here. - See the DataTable reference section for conflict resolution. + New-HTMLTable has parameters for -ResponsivePriorityOrder and -ResponsivePriorityOrderIndex and these are set at a higher precedent than options specified here. + See the DataTable reference section for conflict resolution. - The New-TableColumnOption cmdlet will add entries to the columnDefs parameter in the order in which the cmdlets are ordered. - If you use 2 or more New-TableColumnOption, the first cmdlet takes priority over the second cmdlet if they specify the same targets or overriding property values - With this in mind, you should almost always specify -AllColumns last, since that will take priority over any commands issued later + The New-TableColumnOption cmdlet will add entries to the columnDefs parameter in the order in which the cmdlets are ordered. + If you use 2 or more New-TableColumnOption, the first cmdlet takes priority over the second cmdlet if they specify the same targets or overriding property values + With this in mind, you should almost always specify -AllColumns last, since that will take priority over any commands issued later - .EXAMPLE - New-TableColumnOption -ColumnIndex (0..4) -Width 50 - The first 5 columns with have a width defined as 50, this may not be exact. - See: https://datatables.net/reference/option/columns.width - .EXAMPLE - New-TableColumnOption -ColumnIndex 0,1,2 -Hidden $false - New-TableColumnOption -ColumnIndex 1 -Sortable $true - New-TableColumnOption -AllColumns -Hidden $true -Searchable $false -Sortable $false - All columns will be hidden, not searchable, and not sortable - However, since there is a option specified higher up, the first 3 columns will be visible - Additionally the 2nd column will be sortable - .INPUTS - None. You cannot pipe objects to New-TableColumnOption - .OUTPUTS - PSCustomObject - .NOTES - The New-HTMLTable cmdlet has -ResponsivePriorityOrder and -ResponsivePriorityOrderIndex that also modifes the columnDefs option in DataTable - #> - [CmdletBinding(DefaultParameterSetName = 'ColumnIndex', SupportsShouldProcess = $false, PositionalBinding = $false, HelpUri = '', ConfirmImpact = 'Medium')] +.EXAMPLE + New-TableColumnOption -ColumnIndex (0..4) -Width 50 + The first 5 columns with have a width defined as 50, this may not be exact. + See: https://datatables.net/reference/option/columns.width +.EXAMPLE + New-TableColumnOption -ColumnIndex 0,1,2 -Hidden $false + New-TableColumnOption -ColumnIndex 1 -Sortable $true + New-TableColumnOption -AllColumns -Hidden $true -Searchable $false -Sortable $false + All columns will be hidden, not searchable, and not sortable + However, since there is a option specified higher up, the first 3 columns will be visible + Additionally the 2nd column will be sortable +.INPUTS + None. You cannot pipe objects to New-TableColumnOption +.OUTPUTS + PSCustomObject +.NOTES + The New-HTMLTable cmdlet has -ResponsivePriorityOrder and -ResponsivePriorityOrderINdex that also modifes the columnDefs option in DataTable +#> +function New-TableColumnOption { + [CmdletBinding(DefaultParameterSetName='ColumnIndex',SupportsShouldProcess=$false,PositionalBinding=$false,HelpUri = '',ConfirmImpact='Medium')] [Alias('EmailTableColumnOption', 'TableColumnOption', 'New-HTMLTableColumnOption')] [OutputType([PSCustomObject])] param( # Identifies specific columns that the properties should apply to - [Parameter(ParameterSetName = "ColumnIndex", Mandatory = $true)] + [Parameter(ParameterSetName="ColumnIndex", Mandatory = $true)] [ValidateNotNullOrEmpty()] [alias('Targets')] [int[]] $ColumnIndex, - # Uses the columnDef Target "_ALL" to indicate all columns / remaining columns - [Parameter(ParameterSetName = "AllColumns", Mandatory = $true)] + # Uses the columnDef Target "_ALL" to indicate all columns / remaining columns + [Parameter(ParameterSetName="AllColumns", Mandatory = $true)] [ValidateNotNullOrEmpty()] - [alias('AllTargets', 'TargetAll')] + [alias('AllTargets','TargetAll')] [switch] $AllColumns, - # Width for the column as a string - [Parameter(ParameterSetName = "ColumnIndex")] - [Parameter(ParameterSetName = "AllColumns")] + # Width for the column as a string + [Parameter(ParameterSetName="ColumnIndex")] + [Parameter(ParameterSetName="AllColumns")] [string] $Width, # Defines if a column is hidden. A hidden column can still be used by Conditional Formatting and can still be searchable - [Parameter(ParameterSetName = "ColumnIndex")] - [Parameter(ParameterSetName = "AllColumns")] + [Parameter(ParameterSetName="ColumnIndex")] + [Parameter(ParameterSetName="AllColumns")] [boolean]$Hidden, # Defines if a column is able to be searched - [Parameter(ParameterSetName = "ColumnIndex")] - [Parameter(ParameterSetName = "AllColumns")] + [Parameter(ParameterSetName="ColumnIndex")] + [Parameter(ParameterSetName="AllColumns")] [boolean]$Searchable, # Defines if a column can be sorted - [Parameter(ParameterSetName = "ColumnIndex")] - [Parameter(ParameterSetName = "AllColumns")] + [Parameter(ParameterSetName="ColumnIndex")] + [Parameter(ParameterSetName="AllColumns")] [boolean]$Sortable ) # Create a hashtable property $TableColumnOptionProperty = @{ - targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; + targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; } - # Check for the existence of parameters, if they are not null then we will set them in the properties - # IF they are null, we don't want to include any values by default - If ($null -ne $PSBoundParameters['Width']) { $TableColumnOptionProperty.width = $Width } - If ($null -ne $PSBoundParameters['Hidden']) { $TableColumnOptionProperty.visible = !$Hidden } - If ($null -ne $PSBoundParameters['Searchable']) { $TableColumnOptionProperty.searchable = $Searchable } - If ($null -ne $PSBoundParameters['Sortable']) { $TableColumnOptionProperty.orderable = $Sortable } - - + # Check for the existence of parameters, if they are not null then we will set them in the properties + # IF they are null, we don't want to include any values by default + If ($PSBoundParameters['Width'] -ne $null) { $TableColumnOptionProperty.width = $Width } + If ($PSBoundParameters['Hidden'] -ne $null) { $TableColumnOptionProperty.visible = !$Hidden } + If ($PSBoundParameters['Searchable'] -ne $null) { $TableColumnOptionProperty.searchable = $Searchable } + If ($PSBoundParameters['Sortable'] -ne $null) { $TableColumnOptionProperty.orderable = $Sortable } + + # Check that we just don't have the 'targets' set, if so, then we have properties and return a custom object - If ($TableColumnOptionProperty.Keys.Count -gt 1) { + If ($TableColumnOptionProperty.Keys.Count -gt 1) { [PSCustomObject] @{ Type = 'TableColumnOption' Output = [PSCustomObject]$TableColumnOptionProperty - } - } Else { + } + } + Else { Write-Warning "New-TableColumnOption did not have any additional arguments listed" } diff --git a/readme.md b/readme.md index 06c3ab65..b176b774 100644 --- a/readme.md +++ b/readme.md @@ -65,8 +65,6 @@ Dependencies: **PSSharedGoods**, **PSWriteColor** and **Connectimo** are only us ## Changelog -- 0.0.90 - 2020.07.27 - - Added `New-TableColumnOption` for `New-HTMLTable` - tnx zsoch [#138](https://github.com/EvotecIT/PSWriteHTML/pull/138) - 0.0.89 - 2020.07.23 - Fix for Tooltips in FullCalendar 5.1 - tnx smasterson [#137](https://github.com/EvotecIT/PSWriteHTML/pull/137) - 0.0.88 - 2020.07.21 From 753eb67187ae6232329f6437b9dd916fbc4e3515 Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 05/15] Revert "Updated example to use psd1 file" This reverts commit 60dbbfaeb4624e83f7c1785f5b59f04a2791bd43. --- Examples/Example39-TableColumnOption/Example39_01.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Example39-TableColumnOption/Example39_01.ps1 b/Examples/Example39-TableColumnOption/Example39_01.ps1 index b3d36714..336d859e 100644 --- a/Examples/Example39-TableColumnOption/Example39_01.ps1 +++ b/Examples/Example39-TableColumnOption/Example39_01.ps1 @@ -1,4 +1,4 @@ -Import-Module "$($PSSCriptRoot)\..\..\PSWriteHTML.psd1" -Force +Import-Module "$($PSSCriptRoot)\..\..\PSWriteHTML.psm1" -Force $Process = Get-Process | Select-Object -First 20 $ProcessesLimited = $Process | Select-Object -Property Id, Name, PriorityClass, ProductVersion, Company, Path, Description From 347c056b6b7949da3ea0d19cf09bdd73b7be7e9d Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 06/15] Revert "Reworked cmdlet, added additional documentation, optimized column definitions" This reverts commit ddafb44e28a26a9114517a07d46b3795dd50fca8. --- .../Example39_01.html | 569 ------------------ .../Example39_01.ps1 | 22 +- Public/New-HTMLTable.ps1 | 41 +- Public/New-HTMLTableColumnOption.ps1 | 62 ++ Public/New-TableColumnOption.ps1 | 98 --- 5 files changed, 91 insertions(+), 701 deletions(-) delete mode 100644 Examples/Example39-TableColumnOption/Example39_01.html create mode 100644 Public/New-HTMLTableColumnOption.ps1 delete mode 100644 Public/New-TableColumnOption.ps1 diff --git a/Examples/Example39-TableColumnOption/Example39_01.html b/Examples/Example39-TableColumnOption/Example39_01.html deleted file mode 100644 index f99acf08..00000000 --- a/Examples/Example39-TableColumnOption/Example39_01.html +++ /dev/null @@ -1,569 +0,0 @@ - - -My title
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
IdNamePriorityClassProductVersionCompanyPathDescription
166447zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
180687zFMNormal16.04Igor PavlovC:\Program Files\7-Zip\7zFM.exe7-Zip File Manager
3956agent_ovpnconnect_1559309046710
4240app_updater
3940armsvc
24284audiodg
224BitTitanDMAExecutor
5920BitTitanDMAExecutor
6252BitTitanDMAMachineHealthCheck
4100BitTitanDMAService
228BitTitanDMASoftwareHealthCheck
4404capiws
2008Cca
5608chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
7536chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
9936chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12144chromeAboveNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
12188chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15632chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
15900chromeNormal84.0.4147.89Google LLCC:\Program Files (x86)\Google\Chrome\Application\chrome.exeGoogle Chrome
IdNamePriorityClassProductVersionCompanyPathDescription
diff --git a/Examples/Example39-TableColumnOption/Example39_01.ps1 b/Examples/Example39-TableColumnOption/Example39_01.ps1 index 336d859e..70dde7fa 100644 --- a/Examples/Example39-TableColumnOption/Example39_01.ps1 +++ b/Examples/Example39-TableColumnOption/Example39_01.ps1 @@ -1,26 +1,24 @@ Import-Module "$($PSSCriptRoot)\..\..\PSWriteHTML.psm1" -Force $Process = Get-Process | Select-Object -First 20 -$ProcessesLimited = $Process | Select-Object -Property Id, Name, PriorityClass, ProductVersion, Company, Path, Description New-HTML -TitleText 'My title' -Online -FilePath $PSScriptRoot\Example39_01.html { New-HTMLContent -HeaderText 'Test' { - New-HTMLTable -DataTable $ProcessesLimited -PagingOptions @(5, 10, 50, 100) { - New-TableColumnOption -ColumnIndex 0,1 -Hidden $false - New-TableColumnOption -AllColumns -Hidden $true + New-HTMLTable -DataTable $Process -PagingOptions @(5, 10, 50, 100) { + New-HTMLTableColumnOption -ColumnIndex 0 -Visible + New-HTMLTableColumnOption -AllColumns -Hidden } } New-HTMLContent -HeaderText 'Test' { - New-HTMLTable -DataTable $ProcessesLimited -PagingOptions @(5, 10, 50, 100) -DefaultSortColumn 'Id' { - New-TableColumnOption -ColumnIndex (0..5) -Width 50 - New-TableColumnOption -ColumnIndex 1 -Sortable $true - New-TableColumnOption -ColumnIndex 1,3,4 -Searchable $true - New-TableColumnOption -AllColumns -Sortable $false -Searchable $false + New-HTMLTable -DataTable $Process -PagingOptions @(5, 10, 50, 100) -DefaultSortColumn 'PriorityClass' { + New-HTMLTableColumnOption -ColumnIndex (0..1) -Width 50 -Visible + New-HTMLTableColumnOption -ColumnIndex (2..3) -Width 300 -Visible -DisableSearch + New-HTMLTableColumnOption -AllColumns -Hidden } } - New-HTMLTable -DataTable $ProcessesLimited -DefaultSortIndex 0 -OrderMulti { - New-TableColumnOption -ColumnIndex 0 -Sortable $true - New-TableColumnOption -AllColumns -Sortable $false + New-HTMLTable -DataTable $Process -DefaultSortIndex 0 -OrderMulti { + New-HTMLTableColumnOption -ColumnIndex 0 -EnableOrdering -DisableSearch + New-HTMLTableColumnOption -AllColumns -DisableOrdering } } -ShowHTML diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index a9befdc3..4c023645 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -58,7 +58,7 @@ function New-HTMLTable { [alias('RegularExpression')][switch]$SearchRegularExpression, [ValidateSet('normal', 'break-all', 'keep-all', 'break-word')][string] $WordBreak = 'normal', [switch] $AutoSize, - [switch] $DisableAutoWidthOptimization, + [switch] $DisableAutoSizeOptimization, [string] $Title ) if (-not $Script:HTMLSchema.Features) { @@ -78,9 +78,6 @@ function New-HTMLTable { $ContentFormattingInline = [System.Collections.Generic.List[PSCustomObject]]::new() $ReplaceCompare = [System.Collections.Generic.List[System.Collections.IDictionary]]::new() $TableColumnOptions = [System.Collections.Generic.List[PSCustomObject]]::new() - - # This will be used to store the colulmnDef option for the datatable - $ColumnDefinitionList = [System.Collections.Generic.List[PSCustomObject]]::New() $RowGrouping = @{ } if ($HTML) { @@ -447,34 +444,34 @@ function New-HTMLTable { foreach ($_ in $ResponsivePriorityOrder) { $Index = [array]::indexof($HeaderNames.ToUpper(), $_.ToUpper()) if ($Index -ne -1) { - [pscustomobject]@{ responsivePriority = 0; targets = $Index } + @{ responsivePriority = 0; targets = $Index } } } foreach ($_ in $ResponsivePriorityOrderIndex) { - [pscustomobject]@{ responsivePriority = 0; targets = $_ } + @{ responsivePriority = 0; targets = $_ } } ) - - foreach ($_ in $PriorityOrderBinding) { - $PriorityOrder++ - $_.responsivePriority = $PriorityOrder - $ColumnDefinitionList.Add($_) - } + $Options.columnDefs = @( + foreach ($_ in $PriorityOrderBinding) { + $PriorityOrder++ + $_.responsivePriority = $PriorityOrder + $_ + } + ) } - # The table column options also adds to the columnDefs parameter If ($TableColumnOptions.Count -gt 0) { - foreach ($_ in $TableColumnOptions) { - $ColumnDefinitionList.Add($_) + If ($Options.columnDefs) { + foreach ($_ in $TableColumnOptions) { + $Options.columnDefs += $_ + } + } + else { + $Options.columnDefs = @( foreach($_ in $TableColumnOptions) { $_ }) } } - - # If we have a column definition list defined, then set the columnDefs option - If ($ColumnDefinitionList.Count -gt 0) { - $Options.columnDefs = $ColumnDefinitionList.ToArray() - } - - If ($DisableAutoWidthOptimization) { + + If ($DisableAutoSizeOptimization) { $Options.autoWidth = $false } diff --git a/Public/New-HTMLTableColumnOption.ps1 b/Public/New-HTMLTableColumnOption.ps1 new file mode 100644 index 00000000..a725bf48 --- /dev/null +++ b/Public/New-HTMLTableColumnOption.ps1 @@ -0,0 +1,62 @@ +function New-TableColumnOption { + [alias('EmailTableColumnOption', 'TableColumnOption', 'New-HTMLTableColumnOption')] + [CmdletBinding()] + param( + [alias('Targets')][int[]]$ColumnIndex, + [alias('TargetAll')][switch]$AllColumns, + [string]$Width, + [switch]$Visible, + [switch]$Hidden, + [alias('EnableSorting')][switch]$EnableOrdering, + [alias('DisableSorting')][switch]$DisableOrdering, + [switch]$DisableSearch, + [switch]$EnableSearch + ) + + If ($PSBoundParameters.ContainsKey('AllColumns') -and $PSBoundParameters.ContainsKey('ColumnIndex')) { + throw "You cannot specify -AllColumns and -ColumnIndex inside the same TableColumnOption" + } + If (!$PSBoundParameters.ContainsKey('AllColumns') -and !$PSBoundParameters.ContainsKey('ColumnIndex')) { + throw "You must specify either -AllColumns or -ColumnIndex inside the TableColumnOption" + } + + $TableColumnOption = $null + + # Create a hashtable property + $TableColumnOptionProperty = @{ + targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; + } + + If ($Width) { $TableColumnOptionProperty['width'] = $Width } + + If ($Visible) { $TableColumnOptionProperty['visible'] = $true } + if ($Hidden) { + If ($Visible) { Write-Warning 'New-HTMLTableColumnOption - Hidden overrides Visible' } + $TableColumnOptionProperty['visible'] = $false + } + + If ($EnableOrdering) { $TableColumnOptionProperty['orderable'] = $true } + if ($DisableOrdering) { + If ($EnableOrdering) { + Write-Warning 'New-HTMLTableColumnOption - Disabling ordering orverrides enabling ordering.' + } + $TableColumnOptionProperty['orderable'] = $false + } + if ($EnableSearch) { $TableColumnOptionProperty['searchable'] = $true } + if ($DisableSearch) { + If ($EnableSearch) { + Write-Warning 'New-HTMLTableColumnOption - Disabling search overrides enabling search' + } + $TableColumnOptionProperty['searchable'] = $false + } + + # Check if we have properties set + If ($TableColumnOptionProperty.Keys.Count -gt 1) { + $TableColumnOption = [PSCustomObject]$TableColumnOptionProperty + } + + [PSCustomObject] @{ + Type = 'TableColumnOption' + Output = $TableColumnOption + } +} diff --git a/Public/New-TableColumnOption.ps1 b/Public/New-TableColumnOption.ps1 deleted file mode 100644 index 5e5826ce..00000000 --- a/Public/New-TableColumnOption.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -<# -.SYNOPSIS - Allows for certain modification of options within DataTable's columnDefs parameter. You can set visibility, searchability, sortability, and width for specific columns -.DESCRIPTION - Allows for certain modification of options within DataTable's columnDefs parameter. - See: https://datatables.net/reference/option/columnDefs - - New-HTMLTable has parameters for -ResponsivePriorityOrder and -ResponsivePriorityOrderIndex and these are set at a higher precedent than options specified here. - See the DataTable reference section for conflict resolution. - - The New-TableColumnOption cmdlet will add entries to the columnDefs parameter in the order in which the cmdlets are ordered. - If you use 2 or more New-TableColumnOption, the first cmdlet takes priority over the second cmdlet if they specify the same targets or overriding property values - With this in mind, you should almost always specify -AllColumns last, since that will take priority over any commands issued later - -.EXAMPLE - New-TableColumnOption -ColumnIndex (0..4) -Width 50 - The first 5 columns with have a width defined as 50, this may not be exact. - See: https://datatables.net/reference/option/columns.width -.EXAMPLE - New-TableColumnOption -ColumnIndex 0,1,2 -Hidden $false - New-TableColumnOption -ColumnIndex 1 -Sortable $true - New-TableColumnOption -AllColumns -Hidden $true -Searchable $false -Sortable $false - All columns will be hidden, not searchable, and not sortable - However, since there is a option specified higher up, the first 3 columns will be visible - Additionally the 2nd column will be sortable -.INPUTS - None. You cannot pipe objects to New-TableColumnOption -.OUTPUTS - PSCustomObject -.NOTES - The New-HTMLTable cmdlet has -ResponsivePriorityOrder and -ResponsivePriorityOrderINdex that also modifes the columnDefs option in DataTable -#> -function New-TableColumnOption { - [CmdletBinding(DefaultParameterSetName='ColumnIndex',SupportsShouldProcess=$false,PositionalBinding=$false,HelpUri = '',ConfirmImpact='Medium')] - [Alias('EmailTableColumnOption', 'TableColumnOption', 'New-HTMLTableColumnOption')] - [OutputType([PSCustomObject])] - param( - # Identifies specific columns that the properties should apply to - [Parameter(ParameterSetName="ColumnIndex", Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [alias('Targets')] - [int[]] - $ColumnIndex, - - # Uses the columnDef Target "_ALL" to indicate all columns / remaining columns - [Parameter(ParameterSetName="AllColumns", Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [alias('AllTargets','TargetAll')] - [switch] - $AllColumns, - - # Width for the column as a string - [Parameter(ParameterSetName="ColumnIndex")] - [Parameter(ParameterSetName="AllColumns")] - [string] - $Width, - - # Defines if a column is hidden. A hidden column can still be used by Conditional Formatting and can still be searchable - [Parameter(ParameterSetName="ColumnIndex")] - [Parameter(ParameterSetName="AllColumns")] - [boolean]$Hidden, - - # Defines if a column is able to be searched - [Parameter(ParameterSetName="ColumnIndex")] - [Parameter(ParameterSetName="AllColumns")] - [boolean]$Searchable, - - # Defines if a column can be sorted - [Parameter(ParameterSetName="ColumnIndex")] - [Parameter(ParameterSetName="AllColumns")] - [boolean]$Sortable - ) - - # Create a hashtable property - $TableColumnOptionProperty = @{ - targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; - } - - # Check for the existence of parameters, if they are not null then we will set them in the properties - # IF they are null, we don't want to include any values by default - If ($PSBoundParameters['Width'] -ne $null) { $TableColumnOptionProperty.width = $Width } - If ($PSBoundParameters['Hidden'] -ne $null) { $TableColumnOptionProperty.visible = !$Hidden } - If ($PSBoundParameters['Searchable'] -ne $null) { $TableColumnOptionProperty.searchable = $Searchable } - If ($PSBoundParameters['Sortable'] -ne $null) { $TableColumnOptionProperty.orderable = $Sortable } - - - # Check that we just don't have the 'targets' set, if so, then we have properties and return a custom object - If ($TableColumnOptionProperty.Keys.Count -gt 1) { - [PSCustomObject] @{ - Type = 'TableColumnOption' - Output = [PSCustomObject]$TableColumnOptionProperty - } - } - Else { - Write-Warning "New-TableColumnOption did not have any additional arguments listed" - } - -} From 34e9da502b5c1456e66b05a8130684c37b652c1c Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 07/15] Revert "Add aliases for ordering" This reverts commit f6915f92022cff4ad3994d57ecf9b2e01906b0c3. --- Public/New-HTMLTableColumnOption.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-HTMLTableColumnOption.ps1 b/Public/New-HTMLTableColumnOption.ps1 index a725bf48..fadddbd4 100644 --- a/Public/New-HTMLTableColumnOption.ps1 +++ b/Public/New-HTMLTableColumnOption.ps1 @@ -7,8 +7,8 @@ function New-TableColumnOption { [string]$Width, [switch]$Visible, [switch]$Hidden, - [alias('EnableSorting')][switch]$EnableOrdering, - [alias('DisableSorting')][switch]$DisableOrdering, + [switch]$EnableOrdering, + [switch]$DisableOrdering, [switch]$DisableSearch, [switch]$EnableSearch ) From 44a549e7cc8f8bc019150900a20e482ab48cd1c6 Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 08/15] Revert "" This reverts commit 101004de2d51710bf17f75bf4d5b35873997a7ff. --- .../Example39_01.ps1 | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 Examples/Example39-TableColumnOption/Example39_01.ps1 diff --git a/Examples/Example39-TableColumnOption/Example39_01.ps1 b/Examples/Example39-TableColumnOption/Example39_01.ps1 deleted file mode 100644 index 70dde7fa..00000000 --- a/Examples/Example39-TableColumnOption/Example39_01.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -Import-Module "$($PSSCriptRoot)\..\..\PSWriteHTML.psm1" -Force - -$Process = Get-Process | Select-Object -First 20 - -New-HTML -TitleText 'My title' -Online -FilePath $PSScriptRoot\Example39_01.html { - New-HTMLContent -HeaderText 'Test' { - New-HTMLTable -DataTable $Process -PagingOptions @(5, 10, 50, 100) { - New-HTMLTableColumnOption -ColumnIndex 0 -Visible - New-HTMLTableColumnOption -AllColumns -Hidden - } - } - New-HTMLContent -HeaderText 'Test' { - New-HTMLTable -DataTable $Process -PagingOptions @(5, 10, 50, 100) -DefaultSortColumn 'PriorityClass' { - New-HTMLTableColumnOption -ColumnIndex (0..1) -Width 50 -Visible - New-HTMLTableColumnOption -ColumnIndex (2..3) -Width 300 -Visible -DisableSearch - New-HTMLTableColumnOption -AllColumns -Hidden - - } - } - New-HTMLTable -DataTable $Process -DefaultSortIndex 0 -OrderMulti { - New-HTMLTableColumnOption -ColumnIndex 0 -EnableOrdering -DisableSearch - New-HTMLTableColumnOption -AllColumns -DisableOrdering - } -} -ShowHTML From 277c5ff61d1b32305cc880bda028929456032987 Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 09/15] Revert "" This reverts commit 1818c04416c52039235c843e3c91ab1b80bc835c. --- Public/New-HTMLTableColumnOption.ps1 | 33 +++++----------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/Public/New-HTMLTableColumnOption.ps1 b/Public/New-HTMLTableColumnOption.ps1 index fadddbd4..bebacfe1 100644 --- a/Public/New-HTMLTableColumnOption.ps1 +++ b/Public/New-HTMLTableColumnOption.ps1 @@ -4,13 +4,10 @@ function New-TableColumnOption { param( [alias('Targets')][int[]]$ColumnIndex, [alias('TargetAll')][switch]$AllColumns, - [string]$Width, - [switch]$Visible, [switch]$Hidden, - [switch]$EnableOrdering, + [string]$Width, [switch]$DisableOrdering, - [switch]$DisableSearch, - [switch]$EnableSearch + [switch]$DisableSearch ) If ($PSBoundParameters.ContainsKey('AllColumns') -and $PSBoundParameters.ContainsKey('ColumnIndex')) { @@ -27,29 +24,11 @@ function New-TableColumnOption { targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; } - If ($Width) { $TableColumnOptionProperty['width'] = $Width } - - If ($Visible) { $TableColumnOptionProperty['visible'] = $true } - if ($Hidden) { - If ($Visible) { Write-Warning 'New-HTMLTableColumnOption - Hidden overrides Visible' } - $TableColumnOptionProperty['visible'] = $false - } + If ($Width) { $TableColumnOptionProperty.Add('width', $Width) } + if ($Hidden) { $TableColumnOptionProperty.Add('visible', $false) } + if ($DisableOrdering) { $TableColumnOptionProperty.Add('orderable', $false) } + if ($DisableSearch) { $TableColumnOptionProperty.Add('searchable', $false)} - If ($EnableOrdering) { $TableColumnOptionProperty['orderable'] = $true } - if ($DisableOrdering) { - If ($EnableOrdering) { - Write-Warning 'New-HTMLTableColumnOption - Disabling ordering orverrides enabling ordering.' - } - $TableColumnOptionProperty['orderable'] = $false - } - if ($EnableSearch) { $TableColumnOptionProperty['searchable'] = $true } - if ($DisableSearch) { - If ($EnableSearch) { - Write-Warning 'New-HTMLTableColumnOption - Disabling search overrides enabling search' - } - $TableColumnOptionProperty['searchable'] = $false - } - # Check if we have properties set If ($TableColumnOptionProperty.Keys.Count -gt 1) { $TableColumnOption = [PSCustomObject]$TableColumnOptionProperty From 63ee5633cb1b5805283b7005a52c70ba3dd16abb Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 10/15] Revert "" This reverts commit 119792aa63bcf7d02387922ad0bd45542e471e50. --- Public/New-HTMLTable.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index 4c023645..a7410880 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -472,7 +472,7 @@ function New-HTMLTable { } If ($DisableAutoSizeOptimization) { - $Options.autoWidth = $false + $Options.autowidth = $false } $Options = $Options | ConvertTo-Json -Depth 6 From 50efea308385394a8771a183ca4b94b773df80d1 Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 11/15] Revert "" This reverts commit 8f5c72645d5771d67458166b9d4d0bfe10fe3788. --- Public/New-HTMLTable.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index a7410880..7a1f4ada 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -58,7 +58,6 @@ function New-HTMLTable { [alias('RegularExpression')][switch]$SearchRegularExpression, [ValidateSet('normal', 'break-all', 'keep-all', 'break-word')][string] $WordBreak = 'normal', [switch] $AutoSize, - [switch] $DisableAutoSizeOptimization, [string] $Title ) if (-not $Script:HTMLSchema.Features) { @@ -464,16 +463,17 @@ function New-HTMLTable { If ($Options.columnDefs) { foreach ($_ in $TableColumnOptions) { $Options.columnDefs += $_ + + # If we have column width specified and the $Width parameter is set, then remove it + if ($_.width -and $Width) { + $Width = $null + } } } else { $Options.columnDefs = @( foreach($_ in $TableColumnOptions) { $_ }) } } - - If ($DisableAutoSizeOptimization) { - $Options.autowidth = $false - } $Options = $Options | ConvertTo-Json -Depth 6 From 1fc124638d41dd52c92977bcb226a5bfcb51f08f Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 12/15] Revert "" This reverts commit bd96ccfbe3e3bd864a870e0d7887dae9525eee10. --- Public/New-HTMLTable.ps1 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index 7a1f4ada..ebcd66e7 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -460,14 +460,9 @@ function New-HTMLTable { } If ($TableColumnOptions.Count -gt 0) { - If ($Options.columnDefs) { + If ($Options.ContainsKey('columnDefs')) { foreach ($_ in $TableColumnOptions) { $Options.columnDefs += $_ - - # If we have column width specified and the $Width parameter is set, then remove it - if ($_.width -and $Width) { - $Width = $null - } } } else { From ef14d567a0830d2b1b8addb3a902b8cd571ffd39 Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 13/15] Revert "" This reverts commit c91d72fb08e6e99bb2ebf612c5b2e45f64f7d215. --- Public/New-HTMLTable.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index ebcd66e7..85136588 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -121,7 +121,7 @@ function New-HTMLTable { } elseif ($Parameters.Type -eq 'TableRowGrouping') { $RowGrouping = $Parameters.Output } elseif ($Parameters.Type -eq 'TableColumnOption') { - $TableColumnOptions.Add($Parameters.Output) + $TableColumnOptions = $Parameters.Output } } } @@ -469,7 +469,7 @@ function New-HTMLTable { $Options.columnDefs = @( foreach($_ in $TableColumnOptions) { $_ }) } } - + $Options = $Options | ConvertTo-Json -Depth 6 # cleans up $Options for ImmediatelyShowHiddenDetails From 9bf5cdaa833d87673cec87a2c1db35dbba2b2bda Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 14/15] Revert "fixed bug" This reverts commit 38dfa219f822ec9905c516bac1d3e1cc8ef8f5f6. --- Public/New-HTMLTableColumnOption.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/New-HTMLTableColumnOption.ps1 b/Public/New-HTMLTableColumnOption.ps1 index bebacfe1..fe08a97b 100644 --- a/Public/New-HTMLTableColumnOption.ps1 +++ b/Public/New-HTMLTableColumnOption.ps1 @@ -13,7 +13,7 @@ function New-TableColumnOption { If ($PSBoundParameters.ContainsKey('AllColumns') -and $PSBoundParameters.ContainsKey('ColumnIndex')) { throw "You cannot specify -AllColumns and -ColumnIndex inside the same TableColumnOption" } - If (!$PSBoundParameters.ContainsKey('AllColumns') -and !$PSBoundParameters.ContainsKey('ColumnIndex')) { + If (!$PSBoundParameters.ContainsKey('AllColumns') -or !$PSBoundParameters.ContainsKey('ColumnIndex')) { throw "You must specify either -AllColumns or -ColumnIndex inside the TableColumnOption" } From c2c1504618a70b8a04c09aa950333bac80ee4b7f Mon Sep 17 00:00:00 2001 From: zsoch Date: Mon, 27 Jul 2020 22:01:32 -0500 Subject: [PATCH 15/15] Revert "add column option" This reverts commit 455b7a76564f26cc7e57891aa5bec5403a182c94. --- Public/New-HTMLTable.ps1 | 16 +---------- Public/New-HTMLTableColumnOption.ps1 | 41 ---------------------------- 2 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 Public/New-HTMLTableColumnOption.ps1 diff --git a/Public/New-HTMLTable.ps1 b/Public/New-HTMLTable.ps1 index 85136588..d0b3028f 100644 --- a/Public/New-HTMLTable.ps1 +++ b/Public/New-HTMLTable.ps1 @@ -76,7 +76,6 @@ function New-HTMLTable { $ContentTop = [System.Collections.Generic.List[PSCustomObject]]::new() $ContentFormattingInline = [System.Collections.Generic.List[PSCustomObject]]::new() $ReplaceCompare = [System.Collections.Generic.List[System.Collections.IDictionary]]::new() - $TableColumnOptions = [System.Collections.Generic.List[PSCustomObject]]::new() $RowGrouping = @{ } if ($HTML) { @@ -120,8 +119,6 @@ function New-HTMLTable { $ReplaceCompare.Add($Parameters.Output) } elseif ($Parameters.Type -eq 'TableRowGrouping') { $RowGrouping = $Parameters.Output - } elseif ($Parameters.Type -eq 'TableColumnOption') { - $TableColumnOptions = $Parameters.Output } } } @@ -456,20 +453,9 @@ function New-HTMLTable { $_.responsivePriority = $PriorityOrder $_ } - ) + ) } - If ($TableColumnOptions.Count -gt 0) { - If ($Options.ContainsKey('columnDefs')) { - foreach ($_ in $TableColumnOptions) { - $Options.columnDefs += $_ - } - } - else { - $Options.columnDefs = @( foreach($_ in $TableColumnOptions) { $_ }) - } - } - $Options = $Options | ConvertTo-Json -Depth 6 # cleans up $Options for ImmediatelyShowHiddenDetails diff --git a/Public/New-HTMLTableColumnOption.ps1 b/Public/New-HTMLTableColumnOption.ps1 deleted file mode 100644 index fe08a97b..00000000 --- a/Public/New-HTMLTableColumnOption.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -function New-TableColumnOption { - [alias('EmailTableColumnOption', 'TableColumnOption', 'New-HTMLTableColumnOption')] - [CmdletBinding()] - param( - [alias('Targets')][int[]]$ColumnIndex, - [alias('TargetAll')][switch]$AllColumns, - [switch]$Hidden, - [string]$Width, - [switch]$DisableOrdering, - [switch]$DisableSearch - ) - - If ($PSBoundParameters.ContainsKey('AllColumns') -and $PSBoundParameters.ContainsKey('ColumnIndex')) { - throw "You cannot specify -AllColumns and -ColumnIndex inside the same TableColumnOption" - } - If (!$PSBoundParameters.ContainsKey('AllColumns') -or !$PSBoundParameters.ContainsKey('ColumnIndex')) { - throw "You must specify either -AllColumns or -ColumnIndex inside the TableColumnOption" - } - - $TableColumnOption = $null - - # Create a hashtable property - $TableColumnOptionProperty = @{ - targets = if ($AllColumns) { "_all" } else { $ColumnIndex }; - } - - If ($Width) { $TableColumnOptionProperty.Add('width', $Width) } - if ($Hidden) { $TableColumnOptionProperty.Add('visible', $false) } - if ($DisableOrdering) { $TableColumnOptionProperty.Add('orderable', $false) } - if ($DisableSearch) { $TableColumnOptionProperty.Add('searchable', $false)} - - # Check if we have properties set - If ($TableColumnOptionProperty.Keys.Count -gt 1) { - $TableColumnOption = [PSCustomObject]$TableColumnOptionProperty - } - - [PSCustomObject] @{ - Type = 'TableColumnOption' - Output = $TableColumnOption - } -}