-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Better relationship display. #3063
base: master
Are you sure you want to change the base?
Conversation
LGTM, nice work! |
@mxstbr although I think it looks better I also think it can be improved further. For example, I think it lends itself to a single table. Although not sure how easy that would be to do. What do you think? |
Bad key press in cell phone closed this unexpectedly...reopened :=) @mxstbr^ |
@JedWatson @mxstbr this is now looking like this: As you can see all relationships are now under a single table and the column names are more explicit to match the relationship configuration in a list. |
@@ -22,7 +23,9 @@ const RelatedItemsList = React.createClass({ | |||
getColumns () { | |||
const { relationship, refList } = this.props; | |||
const columns = refList.expandColumns(refList.defaultColumns); | |||
return columns.filter(i => i.path !== relationship.refPath); | |||
const refListNameColumn = columns.filter(i => i.path === refList.nameField.path); | |||
const refListRelationshipFieldColumn = columns.filter(i => i.path === relationship.refPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, I'd prefer those two to be:
columns.filter((column) => column.something === somethingElse);
(am not too fussed about the parentheses, but why call the variable inside the filter i
when it's a column
? Makes it harder to understand when skimming the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was just following the consistency of whomever did it first :-) will update
Did a proper code review (should've done previously, my bad!), left a few comments and nitpicks but the new table looks great! 👍 Good work! |
@mxstbr thanks for the code review...this is still in-progress as need to still handle nameless relationships. btw, not sure why my other github ID (epihacker) is being used for the commits...very confusing :-) |
@JedWatson @mxstbr I now deem this change set complete. I tested as many use cases of relationships as I could think of to make sure all displays fine. The display is now flexible in that it handles named/unnamed relationships, labeled/unlabeled relationships, and different relationship cardinalities. Again, the display also tries to reflect the relationship configuration to make it easier to reason about. |
LGTM from a code perspective, ping @JedWatson who has a bigger overview of the feature set here. |
@webteckie tbh I'm a bit confused about the problem this is solving, and what your solution actually does (vs. how I expected relationships to behave; agreed there are bugs and/or missing features in the current implementation that we need to address!) In ca use-case with lots of related items coming in from a single relationship, I would think this update (as I understand it) would make it harder to use, esp. for example in a scenario where pagination / etc is involved... But I don't know that I understand what you've done properly. Can you describe it for me, maybe with some example List definitions to go along with the screenshots of how it now works? |
@JedWatson to me the way things are now is a bit difficult to reason about when relationship values exist as well as the display doesn't make sense when you have multiple relationships defined and no, yet, filled. Obviously, this seems to be a subjective thing I guess since you seem to think the current display is adequate :-) As far as showing examples, I think it's best that you pull it down and compare the existing and the proposed with different relationship configurations. |
@JedWatson not sure pagination is a relevant issue here since the rows in the table always relate to the number of relationship fields configured in the active list. You would never expect that to be a huge number of fields. To see the actual full set of relationship values in the field you still need to go to the parent list (same as the previous display). I tried to go back to take some snapshots of the previous display to compare and can't even do it. For the exact same item above this is what I see: Doesn't compare! :-) |
if (this.state.err) { | ||
return <div className="Relationship">{this.state.err}</div>; | ||
tbody = <tr><td>{this.state.err}</td></tr>; | ||
} else if (this.state.items && this.state.items.results && this.state.items.results.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would read a lot easier with
} else {
const results = this.state.items && this.state.items.results
if (results) {
if (results.length) {...} else {...}
}
also, making the spinner tbody only in a final else clause prevents unnecessary React.createElement calls.
👍 |
}, | ||
renderRelationshipTableBody () { | ||
const loadedItems = this.state.items; | ||
const results = this.state.items && this.state.items.results; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const results = loadedItems && loadedItems.results;
fef1eda
to
4fb5fc1
Compare
4fb5fc1
to
d2e387b
Compare
@@ -38,7 +38,7 @@ const ItemsRow = React.createClass({ | |||
}); | |||
// item fields | |||
var cells = this.props.columns.map((col, i) => { | |||
var ColumnType = Columns[col.type] || Columns.__unrecognised__; | |||
var ColumnType = Columns[col.type] || Columns.text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JedWatson I had a KS frontend crash due to Columns.__unrecognised__
, so I'm happy with this line, but I presume that the idea was to actually define a column type __unrecognised__
so that it would show in a specific way in the UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there used to be an __unrecognised__
type, which would warn that an implementation was missing. Looks like it was lost - I think we should add it back again, rather than quietly defaulting to text
. Having a type without an implementation is an error case, and means something's gone wrong at a really low level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JedWatson how would you handle cases where a list does not have a name mapping? In that case, the item ID, which doesn't not have a representative field type shows. That's what the text
default is doing here ;=)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just leaving a note here to clarify that this has been fixed in master
@JedWatson LGTM |
return columns.filter(i => i.path !== relationship.refPath); | ||
const refListNameColumn = columns.filter(column => column.path === refList.namePath || (column.path === 'id' && refList.namePath === '_id')); | ||
const refListRelationshipFieldColumn = columns.filter(column => column.path === relationship.refPath); | ||
return [refListNameColumn[0], refListRelationshipFieldColumn[0]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webteckie, I'm seeing this second column as undefined, causing problems during render. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So unless the referring field is in the default columns of the referring list, this crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wmertens probably an issue in the original code as well? I can look into this, but I'm hesitant to spend any more time on this if @JedWatson is not going to merge it :=)
4d0f9d6
to
d0f0fd6
Compare
d0f0fd6
to
2a80be7
Compare
@webteckie I fixed the column issue, split out the crash fixes, and rebased. |
@webteckie now that I've had some time to play with it, I do think the information could be presented better. I would prefer a sub-heading per relationship, and then a list with the named links to the referrers, with a simple Also, I would prefer if the value were only shown for many-relationships, otherwise you get a lot of repetition. |
Pie in the sky: how about, when you click on a relationship, it folds open a quick view of the item, without editing fields? Kind of like the movie detail view in NetFlix |
it seems like what you describe above is the way things are :-) The reason for this PR is because that doesn't seem to work that well for me :-)
That could work, I guess. Feel free :-) |
Description of changes
This change hopes to provide a better user experience when browsing the relationship display for items. As currently implemented the updated display looks as follows:
Related issues (if any)
#2319
Testing
npm run test-all
ran successfully.