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

Fix the order of fields on the AdvancedSearch Page #11279

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

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?

Copy link
Contributor Author

@PaulBoon PaulBoon Feb 20, 2025

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.

Copy link
Member

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:

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);
}
so no need to sort by block here.

}

public List<DatasetFieldType> findAllFacetableFieldTypes() {
Expand Down