LP#1626157 Grid column header sort icons
authorBill Erickson <berickxx@gmail.com>
Thu, 10 May 2018 16:29:47 +0000 (12:29 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 10 May 2018 16:29:47 +0000 (12:29 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid-header.component.html
Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts
Open-ILS/src/eg2/src/app/share/grid/grid.component.css

index 14aeec6..b992adc 100644 (file)
     (dragleave)="onColumnDragLeave($event, col)"
     [ngClass]="{'dragover' : col.isDragTarget}"
     class="eg-grid-cell eg-grid-header-cell" [ngStyle]="{flex:col.flex}">
-    <a class="sortable" *ngIf="col.isSortable" (click)="sortOneColumn(col)">
-      {{col.label}}
+    <a class="sortable label-with-material-icon" *ngIf="col.isSortable" 
+      (click)="sortOneColumn(col)">
+      <span class="eg-grid-header-cell-sort-label">{{col.label}}</span>
+      <span class="material-icons eg-grid-header-cell-sort-arrow"
+        *ngIf="isColumnSorting(col, 'ASC')">arrow_downwards</span>
+      <span class="material-icons eg-grid-header-cell-sort-arrow"
+        *ngIf="isColumnSorting(col, 'DESC')">arrow_upwards</span>
     </a>
     <span *ngIf="!col.isSortable">{{col.label}}</span>
   </div>
index 4234d46..2b9f00d 100644 (file)
@@ -50,5 +50,12 @@ export class EgGridHeaderComponent implements OnInit {
         this.dataSource.sort = [{name: col.name, dir: dir}];
         this.grid.reload();
     }
+
+    // Returns true if the provided column is sorting in the 
+    // specified direction.
+    isColumnSorting(col: EgGridColumn, dir: string): boolean {
+        let sort = this.dataSource.sort.filter(c => c.name == col.name)[0];
+        return sort && sort.dir == dir;
+    }
 }
 
index a6f6bd8..57bb252 100644 (file)
     border-color: #b8daff;
 }
 
-.eg-grid-header-cell a.sortable {
+/*
+.eg-grid-header-cell a.sortable span {
+*/
+.eg-grid-header-cell-sort-label {
   cursor: pointer;
   color: #007bff;
   text-decoration:underline;
 }
 
+.eg-grid-header-cell-sort-arrow {
+  font-size: 14px;
+}
+
 .eg-grid-cell {
     flex: 1; /* applied per column */
     padding: 6px;