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

Enable editing typo with double clicking on field name in custom entry type #9977

Merged
merged 15 commits into from
Jun 8, 2023

Conversation

DinjerChang
Copy link
Contributor

@DinjerChang DinjerChang commented Jun 6, 2023

References #9840

This PR is related to the second todo in #9840
We enable the editing feature for user when they have typo when customizing the new field.

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

Screenshot 2023-06-05 at 5 43 04 PM
Screenshot 2023-06-05 at 5 43 18 PM
Screenshot 2023-06-05 at 5 43 39 PM

Comment on lines 164 to 170
} else {
dialogService.showWarningDialogAndWait(
Localization.lang("Duplicate fields"),
Localization.lang("Warning: You added field \"%0\" twice. Only one will be kept.", newFieldValue));
event.getTableView().edit(-1, null);
event.getTableView().refresh();
}
Copy link
Member

Choose a reason for hiding this comment

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

Modern software seldom makes use of popups. I would use the notifiy functionality. The user has no choice. Moreover, the current code keeps the old casing. Thus, instead of newFieldValue, the existing one should be output. As a consequence, the code of fieldExists needs to be modified accordingly.

Copy link
Contributor Author

@DinjerChang DinjerChang Jun 6, 2023

Choose a reason for hiding this comment

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

The reason I use newFieldValue instead of the existing one is to see if the user input value (newFieldValue) exist in the current fields. Let's say we already have two new Field, Name and Test. When a user try to edit Name to Test, he would double click the Name Field and type "Test", so "Test" is the newFieldValue. So I think we have to see what user input is and compare it with the existing Field. In this case, Test already exist, so we will notify the user.

If we choose the existing one by using the method field.getDisplayName(), the value would be Name since we haven't modify the field yet. In this case, we always get the fieldExists value to be True

Also, I'm replacing equals with equlsIgnoreCase to handle the casing comparison problem.
Let's say a user edit Name to name, it should be and will be seen as duplicate field.

Let me know if I understand statement correctly and if I'm on the right track :)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry that I was not clear in my terms. Thank you for explaining a scenario. I hope, this short explanation based on your scenario helps:

I was trying to say: User renames to TEST, but Test exists. I assume the user knows, he input TEST, but forgot about the existing field Test. Therefore, Test should be displayed and not TEST.

…ing user input value with existing value of field
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

One more thing:

  1. Double click on a field
  2. Press enter

Expected behavior: Field is as kept as is - and no notificaiton is output

Actual behavior: Field is kapt AND an notification is output:

image

I think, in if (fieldExists) inside an additional check needs to be made. Maybe also before - if the old name is the new name

DinjerChang and others added 2 commits June 7, 2023 10:44
…fter double click then click enter, change negataion to positvie of fieldExists
Comment on lines 160 to 161
boolean fieldExists = entryFields.stream().anyMatch(fieldViewModel ->
fieldViewModel.nameProperty().getValue().equalsIgnoreCase(newFieldValue));
fieldViewModel.nameProperty().getValue().equalsIgnoreCase(newFieldValue) && !newFieldValue.equals(field.getDisplayName()));
Copy link
Member

Choose a reason for hiding this comment

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

The new condition does not make use of ´fieldViewModel `

I think, following code matches your intention:

boolean fieldExists = !newFieldValue.equals(field.getDisplayName()) && entryFields.stream().anyMatch(fieldViewModel ->
                            fieldViewModel.nameProperty().getValue().equalsIgnoreCase(newFieldValue));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I shouldn't put it in the anyMatch() method when streaming

koppor
koppor previously approved these changes Jun 8, 2023
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Thank you for keeping working on this!

I think, UI tests for this are hard. Thus, this PR is OK from my side!

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 8, 2023
@koppor
Copy link
Member

koppor commented Jun 8, 2023

@DinjerChang In future, please chechk if an issue is assigned to a person and if the person is on your team. It seams that the issue was assigned to @eric052199, which probably is not on your team? -- Do you intend to work on the first item of the TODO, too?

@calixtus
Copy link
Member

calixtus commented Jun 8, 2023

Modified changelog, since this was not a fix for a bug, but a small and most welcome enhancement. Thanks!

@DinjerChang
Copy link
Contributor Author

DinjerChang commented Jun 8, 2023

@koppor @calixtus Sorry I forgot to mention that Eric and I are on the same team.
I'll take some time researching on the first todo to see if I could fix it!
Another subject, when working on the second todo, I took some references of the file org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.java line 66 ~ 68 and
org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java #addNewField().
I think maybe those parts need some refactoring like the dialog.notify() and the if-else negation statement of fieldExists that we modified in this PR, just for your information.
Overall, thanks for the heads up!

@Siedlerchr
Copy link
Member

@DinjerChang That sounds good. I would suggest you create a new PR then and we merge this one

Siedlerchr
Siedlerchr previously approved these changes Jun 8, 2023
@koppor
Copy link
Member

koppor commented Jun 8, 2023

When the user entered the same field twice, the old field value is kept. Thus, the notification message is wrong. We fixed that.

image

@calixtus calixtus merged commit 5ca1ad8 into JabRef:main Jun 8, 2023
@koppor
Copy link
Member

koppor commented Jun 9, 2023

While discussing it with a group of maintainers of JabRef, we worked on the code again: PR is #9993. We hope to get this merged the next days, so that you have a good foundation to work on the core issue.

For the different field properties, a good start are tests. A skeletton is provided at https://github.com/JabRef/jabref/pull/9993/files#diff-420e1dfef38c9004e74cc9b2074499e837558303f00e177c9312ccd38def62e1. It could be used to work on the serialization format proposed at step 10 at #9840 (comment).

@DinjerChang DinjerChang deleted the fix-for-issue-9840 branch June 18, 2023 20:51
@DinjerChang DinjerChang restored the fix-for-issue-9840 branch June 18, 2023 20:51
Siedlerchr added a commit that referenced this pull request Jan 1, 2024
* upstream/main: (68 commits)
  Fix issue 9863 - Change Tab selection order (#9907)
  New Crowdin updates (#9994)
  Enable editing typo with double clicking on field name in custom entry type (#9977)
  Remove "Field name:" from localization - we already have "Field name" (#9991)
  Changed database to catalog in org.jabref.gui.slr and org.jabref.logic.crawler (#9989)
  Use environment variables for hostname detection (#9910)
  Add cleanup activity for URL field (#9970)
  Fix freezing when fetching IBSN and no results are found (#9987)
  Make Group(Node)TreeViewModel more OO (#9978)
  Fix container for group item count still visible if display count is off  (#9980)
  Fix paste of BibTeX data (#9985)
  Bring back SimplifyBoolean* and UnnecessaryParantheses (and refine guide) (#9981)
  Add new menu entry to remove braces from selection, aka unprotect it. (#9968)
  User specific comment (#9727)
  Bump org.openrewrite.recipe:rewrite-recipe-bom from 1.19.3 to 2.0.0 (#9975)
  Fix typos
  Remove non-needed link
  Fix typos
  Enable RemoveJavaDocAuthorTag (#9973)
  Bump com.fasterxml.jackson.datatype:jackson-datatype-jsr310 (#9974)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bib(la)tex status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants