add combobox
authorJane Sandberg <sandbej@linnbenton.edu>
Sun, 11 Aug 2019 14:48:36 +0000 (07:48 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Sun, 11 Aug 2019 14:48:36 +0000 (07:48 -0700)
Open-ILS/src/eg2/src/app/staff/cat/authorities/authorities.module.ts
Open-ILS/src/eg2/src/app/staff/cat/authorities/manage.component.html
Open-ILS/src/eg2/src/app/staff/cat/authorities/manage.component.ts

index 26412b3..e5f138b 100644 (file)
@@ -1,3 +1,4 @@
+import { ReactiveFormsModule } from '@angular/forms';
 import {NgModule} from '@angular/core';
 import {StaffCommonModule} from '@eg/staff/common.module';
 import {ManageAuthoritiesComponent} from './manage.component';
@@ -9,7 +10,8 @@ import {AuthoritiesRoutingModule} from './routing.module';
   ],
   imports: [
     AuthoritiesRoutingModule,
-    StaffCommonModule
+    StaffCommonModule,
+    ReactiveFormsModule
   ],
 })
 
index bbba1ce..3fd775b 100644 (file)
@@ -1,3 +1,12 @@
+<form [formGroup]="search">
+  <eg-combobox formControlName="field">
+    <eg-combobox-entry *ngFor="let authorityField of authorityFields"
+      [entryId]="authorityField.id()"
+      [entryLabel]="authorityField.name()">
+    </eg-combobox-entry>
+  </eg-combobox>
+</form>
+{{field}}
 <eg-grid #grid [dataSource]="gridSource"
   persistKey="cat.authorities.manage">
   <eg-grid-column path="record.id" label="ID" i18n-label [index]="true" [hidden]="true"></eg-grid-column>
index 2a2acc1..57edd83 100644 (file)
@@ -1,34 +1,48 @@
+import {FormGroup, FormControl} from '@angular/forms';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {Component} from '@angular/core';
 import {GridDataSource} from '@eg/share/grid/grid';
 import {Pager} from '@eg/share/util/pager';
+import { IdlObject } from '@eg/core/idl.service';
 
 @Component({
   templateUrl: './manage.component.html',
 })
 export class ManageAuthoritiesComponent {
     gridSource: GridDataSource;
+    search: FormGroup;
+    authorityFields: IdlObject[] = [];
 
     constructor(
         private pcrud: PcrudService
-        ) {
+    ) {
+        this.search = new FormGroup({
+            field: new FormControl()
+        });
+
+        this.pcrud.search('acsaf', {'main_entry': null})
+        .subscribe((field) => this.authorityFields.push(field));
 
         this.gridSource = new GridDataSource();
 
         this.gridSource.getRows = (pager: Pager) => {
-            return this.pcrud.search('ash', {
-                'record': { 'in': {
-                    'from': 'are', 'select': {'are': ['id']}, 'where': {'deleted': 'false'}}},
-                'atag': { 'in': {
-                    'from': 'acsaf', 'select': {'acsaf': ['id']}, 'where': {'main_entry': null}}},
-                },
-                {flesh: 2,
-                flesh_fields: {
-                    are: ['creator', 'editor', 'owner'],
-                    ash: ['record']
-                }
-            });
+            if (this.field.value) {
+                return this.pcrud.search('ash', {
+                    'record': { 'in': {
+                        'from': 'are', 'select': {'are': ['id']}, 'where': {'deleted': 'false'}}},
+                    'atag': this.field.value.id,
+                    },
+                    {flesh: 2,
+                    flesh_fields: {
+                        are: ['creator', 'editor', 'owner'],
+                        ash: ['record']
+                    }
+                });
+            }
         };
     }
+    get field() {
+        return this.search.get('field');
+    }
 
 }