LP1847800 Admin grid filter display, default fields, IDL repairs
authorBill Erickson <berickxx@gmail.com>
Wed, 6 May 2020 14:47:37 +0000 (10:47 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 12 May 2020 15:27:20 +0000 (11:27 -0400)
* Indicate in the UI when grid filters are applied via URL and offer a
  way for the user to clear the filters.

* When grid filters are applied, use them as the basis for the "Default
  New Record" object which seeds the fm-editor.  In other words, apply
  default values to the fm-editor to match the grid filters.

* Repair some IDL thinkos and add more 'selector' values.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index 9a877b6..fbef932 100644 (file)
@@ -218,7 +218,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
        <class id="vibtf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="vandelay::import_bib_trash_fields" oils_persist:tablename="vandelay.import_bib_trash_fields" reporter:label="Import/Overlay Fields for Removal">
                <fields oils_persist:primary="id" oils_persist:sequence="vandelay.import_bib_trash_fields_id_seq">
-                       <field reporter:label="Field ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Field ID" name="id" reporter:datatype="id" reporter:selector="field"/>
                        <field reporter:label="Group" name="grp" reporter:datatype="link" config_field="true"/>
                        <field reporter:label="Field" name="field" reporter:datatype="text"/>
                </fields>
@@ -340,7 +340,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             reporter:label="Import/Overlay Field Groups for Removal">
                <fields oils_persist:primary="id" 
                 oils_persist:sequence="vandelay.import_bib_trash_group_id_seq">
-                       <field reporter:label="ID" name="id" reporter:datatype="id" reporter:selector="name"/>
+                       <field reporter:label="ID" name="id" reporter:datatype="id" reporter:selector="label"/>
                        <field reporter:label="Owner" name="owner" reporter:datatype="link"/>
                        <field reporter:label="Label" name="label" reporter:datatype="text"/>
                        <field reporter:label="Always Apply" name="always_apply" reporter:datatype="bool"/>
@@ -2583,7 +2583,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <link field="thesauri" reltype="has_many" key="control_set" map="" class="at"/>
                        <link field="main_entry" reltype="has_a" key="id" map="" class="acsaf"/>
                        <link field="sub_entries" reltype="has_many" key="main_entry" map="" class="acsaf"/>
-                       <link field="heading" reltype="has_a" key="id" map="" class="ahf"/>
+                       <link field="heading_field" reltype="has_a" key="id" map="" class="ahf"/>
                </links>
                <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
                        <actions>
@@ -2777,7 +2777,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
        <class id="ahf" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::heading_field" oils_persist:tablename="authority.heading_field" reporter:label="Authority Heading Fields">
                <fields oils_persist:primary="id" oils_persist:sequence="authority.heading_fields_id_seq">
-                       <field name="id" reporter:datatype="id" />
+                       <field name="id" reporter:datatype="id" reporter:selector="label" />
                        <field name="heading_type" reporter:datatype="text" reporter:label="Heading Type" />
                        <field name="heading_purpose" reporter:datatype="text" reporter:label="Heading Purpose" />
                        <field name="label" reporter:datatype="text" reporter:label="Heading Field Label" />
index c05a98b..ceb9cbc 100644 (file)
 <ng-template #createErrStrTmpl i18n>Failed to create new {{idlClassDef.label}}</ng-template>
 <eg-string #createErrString [template]="createErrStrTmpl"></eg-string>
 
-<ng-container *ngIf="orgField">
-  <eg-org-family-select
-    [limitPerms]="viewPerms" 
-    [selectedOrgId]="contextOrg.id()"
-    [(ngModel)]="searchOrgs"
-    (ngModelChange)="grid.reload()">
-  </eg-org-family-select>
+<ng-container *ngIf="orgField || gridFilters">
+  <div class="row">
+    <div class="col-lg-6">
+      <ng-container *ngIf="orgField">
+        <eg-org-family-select
+          [limitPerms]="viewPerms" 
+          [selectedOrgId]="contextOrg.id()"
+          [(ngModel)]="searchOrgs"
+          (ngModelChange)="grid.reload()">
+        </eg-org-family-select>
+      </ng-container>
+    </div>
+    <div class="col-lg-6 d-flex">
+      <div class="flex-1"></div><!-- push right -->
+      <ng-container *ngIf="gridFilters">
+        <span i18n>Filters Applied: {{gridFilters | json}}</span>
+        <a class="pl-2 font-italic" 
+          [attr.href]="clearGridFiltersUrl()" i18n>Clear Filters</a>
+      </ng-container>
+    </div>
+  </div>
   <hr/>
 </ng-container>
 
index f268498..dfc85a2 100644 (file)
@@ -191,6 +191,20 @@ export class AdminPageComponent implements OnInit {
             } catch (E) {
                 console.error('Invalid grid filters provided: ', filters);
             }
+
+            // Use the grid filters as the basis for our default
+            // new record (passed to fm-editor).
+            if (!this.defaultNewRecord) {
+                const rec = this.idl.create(this.idlClass);
+                Object.keys(this.gridFilters).forEach(field => {
+                    // When filtering on the primary key of the current
+                    // object type, avoid using it in the default new object.
+                    if (rec[field] && this.pkeyField !== field) {
+                        rec[field](this.gridFilters[field]);
+                    }
+                });
+                this.defaultNewRecord = rec;
+            }
         }
 
         // Limit the view org selector to orgs where the user has
@@ -464,6 +478,12 @@ export class AdminPageComponent implements OnInit {
             idlField: col.name
         });
     }
+
+    clearGridFiltersUrl(): string {
+        const parts = this.idlClassDef.table.split(/\./);
+        const url = this.configLinkBasePath + '/' + parts[0] + '/' + parts[1];
+        return this.ngLocation.prepareExternalUrl(url);
+    }
 }