Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

webteckie
Copy link
Contributor

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:
image

Related issues (if any)

#2319

Testing

  • Please confirm npm run test-all ran successfully.

@mxstbr
Copy link
Collaborator

mxstbr commented Jun 21, 2016

LGTM, nice work!

@webteckie
Copy link
Contributor Author

webteckie commented Jun 21, 2016

@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?

@webteckie webteckie closed this Jun 21, 2016
@webteckie webteckie reopened this Jun 21, 2016
@webteckie
Copy link
Contributor Author

Bad key press in cell phone closed this unexpectedly...reopened :=) @mxstbr^

@webteckie
Copy link
Contributor Author

@JedWatson @mxstbr this is now looking like this:
image

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);
Copy link
Collaborator

@mxstbr mxstbr Jun 23, 2016

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)

Copy link
Contributor Author

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

@mxstbr
Copy link
Collaborator

mxstbr commented Jun 23, 2016

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!

@webteckie
Copy link
Contributor Author

@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 :-)

@webteckie
Copy link
Contributor Author

@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.

@mxstbr
Copy link
Collaborator

mxstbr commented Jun 24, 2016

LGTM from a code perspective, ping @JedWatson who has a bigger overview of the feature set here.

@JedWatson
Copy link
Member

@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?

@webteckie
Copy link
Contributor Author

webteckie commented Jun 25, 2016

@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.

@webteckie
Copy link
Contributor Author

Latest display looks like this...the parent relationship is now always displayed even if no relationship items configured:

image

@webteckie
Copy link
Contributor Author

@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:

image

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) {
Copy link
Contributor

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.

@wmertens
Copy link
Contributor

👍

},
renderRelationshipTableBody () {
const loadedItems = this.state.items;
const results = this.state.items && this.state.items.results;
Copy link
Contributor

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;

@webteckie webteckie force-pushed the relationship-display-enhancements branch from fef1eda to 4fb5fc1 Compare June 30, 2016 15:07
@webteckie webteckie force-pushed the relationship-display-enhancements branch from 4fb5fc1 to d2e387b Compare June 30, 2016 20:42
@@ -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;
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

@webteckie webteckie Jul 6, 2016

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 ;=)

Copy link
Member

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

@wmertens
Copy link
Contributor

wmertens commented Jul 1, 2016

LGTM

@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]];
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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 :=)

@wmertens wmertens force-pushed the relationship-display-enhancements branch from 4d0f9d6 to d0f0fd6 Compare July 5, 2016 13:05
@wmertens wmertens force-pushed the relationship-display-enhancements branch from d0f0fd6 to 2a80be7 Compare July 5, 2016 13:11
@wmertens
Copy link
Contributor

wmertens commented Jul 5, 2016

@webteckie I fixed the column issue, split out the crash fixes, and rebased.

@wmertens
Copy link
Contributor

wmertens commented Jul 5, 2016

@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 - referringField: value after it. That way, long names and long many-relationships can use the whole line.

Also, I would prefer if the value were only shown for many-relationships, otherwise you get a lot of repetition.

@wmertens
Copy link
Contributor

wmertens commented Jul 5, 2016

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

@webteckie
Copy link
Contributor Author

@wmertens

I would prefer a sub-heading per relationship, and then a list with the named links to the referrers, with a simple - referringField: value after it.

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 :-)

how about, when you click on a relationship, it folds open a quick view of the item, without editing fields?

That could work, I guess. Feel free :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants