How to create an searchable add-reference-button/action in admin-on-rest?

Viewed 219

Consider a case where I have a functional JSON backend, and the admin-on-rest resources company, user and company_user.

The data is as follows

company

  • id
  • name
  • address ...etc.

user

  • id
  • name
  • phone
  • address ...etc.

company_user

  • id
  • company_id (references company)
  • user_id (references user)
  • position ...etc.

It is very easy to have a separate top-level resource view for the company_user resource type; but it should really be editable per user and per company, on preferably on a tab of the user, or the company resource views.

Thus comes the problem: how to create a tab for user resource, where I can list the current company-references (company_user rows), but in the same tab I need a sane way to do the following functionality:

  1. search for all the companies that are not currently referred to by this user (of course there is an API call for that);
  2. add a row to to the company_user collection and;
  3. refresh the tab
1 Answers
Related