0

Currently I have a <TabbedShowLayout> presenting resource data and related data. I want a view to make relations with resource. I was trying to have a tab that changed its contents based on route and for that used Switch and Route but no success with that. The base route was supposed to be something like resource/id/show/related-model-tab/ and for adding relation something like addremove was added to the previous route.

I want to have a component to render on the 1st route, and another in the 2nd. Since RA doesn't support a feature like this yet, should I use Switch and Route components from React Router, or should I use the customRoutes in order to show relation add/remove components outside the tabbed layout?

Mário Ferreiro
  • 317
  • 3
  • 12

1 Answers1

0

The answer is neither. RA doesn't support nested routes in Tab in v2.1.1 or under, the best solution to preserve the behaviour is to have the Tab change its content only based in a flag. For example if flag is not active, show a list of related items, if flag is active show the possibility to add or remove related items.

Even without the route specification it's probably a more dynamic solution than have a custom route for every related model addition or removal. If there were too many model relations it could be a cumbersome to have a customRoute to each relation.

Mário Ferreiro
  • 317
  • 3
  • 12