Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Only show contributed extended fields in embed sidebar search #1794

Merged
merged 2 commits into from
Apr 13, 2022

Conversation

emilyhu0106
Copy link
Contributor

@emilyhu0106 emilyhu0106 commented Apr 8, 2022

Overview

In embed mode, we only want the extended profile fields that are contributed by the contributor to appear on the filter sidebar. Perviously, it would be a confusing experience for an Embedded Map if the Embedded Map owner had not contributed Type of Product, but that still appeared as a searchable field on their map.

This PR add extended_fields to embed_configs endpoint and use the returned value to check if the extended profile fields are contributed by the user.

Connects #1561

Demo

2022-04-08 16 26 28

Notes

When users contributing facilities with extended fields, we will match the processing type with the associated facility type based on taxonomy (see #1616), which means we may populate the facility type / processing type automatically without explicitly contributing that field.

Testing Instructions

This PR assumes resetdb has been run.

  • Check out this branch, run ./script/update
  • Log in as c3@example.com, and make sure it has any level of embed access
    • Open embed mode and there should be no "More Filter" since no extended fields are contributed
    • Open OAR front-page and make sure the sidebar looks as normal
  • Contribute ExtendedFieldsTestListLimited.csv and fully process it using ./tools/batch-process {list-id}
    • Open embed mode, extend "More Filters", and make sure only "Facility Type", "Number of Workers", "Processing Type", and "Product Type" filters are shown.
    • Open OAR front-page and make sure the sidebar looks as normal

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

@emilyhu0106 emilyhu0106 marked this pull request as ready for review April 11, 2022 16:20
Copy link
Contributor

@jwalgran jwalgran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to this correctly hiding fields from the search form. There is a stray model field and migration that I think we can remove as well as some extra whitesapce that we can avoid by slightly adjusting how we hide the search fields.

@@ -2280,6 +2280,20 @@ class EmbedConfig(models.Model):
blank=False,
default='default',
help_text='The map style for the embedded map')
extended_fields = postgres.ArrayField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We derive the list the list embed fields dynamically in the EmbedConfig serializer so we do not need a database field. We should be able to remove this field and delete the migration without affecting functionality.

Make sure to run ./scripts/manage migrate 0088 to un-apply the migration from your development database before you delete it.

@@ -0,0 +1,19 @@
# Generated by Django 2.2.24 on 2022-04-06 23:33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We derive the list the list embed fields dynamically in the EmbedConfig serializer so we do not need a database field. We should be able to remove this field and delete the migration without affecting functionality.

Make sure to run ./scripts/manage migrate 0088 to un-apply the migration from your development database before you delete it.

@@ -194,110 +198,160 @@ function FilterSidebarExtendedSearch({
</div>
</div>
<div className="form__field">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing this with an API submission that included only 1 of the 5 extended fields I saw a large amount of white space in the embed sidebar

Screen Shot 2022-04-11 at 3 19 16 PM

Consider moving these <div className="form__field"> tags inside the ShowOnly tags so that we don't render extra empty divs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I did see some white spaces but didn't connect it with the empty div

@emilyhu0106
Copy link
Contributor Author

This PR is ready for another look. Please run update to make sure 0088 is the latest migration

Copy link
Contributor

@jwalgran jwalgran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I demoed this in our sprint review and it worked well. Thank you.

@jwalgran jwalgran removed their assignment Apr 13, 2022
@emilyhu0106
Copy link
Contributor Author

Thank you for reviewing!

In embed_configs endpoint, return a new extended_fields array that
includes field names contributed by this specific contributor.
Exclude extended profile fields from search in side bar if the fields
are not returned from the endpoint. When no extended fields are
contributed, "More Filter" button is hidden from the sidebar search.
@emilyhu0106 emilyhu0106 force-pushed the eh/certain-extended-fields-in-embed branch from 189085d to c9c44e0 Compare April 13, 2022 14:42
@emilyhu0106 emilyhu0106 merged commit 197aa5a into develop Apr 13, 2022
@emilyhu0106 emilyhu0106 deleted the eh/certain-extended-fields-in-embed branch April 13, 2022 14:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants