Skip to content

Commit

Permalink
Update sorting of entries in maintable by special fields immediately (#…
Browse files Browse the repository at this point in the history
…9338)

* Updating specialFieldValues with possibly modified value from BibEntry

Workaround that is necessary because specialFieldValues and entry.fields get updated separately (entry.fields before speicalFieldValues). This lead to the behaviour that when sorting for a special field in the maintaible (like ranking or read status), the sorting does not get updated properly on change.

* Updating changelog with #9334

* Removing unnecessary comment

Co-authored-by: Carl Christian Snethlage <[email protected]>

Co-authored-by: Carl Christian Snethlage <[email protected]>
  • Loading branch information
SebieF and calixtus authored Nov 3, 2022
1 parent 1face3f commit bcc200c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed that sorting of entries in the maintable by special fields is updated immediately [#9334](https://github.com/JabRef/jabref/issues/9334)
- We fixed the Cleanup entries dialog is partially visible [#9223](https://github.com/JabRef/jabref/issues/9223)
- We fixed the display of the "Customize Entry Types" dialogue title [#9198](https://github.com/JabRef/jabref/issues/9198)
- We fixed an issue where author names with tilde accents (for example ñ) were marked as "Names are not in the standard BibTex format" [#8071](https://github.com/JabRef/jabref/issues/8071)
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,24 @@ public ObservableValue<List<AbstractGroup>> getMatchedGroups() {

public ObservableValue<Optional<SpecialFieldValueViewModel>> getSpecialField(SpecialField field) {
OptionalBinding<SpecialFieldValueViewModel> value = specialFieldValues.get(field);
// Fetch possibly updated value from BibEntry entry
Optional<String> currentValue = this.entry.getField(field);
if (value != null) {
return value;
if (currentValue.isEmpty() && value.getValue().isEmpty()) {
var zeroValue = getField(field).flatMapOpt(fieldValue -> field.parseValue("CLEAR_RANK").map(SpecialFieldValueViewModel::new));
specialFieldValues.put(field, zeroValue);
return zeroValue;
} else if (value.getValue().isEmpty() || !value.getValue().get().getValue().getFieldValue().equals(currentValue)) {
// specialFieldValues value and BibEntry value differ => Set specialFieldValues value to BibEntry value
value = getField(field).flatMapOpt(fieldValue -> field.parseValue(fieldValue).map(SpecialFieldValueViewModel::new));
specialFieldValues.put(field, value);
return value;
}
} else {
value = getField(field).flatMapOpt(fieldValue -> field.parseValue(fieldValue).map(SpecialFieldValueViewModel::new));
specialFieldValues.put(field, value);
return value;
}
return value;
}

public ObservableValue<String> getFields(OrFields fields) {
Expand Down

0 comments on commit bcc200c

Please sign in to comment.