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

Edit object references #175

Merged
merged 7 commits into from
Sep 30, 2017
Merged

Edit object references #175

merged 7 commits into from
Sep 30, 2017

Conversation

itsjgf
Copy link
Contributor

@itsjgf itsjgf commented Sep 28, 2017

Closes #168 and closes #37.

Summary

  1. You can edit an object reference by double clicking on it or right click + “Update reference”.
  2. When the modal is open, a list with the current possible references appears and the “Ok” button displays “Set to null”.
  3. Once you select a new object, the button will change from ‘Set to null’ to ‘Set’.

Additional changes which are not related to this PR:

  1. Table: Enable row selection on click and editing on double click.
  2. Row highlighting: Add missing columnIndex.
  3. Edit cell: Add missing autofocus.

@itsjgf itsjgf changed the title (WIP) Edit object references Edit object references Sep 28, 2017
@bigfish24
Copy link
Contributor

bigfish24 commented Sep 29, 2017

Testing this out it looks pretty good, but the UI/UX is difficult due to the selection behavior.

It should be that a single-click selects a row and a double-click goes into edit for a cell.

When I right click on an object reference, I would expect the row to be highlighted:
image

The row is not highlighted so it is hard to see which object I right clicked on. Also, minor, but I think "Update Reference" should be first.

Similarly, on the modal to select a reference:
image

I think you should select the row, then click have the blue button change to "Set" vs. "Set to null" to confirm the selection. @kraenhansen thoughts?

@itsjgf
Copy link
Contributor Author

itsjgf commented Sep 29, 2017

Totally agree. I was trying to avoid changing the current cell implementation which is not highlighting rows nor managing click/double click 'properly'.

Working on it 😊.

Copy link
Member

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes required - and I did a small commit on the branch as well.

style={{ userSelect: 'none', cursor: 'pointer' }}
onClick={e => {
e.stopPropagation();
e.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? What is the default behaviour of clicking a div?

onCellChange: (object: any, propertyName: string, value: string) => void;
onListCellClick: (
onCellChange?: (object: any, propertyName: string, value: string) => void;
onListCellClick?: (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reasoning behind making these optional?

Copy link
Contributor Author

@itsjgf itsjgf Sep 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to be able to reuse the table (e.g to select a row), there are some props that should be optional, like that one.

@@ -121,6 +121,14 @@ $realm-browser-header-icon-space: 24px;
flex-direction: column;
}

&__SelectObject{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&__SelectObject { <- missing a space :)

display: flex;
flex-direction: column;
padding:0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a space .. here as well. And the properties are not ordered, are you SCSS linting?

object: any,
property: Realm.ObjectSchemaProperty,
value: any,
) => void;
onColumnWidthChanged: (index: number, width: number) => void;
schema: Realm.ObjectSchema | null;
rowToHighlight: number | null;
rowToHighlight?: number | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that this can now both be undefined (because it's optional) and null because of its type.
I think it should just be

rowToHighlight?: number

or just left as

rowToHighlight: number | null

Otherwise we have two ways of checking if no row is selected (if we're not using Number.isInteger(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that null was there cause the old linter was throwing some errors. Totally true, we have to re-check the types.

min-height: 300px;
padding: 0;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some spaces and sorted the lines - are you running the SASS linter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn’t worry too much about this. We were going to propose yesterday to use prettier + stylelinter so we don’t have to fix this stuff manually, but the new features seemed more important.
Also, we could add css-modules in order to avoid long class names (e.g RealmBrowser__Content__Cell could be just cell or Cell).

I can fix them right now if that's a priority 😛

<ModalFooter>
{optional && (
<Button color="primary" onClick={() => updateReference(null)}>
Set to null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be the primary action - if we had a way to select the row in the content table - I would also expect there to be a primary button to "Select" the object of which row was selected, instead for this happening when simply clicking the row.

schema={schema}
data={data}
onRowClick={updateReference}
onListCellClick={updateReference}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this PR didn't add the onListCellClick but this name confuses me - and why would I need to define this property here, wouldn't the click bubble to the onRowClick callback anyway?

Copy link
Contributor Author

@itsjgf itsjgf Sep 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t add that prop but that’s the one handling the click event for “complex types (Objects/Lists), the simple types don’t have one (they got one internally assigned tho!).

I think that we should have only one onClick event for the cells (from onListCellClick to onCellClick and pass it to simples types too) and add another one for onDoubleClick (onCellDoubleClick). And get rid of onRowClick 😅.

What do you think about it?

Copy link
Member

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of making progress over perfection - let's get this merged.

@bigfish24
Copy link
Contributor

It’s not clear if Commite is around on the weekend so we should merge if we are happy.

@itsjgf itsjgf merged commit bc3858a into master Sep 30, 2017
@itsjgf itsjgf deleted the jg/edit-object-reference branch September 30, 2017 18:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants