referenced_list does not respect entity specific baseApiUrl
See original GitHub issueI’m trying to build an admin interface that connects different admin API’s in one app. ng-admin is the perfect way to do that. So I’m having one main admin api that I configure when creating the app like this:
var admin = nga.application('Admin interface')
.baseApiUrl(location.protocol + '//' + ENTITY1_ADMIN_API_HOST + (ENTITY1_ADMIN_API_PORT ? ':' + ENTITY1_ADMIN_API_PORT : '') + ENTITY1_ADMIN_API_BASE_PATH + '/')
I have added an admin provider for an entity served by this api like this:
app.config(function($provide, NgAdminConfigurationProvider, RestangularProvider) {
$provide.factory("Entity1Admin", function() {
var nga = NgAdminConfigurationProvider;
var entity1 = nga.entity('entity1').readOnly();
...
}
Then I have another entity from a second admin API defined like this:
app.config(function($provide, NgAdminConfigurationProvider, ENTITY2_ADMIN_API_HOST, ENTITY2_ADMIN_API_PORT, ENTITY2_ADMIN_API_BASE_PATH) {
$provide.factory("TwitterAdmin", function() {
var nga = NgAdminConfigurationProvider;
var entity2 = nga.entity('entity2').baseApiUrl(location.protocol + '//' + ENTITY2_ADMIN_API_HOST + (ENTITY2_ADMIN_API_PORT ? ':' + ENTITY2_ADMIN_API_PORT : '') + ENTITY2_ADMIN_API_BASE_PATH + '/');
...
So far so good. I’m able to build the admin interface for editing both entities. Now I want to link them using a referenced list, so I add this for the first entity:
entity1.showView()
.fields([
nga.field('metadata', 'referenced_list')
.targetEntity(nga.entity('entity2'))
.targetReferenceField('id_entity')
.targetFields([
nga.field('id').label('ID'),
nga.field('value').label('description')
])
.permanentFilters({
entity: 'team' // display only the metadata relevant for entity1
})
that should show all results from entity2 related to entity1 with applying a filter.
It works for entities on the same host but in this case it tries to make make a connection to ENTITY1_ADMIN_API_HOST instead of ENTITY2_ADMIN_API_HOST as well which is wrong.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (1 by maintainers)
@pdhoward No, I use a
ma-filtered-list-button
now instead of thereferenced_list
so that I have at least a button pointing to the information which I wanted to show directly.@dirkaholic method is the easiest way to achieve this purpose. Closing the issue.
Feel free to re-open it if it doesn’t solve your usecase.