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

Conversation

PaulBoon
Copy link
Contributor

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:

@coveralls
Copy link

Coverage Status

coverage: 22.736%. remained the same
when pulling d72766a on PaulBoon:IQSS/11272-FixOrderOnAdvancedSearchPage
into 2210d16 on IQSS:develop.

@@ -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.

Copy link
Member

@qqmyers qqmyers left a 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.

@qqmyers qqmyers added the Size: 3 A percentage of a sprint. 2.1 hours. label Feb 20, 2025
@jggautier
Copy link
Contributor

jggautier commented Feb 20, 2025

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:

Screenshot 2025-02-20 at 11 56 25 AM

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:

Screenshot 2025-02-20 at 12 00 43 PM

@jggautier
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: 3 A percentage of a sprint. 2.1 hours.
Projects
Status: Ready for Triage
Development

Successfully merging this pull request may close these issues.

Advanced search page does not use the display order of the metadata fields
4 participants