Private/Angular/Component/List/Table/New-NgTableComponentHtmlToString.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Function New-NgTableComponentHtmlToString([WebCsprojInfo]$webCsprojInfo, [TableInfo]$tableInfo, [string]$newUrl)
{
    [string]$result = @"
<h2>$($tableInfo.tablePretty) List</h2>

 <div class="table-responsive" *ngIf="$($tableInfo.tableLowerCamel)s; else $($tableInfo.tableLowerCamel)sLoading">
    <table class="table table-striped" style="max-width: none; width: 0px">
      <thead>
        <tr>
"@


    # Add column headers
    foreach ($columnInfo in $tableInfo.columnInfos)
    {
        $result = $result + "<th>$($columnInfo.caption)</th>"
    }
    $result = $result + @"
        </tr>
    </thead>
"@


    # Add one row that uses angular repeater
    $result = $result + @"
      <tbody>
        <ng-container *ngFor="let $($tableInfo.tableLowerCamel) of $($tableInfo.tableLowerCamel)s">
          <tr>
"@
        
    foreach ($columnInfo in $tableInfo.columnInfos)
    {
        $result = $result + "<td>{{$($tableInfo.tableLowerCamel).$($columnInfo.columnLowerCamel)}}</td>"
    }

    $result = $result + @"
          </tr>
        </ng-container>
      </tbody>
    </table>

    <a class="btn btn-primary" routerLink="$($newUrl)" routerLinkActive="active">New $($tableInfo.tablePretty)</a>
  </div>
  <ng-template #$($tableInfo.tableLowerCamel)sLoading>
    Loading ...
  </ng-template>
"@

    return $result 
}