-
Notifications
You must be signed in to change notification settings - Fork 500
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
Fix the order of fields on the AdvancedSearch Page #11279
base: develop
Are you sure you want to change the base?
Fix the order of fields on the AdvancedSearch Page #11279
Conversation
@@ -93,7 +93,7 @@ public class DatasetFieldServiceBean implements java.io.Serializable { | |||
String oldHash = null; | |||
|
|||
public List<DatasetFieldType> findAllAdvancedSearchFieldTypes() { | |||
return em.createQuery("select object(o) from DatasetFieldType as o where o.advancedSearchFieldType = true and o.title != '' order by o.id", DatasetFieldType.class).getResultList(); | |||
return em.createQuery("select object(o) from DatasetFieldType as o where o.advancedSearchFieldType = true and o.title != '' order by o.displayOrder,o.id", DatasetFieldType.class).getResultList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since displayOrder is within the metadatablock, should this be order by metadatablock_id, displayOrder to keep things ordered by block, using displayOrder within the block? Is order by o.id still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep o.id
because that is a fallback when the displayOrder is the same and what has been used thus far.
Not sure about the metadatablock_id, because I don't expect the fields start moving to other blocks if we don't use it in ordering.
I mean, it does not change the advanced search page, it might be nice for someone debugging the code and watching the result of the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh - I see the code pulls things out per block after this query:
dataverse/src/main/java/edu/harvard/iq/dataverse/search/AdvancedSearchPage.java
Lines 76 to 87 in 2210d16
this.metadataFieldList = datasetFieldService.findAllAdvancedSearchFieldTypes(); | |
for (MetadataBlock mdb : metadataBlocks) { | |
List<DatasetFieldType> dsfTypes = new ArrayList<>(); | |
for (DatasetFieldType dsfType : metadataFieldList) { | |
if (dsfType.getMetadataBlock().getId().equals(mdb.getId())) { | |
dsfTypes.add(dsfType); | |
} | |
} | |
metadataFieldMap.put(mdb.getId(), dsfTypes); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. I would suggest adding a one line release note though, e.g. - metadata fields on the Advanced Search page are now shown in display order.
Would this include the Persistent ID and Publication Date fields? that we see on the dataset page's Metadata tab but that are not configurable with the metadata block TSV files? When viewing the Citation Metadata on the dataset page's Metadata tab, those fields appear at the top: But they're "system generated" metadata and not configurable with the Citation metadata block TSV file, and they're at the bottom of the Advanced Search page: |
I should mention that I'm really interested in a discussion, even just a brief one here, that helps me understand if the order of those two fields will change when users see the Advanced Search page, and I'm not necessarily suggesting that this PR be changed to reorder those two fields. |
What this PR does / why we need it:
Have advanced search page use a query that orders by displayOrder before id, so that it will use the displayOrder if available instead of ignoring it.
Which issue(s) this PR closes:
Special notes for your reviewer:
Suggestions on how to test this:
Use a custom metadata block (tsv file) and change the order in a way that it is different from the rows order in the file, like change the last one to have order
0
.Then load that tsv and check the advanced search page, before the fix it would not be at the top, but after the fix it will be.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?:
Additional documentation: