-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[WIP] New (Multi-)Relation Widget #1928
Conversation
Deploy preview for netlify-cms-www ready! Built with commit c9758d8 |
Deploy preview for netlify-cms-www ready! Built with commit 01fade7 |
Deploy preview for cms-demo ready! Built with commit 01fade7 |
Nice work! But I think I would be more in favor of keeping the current behavior of the |
Hey @alexandernanberg, thanks for chiming in. (: I fully agree and I'm not at all opposed to reimplementing the current But this PR tries to solve a different issue. named: consistent multiple relations. (and a custom UI) I'm very concerned with UX for the editing interface, as it reduces support requests and anxiety. Actually on my case I go a little further and filter the options based on another field on the entry. (that part is not on this PR) Specifically on my case, there can be multiple authors that go by exactly the same name (it's scoped by semesters, on a same semester they are unique, across all time they aren't). So saving only name doesn't cut for me, and if someone change it's name, the linking is broken. that's why I think saving Regarding
|
The custom UI "hack" looks really, really cool. Relations are inherently tricky with no database. What you're trying to do is an approximation of relational database behavior where records are referenced by a unique ID rather than based on their values, which, as you mentioned, may change. What you're doing makes sense - a tl;dr version of your requirements seems to be:
Let me know if that's incorrect or lacking. I do believe that this is compatible with the current relation widget, we'd just add a |
Can I haz? Also in the select widget! 😄 |
Will try to get some time this weekend. (: I really liked @erquhart suggestion: adding an option for using only slugs in the That would also solve the migration from I'd like some feedback on the approach of Thanks for the positive feedback on "UI hacks"! (: |
This looks awesome! Can you add docs updates to your checklist? 😉 |
Added [WIP] in title. Once you are ready @leonardodino just remove it from the title. |
thanks @talves (: it's indeed WIP, but there are a couple of roadblocks: #1013 #1936. I'm proposing moving this to the |
#2010 merged instead, as requested. |
Summary
Add a new
relation
-like widget capable of selecting multiple entries (also support single).It's based on
react-select
, as the newselect
from #1901.Motivation (TLDR; we need a multi-relation widget)
I'm working on my college campus newspaper website, and using
NetlifyCMS
to manage it's contents. It's working great! I'm really glad this awesome project is being maintained (:The journalism students from a dedicated online news course are the ones editing it, It currently uses an extended version of the relation widget for selecting author and the category. It's a bit hacky, especially considering it saves an object (title + slug), although it can only select a single author. The most requested feature was multi-author attribution in the posts.
relation
widgetPR
I'm saving the
title
so it's more readable in the CMS UI, although that complicates a lot linking the files in Gatsby, and adds potentially stale data.The ideal for this case is an array of slugs, but requires that the CMS can resolve slugs back to data to have a nice UI, hence exporting
loadEntry
action, and persisting onlyslugs
(incompatible with currentrelation
).How it looks
All of the styling work is directly borrowed from the recent update in the
select
field by @alexandernanberg (:It should, probably, be de-duplicated later by exporting it from
netlify-cms-ui-default
or something like that.How it works
It saves the related entry slug, or array of slugs, and pulls it back when displaying it. The autocomplete list still renders from the
queryHits
, as in the originalrelation
.Based on my limited knowledge of
SSG
(mostlyGatsby
andharp
), and file based CMS (kirby
andstacey
), linking by the slug, granted it's stable as in NetlifyCMS, is the least painful method of linking entries together.Caveats
It is incompatible with the current
relation
, because there's novalueField
option.displayFields
is possible but not implemented, as ajs
constructor or composing seems a better way to configure it, as demonstrated in the motivation image.Test plan
[WIP]
probably will do something based of theselect
widget as well.this is WIP
I've opened it here for discussion.
It seems to be working right now, but it lacks tests, and it could be improved in some ways.
Also, it's not compatible with current
relation
widget, and probably never will.naming (will extend currentSlugRelation
is a bad name, need suggestions)relation
relation
widget (re: @erquhart)select
. (move tonetlify-cms-ui-default
, probably another PR)but I'm sure it's not consistentprettier 🎉)A picture of a cute animal (not mandatory but encouraged)