Skip to content

PodeWebTable doesn't instantiate with New-PodeWebIcon inside Initialize-PodeWebTableColumn #673

@ChiefIntegrator

Description

@ChiefIntegrator

Describe the Bug

Passing an Icon object to Initialize-PodeWebTableColumn in a New-PodeWebTable call causes table creation to silently fail. As below:

# Works:
New-PodeWebTable -Name 'Fulfilment' -DataColumn SurveyId -ScriptBlock {
			Get-Content -Path 'C:\Temp\Fulfilment.csv' | ConvertFrom-Csv	
		} -Columns @(
			Initialize-PodeWebTableColumn -Key Discovered	-Icon 'account-box-multiple-outline' -Name "`0"
			Initialize-PodeWebTableColumn -Key Ingressed -Icon 'database-import' -Name "`0"
			Initialize-PodeWebTableColumn -Key Conditioned -Icon 'factory' -Name "`0"
			Initialize-PodeWebTableColumn -Key Egressed -Icon 'database-export' -Name "`0"
		)
# Does not work:
New-PodeWebTable -Name 'Fulfilment' -DataColumn SurveyId -ScriptBlock {
			Get-Content -Path 'C:\Temp\Fulfilment.csv' | ConvertFrom-Csv	
		} -Columns @(
			Initialize-PodeWebTableColumn -Key Discovered	-Icon 'account-box-multiple-outline' -Name "`0"
			Initialize-PodeWebTableColumn -Key Ingressed -Icon 'database-import' -Name "`0"
			Initialize-PodeWebTableColumn -Key Conditioned -Icon (New-PodeWebIcon -Name 'factory') -Name "`0"
			Initialize-PodeWebTableColumn -Key Egressed -Icon 'database-export' -Name "`0"
		)

Steps To Reproduce

Steps to reproduce the behavior:

  1. (as above) Instantiate New-PodeWebTable with:
  2. Columns param containing:
  3. Initialize-PodeWebTableColumn expression with:
  4. Icon param set to hashtable result from New-PodeWebIcon expression

Expected Behavior

Table would instantiate or throw an exception when an Icon object hashtable is passed as a param to a nested Initialize-PodeWebTableColumn expression

Platform

  • OS: Windows 11
  • Browser: Chrome
  • Versions:
    • Pode: v2.12.0
    • Pode.Web: v1.0.0
    • PowerShell: 7.5.2

Additional Context

(I think) I've traced this back to buildTableHeader in default.js, where Icon is treated as a string rather than being polymorphic:

if (column.Icon) {
        value += `<span class='mdi mdi-${column.Icon.toLowerCase()} mRight04'></span>`;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions