LP1819179 PCRUD selector fleshing handles maps
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / core / idl.service.ts
index b6f8173..56b8b90 100644 (file)
@@ -138,7 +138,16 @@ export class IdlService {
     // 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];
+        let fieldDef = this.classes[fmClass].field_map[field];
+
+        if (fieldDef.map) {
+            // For mapped fields, we want the selector field on the
+            // remotely linked object instead of the directly
+            // linked object.
+            const linkedClass = this.classes[fieldDef.class];
+            fieldDef = linkedClass.field_map[fieldDef.map];
+        }
+
         if (fieldDef.class) {
             const classDef = this.classes[fieldDef.class];
             if (classDef.pkey) {