Skip to content

Commit

Permalink
Fix params for DetailView field of nested (referenced) entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasia Korobkin committed Jul 15, 2015
1 parent 737964c commit 9489aca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/blog/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
.targetReferenceField('post_id')
.targetFields([
nga.field('created_at').label('Posted'),
nga.field('body').label('Comment')
nga.field('body').label('Comment'),
nga.field('id').isDetailLink(true)
])
.sortField('created_at')
.sortDir('DESC'),
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/ng-admin/Crud/column/maColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions src/javascripts/test/e2e/EditionViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 nested entity', function () {
$$('#row-comments td a').first().click();
browser.getLocationAbsUrl().then(function(url){
expect(url).toContain('/comments/edit/');
});
});
});
});
3 changes: 2 additions & 1 deletion src/javascripts/test/e2e/ShowViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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[2].getAttribute('class')).toBe('ng-scope ng-admin-column-id');
});
});
});
Expand Down

0 comments on commit 9489aca

Please sign in to comment.