Skip to content

Commit bcc200c

Browse files
SebieFcalixtus
andauthored
Update sorting of entries in maintable by special fields immediately (#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]>
1 parent 1face3f commit bcc200c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
5555

5656
### Fixed
5757

58+
- We fixed that sorting of entries in the maintable by special fields is updated immediately [#9334](https://github.com/JabRef/jabref/issues/9334)
5859
- We fixed the Cleanup entries dialog is partially visible [#9223](https://github.com/JabRef/jabref/issues/9223)
5960
- We fixed the display of the "Customize Entry Types" dialogue title [#9198](https://github.com/JabRef/jabref/issues/9198)
6061
- 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)

src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,24 @@ public ObservableValue<List<AbstractGroup>> getMatchedGroups() {
104104

105105
public ObservableValue<Optional<SpecialFieldValueViewModel>> getSpecialField(SpecialField field) {
106106
OptionalBinding<SpecialFieldValueViewModel> value = specialFieldValues.get(field);
107+
// Fetch possibly updated value from BibEntry entry
108+
Optional<String> currentValue = this.entry.getField(field);
107109
if (value != null) {
108-
return value;
110+
if (currentValue.isEmpty() && value.getValue().isEmpty()) {
111+
var zeroValue = getField(field).flatMapOpt(fieldValue -> field.parseValue("CLEAR_RANK").map(SpecialFieldValueViewModel::new));
112+
specialFieldValues.put(field, zeroValue);
113+
return zeroValue;
114+
} else if (value.getValue().isEmpty() || !value.getValue().get().getValue().getFieldValue().equals(currentValue)) {
115+
// specialFieldValues value and BibEntry value differ => Set specialFieldValues value to BibEntry value
116+
value = getField(field).flatMapOpt(fieldValue -> field.parseValue(fieldValue).map(SpecialFieldValueViewModel::new));
117+
specialFieldValues.put(field, value);
118+
return value;
119+
}
109120
} else {
110121
value = getField(field).flatMapOpt(fieldValue -> field.parseValue(fieldValue).map(SpecialFieldValueViewModel::new));
111122
specialFieldValues.put(field, value);
112-
return value;
113123
}
124+
return value;
114125
}
115126

116127
public ObservableValue<String> getFields(OrFields fields) {

0 commit comments

Comments
 (0)