LP1821382 Angular grid optoin to disable paging
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / share / grid / grid.component.ts
index 1fa4c2c..e1f988f 100644 (file)
@@ -1,6 +1,6 @@
 import {Component, Input, Output, OnInit, AfterViewInit, EventEmitter,
     OnDestroy, HostListener, ViewEncapsulation} from '@angular/core';
-import {Subscription} from 'rxjs/Subscription';
+import {Subscription} from 'rxjs';
 import {IdlService} from '@eg/core/idl.service';
 import {OrgService} from '@eg/core/org.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
@@ -44,6 +44,8 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
     // The value is prefixed with 'eg.grid.'
     @Input() persistKey: string;
 
+    @Input() disableSelect: boolean;
+
     // Prevent selection of multiple rows
     @Input() disableMultiSelect: boolean;
 
@@ -77,6 +79,24 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
     // Allow the caller to jump directly to a specific page of
     // grid data.
     @Input() pageOffset: number;
+    // Pass in a default page size.  May be overridden by settings.
+    @Input() pageSize: number;
+
+    // If true and an idlClass is specificed, the grid assumes
+    // datatype=link fields that link to classes which define a selector
+    // are fleshed with the linked object.  And, instead of displaying
+    // the raw field value, displays the selector value from the linked
+    // object.  The caller is responsible for fleshing the appropriate
+    // fields in the GridDataSource getRows handler.
+    //
+    // This only applies to auto-generated columns.
+    //
+    // For example, idlClass="aou" and field="ou_type", the display
+    // value will be ou_type().name() since "name" is the selector
+    // field on the "aout" class.
+    @Input() showLinkSelectors: boolean;
+
+    @Input() disablePaging: boolean;
 
     context: GridContext;
 
@@ -109,9 +129,12 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
         this.context.isSortable = this.sortable === true;
         this.context.isMultiSortable = this.multiSortable === true;
         this.context.useLocalSort = this.useLocalSort === true;
+        this.context.disableSelect = this.disableSelect === true;
+        this.context.showLinkSelectors = this.showLinkSelectors === true;
         this.context.disableMultiSelect = this.disableMultiSelect === true;
         this.context.rowFlairIsEnabled = this.rowFlairIsEnabled  === true;
         this.context.rowFlairCallback = this.rowFlairCallback;
+        this.context.disablePaging = this.disablePaging === true;
         if (this.showFields) {
             this.context.defaultVisibleFields = this.showFields.split(',');
         }
@@ -123,6 +146,10 @@ export class GridComponent implements OnInit, AfterViewInit, OnDestroy {
             this.context.pager.offset = this.pageOffset;
         }
 
+        if (this.pageSize) {
+            this.context.pager.limit = this.pageSize;
+        }
+
         // TS doesn't seem to like: let foo = bar || () => '';
         this.context.rowClassCallback =
             this.rowClassCallback || function () { return ''; };