question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

referenced_list does not respect entity specific baseApiUrl

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dirkaholiccommented, Apr 7, 2016

@pdhoward No, I use a ma-filtered-list-button now instead of the referenced_list so that I have at least a button pointing to the information which I wanted to show directly.

0reactions
jpetitcolascommented, Nov 21, 2016

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found