LP#1775466 Grid row count selector
authorBill Erickson <berickxx@gmail.com>
Fri, 25 May 2018 18:59:12 +0000 (14:59 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 6 Jun 2018 20:59:41 +0000 (16:59 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.html
Open-ILS/src/eg2/src/app/share/grid/grid.component.css
Open-ILS/src/eg2/src/app/share/util/pager.ts

index 2bd0e3f..8627ff6 100644 (file)
@@ -13,7 +13,7 @@
   <!-- push everything else to the right -->
   <div class="flex-1"></div>
 
-  <div ngbDropdown class="ml-1" placement="bottom-right">
+  <div ngbDropdown class="mr-1" placement="bottom-right">
     <button ngbDropdownToggle [disabled]="!gridContext.toolbarActions.length"
         class="btn btn-outline-dark no-dropdown-caret">
       <span title="Actions For Selected Rows" i18n-title 
     </div>
   </div>
 
-  <div class="btn-toolbar ml-1">
-    <div class="btn-grp">
-      <button [disabled]="gridContext.pager.isFirstPage()" type="button" 
-        class="btn btn-outline-dark" (click)="gridContext.pager.toFirst()">
-        <span title="First Page" i18n-title 
-            class="material-icons mat-icon-in-button">first_page</span>
-      </button>
-      <button [disabled]="gridContext.pager.isFirstPage()" type="button" 
-        class="btn btn-outline-dark" (click)="gridContext.pager.decrement()">
-        <span title="Previous Page" i18n-title 
-            class="material-icons mat-icon-in-button">keyboard_arrow_left</span>
-      </button>
-      <button [disabled]="gridContext.pager.isLastPage()" type="button" 
-        class="btn btn-outline-dark" (click)="gridContext.pager.increment()">
-        <span title="Next Page" i18n-title 
-            class="material-icons mat-icon-in-button">keyboard_arrow_right</span>
-      </button>
-      <button [disabled]="!gridContext.pager.resultCount || gridContext.pager.isLastPage()" 
-        type="button" class="btn btn-outline-dark" (click)="gridContext.pager.toLast()">
-        <span title="First Page" i18n-title 
-            class="material-icons mat-icon-in-button">last_page</span>
-      </button>
+  <button [disabled]="gridContext.pager.isFirstPage()" type="button" 
+    class="btn btn-outline-dark mr-1" (click)="gridContext.pager.toFirst()">
+    <span title="First Page" i18n-title 
+        class="material-icons mat-icon-in-button">first_page</span>
+  </button>
+  <button [disabled]="gridContext.pager.isFirstPage()" type="button" 
+    class="btn btn-outline-dark mr-1" (click)="gridContext.pager.decrement()">
+    <span title="Previous Page" i18n-title 
+        class="material-icons mat-icon-in-button">keyboard_arrow_left</span>
+  </button>
+  <button [disabled]="gridContext.pager.isLastPage()" type="button" 
+    class="btn btn-outline-dark mr-1" (click)="gridContext.pager.increment()">
+    <span title="Next Page" i18n-title 
+        class="material-icons mat-icon-in-button">keyboard_arrow_right</span>
+  </button>
+
+  <button [disabled]="!gridContext.pager.resultCount || gridContext.pager.isLastPage()" 
+    type="button" class="btn btn-outline-dark mr-1" (click)="gridContext.pager.toLast()">
+    <span title="First Page" i18n-title 
+        class="material-icons mat-icon-in-button">last_page</span>
+  </button>
+
+  <div ngbDropdown class="mr-1" placement="bottom-right">
+    <button ngbDropdownToggle class="btn btn-outline-dark text-button">
+      <span title="Select Row Count" i18n-title i18n>
+        Rows {{gridContext.pager.limit}}
+      </span>
+    </button>
+    <div class="dropdown-menu" ngbDropdownMenu>
+      <a class="dropdown-item" 
+        *ngFor="let count of [5, 10, 25, 50, 100]"
+        (click)="gridContext.pager.setLimit(count)">
+        <span class="ml-2">{{count}}</span>
+      </a>
     </div>
   </div>
 
   <eg-grid-column-config #columnConfDialog [columnSet]="gridContext.columnSet">
   </eg-grid-column-config>
-  <div ngbDropdown class="ml-1" placement="bottom-right">
+  <div ngbDropdown placement="bottom-right">
     <button ngbDropdownToggle class="btn btn-outline-dark no-dropdown-caret">
-      <span title="Show Grid Options" i18n-title class="material-icons mat-icon-in-button">settings</span>
+      <span title="Show Grid Options" i18n-title 
+        class="material-icons mat-icon-in-button">settings</span>
     </button>
     <div class="dropdown-menu" ngbDropdownMenu>
       <a class="dropdown-item label-with-material-icon" 
index 5bb1c9e..01d1253 100644 (file)
   display: flex;
 }
 
+.eg-grid-toolbar .material-icons {
+  font-size: 20px;
+}
+
+/* Kind of hacky -- only way to get a toolbar button with no 
+ * mat icon to line up horizontally with mat icon buttons */
+.eg-grid-toolbar .text-button {
+  padding-top: 11px;
+  padding-bottom: 11px;
+}
+
 .eg-grid-cell-skinny {
   width: 2.2em;
   text-align: center;
index 7d524b7..b352fdb 100644 (file)
@@ -19,6 +19,13 @@ export class Pager {
         this.offset = 0;
     }
 
+    setLimit(l: number) {
+        if (l !== this.limit) {
+            this.limit = l;
+            this.setPage(1);
+        }
+    }
+
     isFirstPage(): boolean {
         return this.offset === 0;
     }