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

Display processing and facility type #1624

Merged
merged 2 commits into from
Feb 7, 2022

Conversation

caseycesari
Copy link
Contributor

Overview

Show the processing type(s) and facility type(s) for a facility in the facility details sidebar.

Also, reorder the extended fields in the sidebar so that processing type and facility type are next to each other.

Connects #1618

Demo

Screen Shot 2022-02-03 at 1 07 39 PM

Testing Instructions

Checklist

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

@jwalgran
Copy link
Contributor

jwalgran commented Feb 3, 2022

Looking at this now.

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.

When I tested a file with 2 processing types (processing-type-2.csv) I saw duplicate facility types, which is expected based on our implementation

Screen Shot 2022-02-03 at 12 08 11 PM

II was able to resolve this by adding some logic and renaming our existing list formatting helper

diff --git a/src/app/src/components/FacilityDetailSidebarExtended.jsx b/src/app/src/components/FacilityDetailSidebarExtended.jsx
index bad608f..666e9b1 100644
--- a/src/app/src/components/FacilityDetailSidebarExtended.jsx
+++ b/src/app/src/components/FacilityDetailSidebarExtended.jsx
@@ -84,8 +84,8 @@ const detailsSidebarStyles = theme =>
 const formatAttribution = (createdAt, contributor) =>
     `${moment(createdAt).format('LL')} by ${contributor}`;
 
-const formatIfList = value =>
-    Array.isArray(value) ? value.map(v => <li>{v}</li>) : value;
+const formatIfListAndRemoveDuplicates = value =>
+    Array.isArray(value) ? [...new Set(value)].map(v => <li>{v}</li>) : value;
 
 /* eslint-disable camelcase */
 const formatExtendedField = ({
@@ -96,7 +96,7 @@ const formatExtendedField = ({
     id,
     formatValue = v => v,
 }) => ({
-    primary: formatIfList(formatValue(value)),
+    primary: formatIfListAndRemoveDuplicates(formatValue(value)),
     secondary: formatAttribution(updated_at, contributor_name),
     verified,
     key: id,

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.

Other than the duplication this works as intended. If you like my suggested diff and include it, consider this approved.

@caseycesari
Copy link
Contributor Author

@jwalgran Good catch. I forgot that having two processing types will now add two facility types. I'll integrate your diff.

@caseycesari
Copy link
Contributor Author

@jwalgran I implemented your fix, and did some more testing. In the case when two facilities have been matched, and they have the same processing or facility type, this is what it will look like:

Screen Shot 2022-02-03 at 3 33 56 PM

Do we want to remove duplicate values across extended field type entries (the current code only does it within the same entry)?

A similar thing happens with product type as well:

Screen Shot 2022-02-03 at 3 37 09 PM

@jwalgran
Copy link
Contributor

jwalgran commented Feb 4, 2022

Handling the cases when a contributor submits the same extended field values multiple times is something that we should address, but is outside the scope of this PR since, as you mentioned, it is not just related to the processing type and facility type fields.

I created #1626 to follow up on this.

@caseycesari caseycesari force-pushed the cpc/display-facility-processing-type branch from 6bd42ae to 80c5eb6 Compare February 7, 2022 16:40
Show the processing type(s) and facility type(s) for a facility in the
facility details sidebar.

Also, reorder the extended fields in the sidebar so that processing type
and facility type are next to each other.

Refs #1618
@caseycesari caseycesari force-pushed the cpc/display-facility-processing-type branch from 80c5eb6 to 364bc36 Compare February 7, 2022 17:03
@caseycesari caseycesari merged commit ddd941b into develop Feb 7, 2022
@caseycesari caseycesari deleted the cpc/display-facility-processing-type branch February 7, 2022 17:08
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