Skip to content

Commit

Permalink
Merge pull request #560 from vasiakorobkin/go_to_detail_state_params_…
Browse files Browse the repository at this point in the history
…override

[RFR] isDetailView doesn't work on refernced_list entity id-field
  • Loading branch information
jpetitcolas committed Jul 24, 2015
2 parents f6cdd0e + 3fefac8 commit 0becc8c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/blog/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
.targetEntity(comment)
.targetReferenceField('post_id')
.targetFields([
nga.field('id').isDetailLink(true),
nga.field('created_at').label('Posted'),
nga.field('body').label('Comment')
])
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 referenced_list entity', function () {
$$('#row-comments td a').first().click();
browser.getLocationAbsUrl().then(function(url){
expect(url).toContain('/comments/edit/');
});
});
});
});
7 changes: 4 additions & 3 deletions 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[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');
});
});
});
Expand Down

0 comments on commit 0becc8c

Please sign in to comment.