LP1847800 Admin grid filter display, default fields, IDL repairs
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / admin-page / admin-page.component.ts
index f268498..dfc85a2 100644 (file)
@@ -191,6 +191,20 @@ export class AdminPageComponent implements OnInit {
             } catch (E) {
                 console.error('Invalid grid filters provided: ', filters);
             }
             } 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
         }
 
         // Limit the view org selector to orgs where the user has
@@ -464,6 +478,12 @@ export class AdminPageComponent implements OnInit {
             idlField: col.name
         });
     }
             idlField: col.name
         });
     }
+
+    clearGridFiltersUrl(): string {
+        const parts = this.idlClassDef.table.split(/\./);
+        const url = this.configLinkBasePath + '/' + parts[0] + '/' + parts[1];
+        return this.ngLocation.prepareExternalUrl(url);
+    }
 }
 
 
 }