Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 3b7c760

Browse files
committed
start of expandable rows for folder list
1 parent ae776ff commit 3b7c760

File tree

3 files changed

+68
-24
lines changed

3 files changed

+68
-24
lines changed

src/app/lists/folder-list/folder-list.component.html

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,29 @@
22
<mat-label>Filter</mat-label>
33
<input matInput (keyup)="applyFilter($event)" placeholder="Ex. Up to Date">
44
</mat-form-field>
5-
<table mat-table class="full-width-table" matSort aria-label="Elements">
6-
<!-- Id Column -->
7-
<ng-container matColumnDef="id">
8-
<th mat-header-cell *matHeaderCellDef mat-sort-header>Id</th>
9-
<td mat-cell *matCellDef="let row">{{row.id}}</td>
5+
<table mat-table class="full-width-table" matSort aria-label="Folders" multiTemplateDataRows>
6+
<ng-container matColumnDef="{{column}}" *ngFor="let column of displayedColumns">
7+
<th mat-header-cell *matHeaderCellDef> {{column}} </th>
8+
<td mat-cell *matCellDef="let folder"> {{folder[column]}} </td>
109
</ng-container>
11-
12-
<!-- Label Column -->
13-
<ng-container matColumnDef="label">
14-
<th mat-header-cell *matHeaderCellDef mat-sort-header>Name</th>
15-
<td mat-cell *matCellDef="let row">{{row.label}}</td>
16-
</ng-container>
17-
18-
<!-- Path Column -->
19-
<ng-container matColumnDef="path">
20-
<th mat-header-cell *matHeaderCellDef mat-sort-header>Path</th>
21-
<td mat-cell *matCellDef="let row">{{row.path}}</td>
22-
</ng-container>
23-
24-
<!-- Status Column -->
25-
<ng-container matColumnDef="state">
26-
<th mat-header-cell *matHeaderCellDef mat-sort-header>State</th>
27-
<td mat-cell *matCellDef="let row">{{row.state}}</td>
10+
<!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns -->
11+
<ng-container matColumnDef="expandedDetail">
12+
<td mat-cell *matCellDef="let folder" [attr.colspan]="displayedColumns.length">
13+
<div class="folder-detail" [@detailExpand]="folder == expandedFolder ? 'expanded' : 'collapsed'">
14+
<div class="folder-devices">
15+
<span>Shared with: </span>
16+
<span class="device-name" *ngFor="let device of folder.devices">{{device.name}}</span>
17+
</div>
18+
</div>
19+
</td>
2820
</ng-container>
2921

3022
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
31-
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
23+
<tr mat-row *matRowDef="let folder; columns: displayedColumns;" class="folder-row"
24+
[class.example-expanded-row]="expandedFolder === folder"
25+
(click)="expandedFolder = expandedFolder === folder ? null : folder">
26+
</tr>
27+
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="detail-row"></tr>
3228
</table>
3329

3430
<mat-paginator #paginator [length]="dataSource?.data.length" [pageIndex]="0" [pageSize]="25"

src/app/lists/folder-list/folder-list.component.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,42 @@
55
.mat-form-field {
66
font-size: 14px;
77
width: 100%;
8+
}
9+
10+
tr.detail-row {
11+
height: 0;
12+
}
13+
14+
tr.folder-row:not(.example-expanded-row):hover {
15+
background: whitesmoke;
16+
}
17+
18+
tr.folder-row:not(.folder-row):active {
19+
background: #efefef;
20+
}
21+
22+
.folder-row td {
23+
border-bottom-width: 0;
24+
}
25+
26+
.folder-detail {
27+
overflow: hidden;
28+
display: flex;
29+
}
30+
31+
.folder-devices {
32+
padding-bottom: 16px;
33+
}
34+
35+
.device-name:not(:first-child) {
36+
margin-left: -.3em;
37+
}
38+
39+
// Hide empty name
40+
.device-name:empty {
41+
display: none;
42+
}
43+
44+
.device-name:not(:first-child):before {
45+
content: ", ";
846
}

src/app/lists/folder-list/folder-list.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ import { SystemConfigService } from '../../services/system-config.service';
88
import { FilterService } from 'src/app/services/filter.service';
99
import { StType } from 'src/app/type';
1010
import { MatInput } from '@angular/material/input';
11+
import { FolderService } from 'src/app/services/folder.service';
12+
import { trigger, state, style, transition, animate } from '@angular/animations';
1113

1214
@Component({
1315
selector: 'app-folder-list',
1416
templateUrl: './folder-list.component.html',
15-
styleUrls: ['./folder-list.component.scss']
17+
styleUrls: ['./folder-list.component.scss'],
18+
animations: [
19+
trigger('detailExpand', [
20+
state('collapsed', style({ height: '0px', minHeight: '0' })),
21+
state('expanded', style({ height: '*' })),
22+
transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
23+
]),
24+
],
1625
})
1726
export class FolderListComponent implements AfterViewInit, OnInit, OnDestroy {
1827
@ViewChild(MatPaginator) paginator: MatPaginator;
@@ -23,6 +32,7 @@ export class FolderListComponent implements AfterViewInit, OnInit, OnDestroy {
2332

2433
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
2534
displayedColumns = ['id', 'label', 'path', 'state'];
35+
expandedFolder: Folder | null;
2636

2737
constructor(
2838
private folderService: FolderService,

0 commit comments

Comments
 (0)