Merge "[CORD-1652] Fixed links to related models in table visualization"
diff --git a/src/app/core/services/helpers/config.helpers.spec.ts b/src/app/core/services/helpers/config.helpers.spec.ts
index be6f7a5..ed1cc3b 100644
--- a/src/app/core/services/helpers/config.helpers.spec.ts
+++ b/src/app/core/services/helpers/config.helpers.spec.ts
@@ -173,10 +173,18 @@
       it('should return the state for a given model', () => {
         expect(service.stateFromCoreModel('Test')).toBe('xos.core.tests');
       });
-
+    });
+    describe('stateWithParams', () => {
       it('should return the state with params for a given model', () => {
         expect(service.stateWithParams('Test', {id: 1})).toBe('xos.core.tests({id: 1})');
       });
+      it('should return the state with params for a given relation', () => {
+        expect(service.relatedStateWithParams('Test', '1')).toBe('xos.core.tests({id: 1})');
+      });
+
+      it('should return the state with params for usage in js', () => {
+        expect(service.stateWithParamsForJs('Test', {id: 1})).toEqual({ name: 'xos.core.tests', params: Object({ id: 1 }) });
+      });
     });
   });
 
diff --git a/src/app/core/services/helpers/config.helpers.ts b/src/app/core/services/helpers/config.helpers.ts
index 3177af1..81901e3 100644
--- a/src/app/core/services/helpers/config.helpers.ts
+++ b/src/app/core/services/helpers/config.helpers.ts
@@ -54,6 +54,7 @@
   toLabels(string: string[], pluralize?: boolean): string[];
   stateFromCoreModel(name: string): string;
   stateWithParams(name: string, model: any): string;
+  relatedStateWithParams(name: string, id: string): string;
   stateWithParamsForJs(name: string, model: any): any;
 }
 
@@ -193,9 +194,7 @@
           this.populateRelated(item, item[f.name], f);
           return item[f.name];
         };
-        col.link = item => {
-          return this.stateWithParams(f.relation.model, item);
-        };
+        col.link = item => this.relatedStateWithParams(f.relation.model, item[col.prop]);
       }
 
       if (f.name === 'backend_status' || f.name === 'policy_status') {
@@ -238,8 +237,12 @@
     return `${state}({id: ${model['id']}})`;
   }
 
+  public relatedStateWithParams(name: string, id: string): string {
+    const state = this.stateFromCoreModel(name);
+    return `${state}({id: ${id}})`;
+  }
+
   public stateWithParamsForJs(name: string, model: any): any {
-    // TODO test and interface
     const state = this.stateFromCoreModel(name);
     return {name: state, params: {id: model.id}};
   }