From e891f63657c2ed86ecb9f077083e2beed4d64673 Mon Sep 17 00:00:00 2001 From: Vasia Korobkin Date: Fri, 24 Jul 2015 11:33:25 +0300 Subject: [PATCH 1/2] Added e2e-test to demonstrate a problem --- examples/blog/config.js | 1 + src/javascripts/test/e2e/EditionViewSpec.js | 13 +++++++++++++ src/javascripts/test/e2e/ShowViewSpec.js | 7 ++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/blog/config.js b/examples/blog/config.js index 2aa6297e..91c16db1 100644 --- a/examples/blog/config.js +++ b/examples/blog/config.js @@ -132,6 +132,7 @@ .targetEntity(comment) .targetReferenceField('post_id') .targetFields([ + nga.field('id').isDetailLink(true), nga.field('created_at').label('Posted'), nga.field('body').label('Comment') ]) diff --git a/src/javascripts/test/e2e/EditionViewSpec.js b/src/javascripts/test/e2e/EditionViewSpec.js index c6d81b5a..9b006e26 100644 --- a/src/javascripts/test/e2e/EditionViewSpec.js +++ b/src/javascripts/test/e2e/EditionViewSpec.js @@ -66,4 +66,17 @@ describe('EditionView', function () { }); }); }); + + describe('DetailLink', function() { + beforeEach(function() { + browser.baseUrl + '#/posts/edit/1'; + }); + + it('should redirect to corresponding detail view even for referenced_list entity', function () { + $$('#row-comments td a').first().click(); + browser.getLocationAbsUrl().then(function(url){ + expect(url).toContain('/comments/edit/'); + }); + }); + }); }); diff --git a/src/javascripts/test/e2e/ShowViewSpec.js b/src/javascripts/test/e2e/ShowViewSpec.js index a0c74258..d787f547 100644 --- a/src/javascripts/test/e2e/ShowViewSpec.js +++ b/src/javascripts/test/e2e/ShowViewSpec.js @@ -26,10 +26,11 @@ describe('ShowView', function () { describe('ReferencedListField', function() { it('should render as a datagrid', function () { $$('.ng-admin-field-comments th').then(function (inputs) { - expect(inputs.length).toBe(2); + expect(inputs.length).toBe(3); - expect(inputs[0].getAttribute('class')).toBe('ng-scope ng-admin-column-created_at'); - expect(inputs[1].getAttribute('class')).toBe('ng-scope ng-admin-column-body'); + expect(inputs[0].getAttribute('class')).toBe('ng-scope ng-admin-column-id'); + expect(inputs[1].getAttribute('class')).toBe('ng-scope ng-admin-column-created_at'); + expect(inputs[2].getAttribute('class')).toBe('ng-scope ng-admin-column-body'); }); }); }); From 3fefac8157c5d4ce4afa3363b2a26d9e3a19e923 Mon Sep 17 00:00:00 2001 From: Vasia Korobkin Date: Fri, 24 Jul 2015 11:34:26 +0300 Subject: [PATCH 2/2] Bug-fix: go_to_detail_state_params_override --- src/javascripts/ng-admin/Crud/column/maColumn.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/javascripts/ng-admin/Crud/column/maColumn.js b/src/javascripts/ng-admin/Crud/column/maColumn.js index c0815398..659c748d 100644 --- a/src/javascripts/ng-admin/Crud/column/maColumn.js +++ b/src/javascripts/ng-admin/Crud/column/maColumn.js @@ -43,10 +43,10 @@ define(function (require) { route = 'show'; } $state.go($state.get(route), - angular.extend({ + angular.extend({}, $state.params, { entity: scope.entry.entityName, id: scope.entry.identifierValue - }, $state.params)); + })); }; scope.gotoReference = function () { var referenceEntity = scope.field.targetEntity().name();