-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
feat: add "create new" functonality to SelectMany #5125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces a "Create new" link to the SelectMany components provided the following are true: - The relation is of type "oneToMany" (that is, "Belongs to many" in the content type builder, or a bidirectional relation). - The item has already been created and is being edited. This enables a simpler workflow: previously, one would have to go to the ListView of the related model, create a new entry, save it, go back to the item we were editing, and associate the newly created entry to the item. Now, the user can click the "Create new" link, create the new item, and it will be automatically associated to the source item. When the user saves it, they will be redirected back to the EditView of the source item. This only works on "Belongs to many" relations, and not in "Has many", because the association is made from the target model's creation view, and not from the source model's edit view. Therefore, we need the relation to be bidirectional. Signed-off-by: Pablo Rodríguez Caballero <pablo@rodriguezcaballero.me>
|
@MeLlamoPablo Could you share a screenshot of the implementation in the UI? I would love to help you to make sure it follows the current UX/UI guidelines. Also, make sure you are using the graphical elements provided by our components library Buffet.js. |
|
Here's a screenshot of the current UI: As I said, it's pretty barebones, I just wanted to showcase the concept. Here's a video of the current workflow: |
|
Wow, thank you for sharing this! I've a few questions:
Otherwise, it's pretty dope! Well done 👏 |
|
Hello!
The way it works is the following: in the There is no special connection between the two entities' edit views. When you click the "add new" link, you are actually leaving the source entity's edit page (meaning that any unsaved changes will be lost). That is why we don't display the link on the creation mode: because we have no id yet, and we can't automatically link it on the destination entry. Keep in mind that my knowledge of the codebase is limited. We needed to deliver this feature to a client who requested it, and I found that to be the easiest way to do it. That's why it probably seems hacky. Which brings me to the next point:
I agree that this would be a better UX, but I'm not sure of how complex it is (might be just embedding another In this case, the linking would be done in the inverse: instead of going to the destination entry and selecting the source entry's id, we would create the destination entry, save it, and add its id to the array of related entities in the source entry. This would have the advantage of allowing to link a new entity on creation. We would also have to handle different cases in Also, if you take a look at my original comment:
You'll see that by switching the place where the association is made, we can overcome this limitation: by linking the destination entry in the source edit view, we can make it work for unidirectional relations too. So, in a nutshell, I agree that your suggestion is a better way to implement this feature. |
|
Any update on this? This is an awesome feature! |
|
Sorry for the late reply. We've discussed it and it seems more complicated than expected. We do like the feature and we do want to implement it. However, we have to consider that it will have conflicts with the permissions system and the internationalization of the content. Also, we have to think about UX. The modal might be a good choice, but it has to be larger than the currently available in the UI kit of Strapi. In this modal, we have to display the relational fields too. But for these, we should not allow the on-the-fly creation of relational data to avoid nested creation of new entries. Then, we have to add functionality to the SelectOne component as well. Due to all the identified problems, we decided to pause the feature. We will come back to you when we will have released the permissions system. I've added the card in our roadmap though. |
|
Thank you for this. I'm closing this PR. If needed we will open a github discussion for this ;) |
|
This pull request has been mentioned on Strapi Community. There might be relevant details there: |
|
Is there any update for this feature? |
|
Is this ever going to be implemented? This is pretty much elementary feature... |
|
+1 |
|
Any updates on this? |

Description of what you did:
This PR introduces a "Create new" link to the SelectMany component provided the following are true:
This enables a simpler workflow: previously, one would have to go to the ListView of the related model, create a new entry, save it, go back to the item we were editing, and associate the newly created entry to the item.
Now, the user can click the "Create new" link, create the new item, and it will be automatically associated to the source item. When the use saves it, they will be redirected back to the EditView of the source item.
This only works on "Belongs to many" relations, and not in "Has many", because the association is made from the target model's creation view, and not from the source model's edit view. Therefore, we need the relation to be bidirectional.
I'm marking this PR as a draft because it is untested, undocumented, and un-i18n'd. I wanted to receive some feedback on this feature before putting more work into it. The new link is also not styled at all, which I'm not sure if is okay for the project.
My PR is a:
Main update on the:
Manual testing done on the following databases:
Thanks for your time.