CSP grid / row flair example user/berick/csp-grid-flair
authorBill Erickson <berickxx@gmail.com>
Wed, 28 Aug 2019 20:20:36 +0000 (16:20 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 28 Aug 2019 20:20:36 +0000 (16:20 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts

index b2d14c1..b8568f0 100644 (file)
     </div>
   </div>
 </div>
+
+<eg-string #cspFlairTooltip i18n-text text="Limited Editing"></eg-string>
+<div class="w-100 mt-2 mb-2">
+  <eg-grid idlClass="csp"
+    [dataSource]="cspSource"
+    [rowFlairIsEnabled]="true"
+    [rowFlairCallback]="cspRowFlairCallback">
+  </eg-grid>
+</div>
+
+
index c6ea7c3..c04d19e 100644 (file)
@@ -50,8 +50,8 @@ export class SandboxComponent implements OnInit {
     @ViewChild('bresvEditor')
     private bresvEditor: FmRecordEditorComponent;
 
-
-    // @ViewChild('helloStr') private helloStr: StringComponent;
+    @ViewChild('cspFlairTooltip') private cspFlairTooltip: StringComponent;
+    cspRowFlairCallback: (row: any) => GridRowFlairEntry;
 
     gridDataSource: GridDataSource = new GridDataSource();
 
@@ -61,6 +61,7 @@ export class SandboxComponent implements OnInit {
 
     btSource: GridDataSource = new GridDataSource();
     acpSource: GridDataSource = new GridDataSource();
+    cspSource: GridDataSource = new GridDataSource();
     editSelected: (rows: IdlObject[]) => void;
     @ViewChild('acpGrid') acpGrid: GridComponent;
     @ViewChild('acpEditDialog') editDialog: FmRecordEditorComponent;
@@ -269,6 +270,22 @@ export class SandboxComponent implements OnInit {
                     }
             } )
         });
+
+        this.cspSource.getRows = (pager: Pager, sort: any[]) => { 
+            // ... paging, etc.
+            return this.pcrud.retrieveAll('csp');
+        }
+
+        this.cspRowFlairCallback = (row: any): GridRowFlairEntry => {
+            // Define in ngOnInit() so we can access 'this'
+            const flair = {icon: null, title: null};
+            if (row.id() < 100) {
+                flair.icon = 'not_interested';
+                // String is static text -- no interpolation required.
+                flair.title = this.cspFlairTooltip.text;
+            }
+            return flair;
+        }
     }
 
     sbChannelHandler = msg => {