LP1812670 Angular grid shows selector labels
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / core / idl.service.ts
index 89f8411..b6f8173 100644 (file)
@@ -133,5 +133,19 @@ export class IdlService {
 
         return result;
     }
+
+    // Given a field on an IDL class, returns the name of the field
+    // on the linked class that acts as the selector for the linked class.
+    // Returns null if no selector is found or the field is not a link.
+    getLinkSelector(fmClass: string, field: string): string {
+        const fieldDef = this.classes[fmClass].field_map[field];
+        if (fieldDef.class) {
+            const classDef = this.classes[fieldDef.class];
+            if (classDef.pkey) {
+                return classDef.field_map[classDef.pkey].selector || null;
+            }
+        }
+        return null;
+    }
 }