Skip to content

Workaround missing "Optional 2" display#11022

Merged
Siedlerchr merged 24 commits into
mainfrom
fix-tab-optional2
Mar 19, 2024
Merged

Workaround missing "Optional 2" display#11022
Siedlerchr merged 24 commits into
mainfrom
fix-tab-optional2

Conversation

@koppor

@koppor koppor commented Mar 13, 2024

Copy link
Copy Markdown
Member

In biblatex mode, when resetting the preferences, JabRef displayed "Optional fields" and "Optional fields 2":

312461887-4dc364ff-7cd1-4b8f-94ac-1fe7ef0cc424

When opening the preferences, navigating to "customize entry types" and immediately saving, the "Optional fields 2" disappears and only "Optional fields" are displayed. Moreover, there is no choice between required fields (e.g., author or editor), JabRef now requires both.

This PR adds a work around: Customized entry types are only stored by JabRef if there was any change. If the fields required and optional are the same as in the respective standard type, there is no writing (and no handling). Thus "Optional fields 2" will stay for non-customized types.

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.

Comment thread src/main/java/org/jabref/model/entry/field/StandardField.java

private BibEntryType getStandardArticleType(BibDatabaseMode mode) {
return entryTypesManager.getEntryTypes(mode).standardTypes.stream().filter(t -> StandardEntryType.Article.equals(t.getType())).findAny().get();
return entryTypesManager.getEntryTypes(mode).standardTypes.stream().filter(t -> StandardEntryType.Article == t.getType()).findAny().get();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better use findFirst to get it ina reliable way

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is only one standard type? Thus, I thought, findAny could be faster?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does it matter in a test? have we ever had problems with reliability of these tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think, somewhere in the main code, I also had it. Chris might be afraid of "Heisenbugs" :)

koppor added 2 commits March 14, 2024 19:42
# Conflicts:
#	src/main/java/org/jabref/model/entry/BibEntryTypesManager.java
@koppor koppor marked this pull request as draft March 14, 2024 19:42
@koppor

koppor commented Mar 14, 2024

Copy link
Copy Markdown
Member Author

I added a test to illustrate the issue - e497592 (#11022)

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 14, 2024
@koppor koppor marked this pull request as ready for review March 14, 2024 23:43
@Siedlerchr

Copy link
Copy Markdown
Member

I am now constantly getting library changed messages when entering texst:
otherkey.bib.zip

@github-actions

github-actions Bot commented Mar 19, 2024

Copy link
Copy Markdown
Contributor

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

@koppor

koppor commented Mar 19, 2024

Copy link
Copy Markdown
Member Author

Cannot reproduce on main. Happens in this branch.

Could reproduce once in this branch.

Restarted JabRef startet with the file again. Could not trigger the issue again. -- @Siedlerchr Do you remember what steps you did? :)

@koppor

koppor commented Mar 19, 2024

Copy link
Copy Markdown
Member Author

I could reproduce it when adding spaces to the citation key and then pressing "Dismiss Changes". Then saving. Then "Dismiss Changes".

@Siedlerchr Siedlerchr enabled auto-merge March 19, 2024 19:06
@Siedlerchr Siedlerchr added this pull request to the merge queue Mar 19, 2024
Merged via the queue into main with commit 49eb6b2 Mar 19, 2024
@Siedlerchr Siedlerchr deleted the fix-tab-optional2 branch March 19, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants