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

Enable users to update approved claimed facility profiles & display claim info in the details sidebar #575

Merged
merged 2 commits into from
Jun 13, 2019

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Jun 11, 2019

Overview

This PR enables users with approved facility claims to edit these claims using a form on the /claimed/claimID route and also updates the facility details sidebar to display that info beneath the existing facility data.

I spun off the work of sending emails to a separate card.

I also spun off adding some multiselect tag fields to a separate card, since we don't really yet know the set of tags for these fields. It occurred to me that we can also remove & defer adding the minimum_order_quantity and average_lead_time fields, too, for now since users can currently just include this info in a free form way in the facility_description field.

Connects #518

Demo

Screen Shot 2019-06-12 at 1 59 23 PM

Screen Shot 2019-06-11 at 9 13 22 PM

Testing Instructions

  • get this branch, then resetdb, processfixtures, switch on the claim a facility and create a superuser
  • sign up for an account through the UI, then fill out a claim a facility form
  • sign in as the superuser and approve the claim
  • sign back in as the other user and visit the OAR ID for the facility you have claimed. Clicking on the claim badge will now take you to your approved claim (if signed out, clicking on the badge will go to a not-yet-existing /about/claimedfacilities route
  • verify that the claimed facility profile form loads and that you can edit and save the fields and that those changes get reflected accurately in the facility details UI

Checklist

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

@kellyi
Copy link
Contributor Author

kellyi commented Jun 12, 2019

I am spinning off the multiselect fields for "certifications", "product types", and "production types" to #576 since we may need to spend some time cataloging the set of options before adding those.

@kellyi
Copy link
Contributor Author

kellyi commented Jun 12, 2019

Remaining work here:

  • link details verified badge to /about/claimedfacilities for users who have not claimed the facility and to /claimed/ID for users who have claimed the facility
  • update the user serializer to send back a list of the OAR IDs for a user's pending & approved facility claims
  • change country inputs to react select boxes

@kellyi
Copy link
Contributor Author

kellyi commented Jun 12, 2019

I spun off emailing contributors on profile changes to #578

@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch from fc67a70 to 1e6b6b7 Compare June 12, 2019 17:58
@kellyi kellyi changed the title WIP claimed facility profile Enable users to update approved claimed facility profiles & display claim info in the details sidebar Jun 12, 2019
@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch from 1e6b6b7 to 91e8732 Compare June 12, 2019 18:10
@kellyi kellyi requested a review from jwalgran June 12, 2019 18:10
@kellyi kellyi marked this pull request as ready for review June 12, 2019 18:10
@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch 2 times, most recently from 9092aa2 to 641f248 Compare June 13, 2019 00:36
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.

The form looks sharp and the core flow is working well. I found a few items that need to be addressed and suggested some follow up issues.

/>

<ClaimInfoSection
label="Claimed Facility Description"
Copy link
Contributor

Choose a reason for hiding this comment

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

The wireframes do not have a "Claimed Facility ..." prefix on these fields. Consider dropping the prefix to reduce some visual noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3c0b219

I also added a header to indicate what the info represents. I think we will also need to add some kind of disclaimed or link to the about page here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2019-06-13 at 11 04 45 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disclaimer message issue is #588

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider dropping the "Facility" prefix too. All the information in the sidebar is about the facility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped the "Facility" prefix in e374b2d

Screen Shot 2019-06-13 at 11 21 37 AM

@@ -146,20 +139,38 @@ class FacilityDetailSidebar extends Component {
{data.properties.name}
</h3>
<p className="panel-header__subheading notranslate">
{data.properties.address} - {data.properties.country_name}
{data.properties.address} -{' '}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we need to change this line? {' '} is not something we see regularly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this got added by running Prettier on this file in my editor; it's how Prettier preserves displayed space chars when breaking text across lines. I can put this all on a single line, though, and remove the {' '}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 1bf02ca


<ClaimInfoSection
label="Claimed Facility Address"
value={`${facility.address || ' '} ${facility.country || ' '}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

facility.country is the country code. We probably want the country name in this situation.

But...

I want to double check that we want to have a country field on the form at all. If the country on a row is wrong, it should be corrected at higher level (the facility, or even the facility list item)

Copy link
Contributor Author

@kellyi kellyi Jun 13, 2019

Choose a reason for hiding this comment

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

Good point. For now I'll remove the facility country selection and field altogether from the form & model (but leave the one for office country). If we decide we do want to allow changing a facility claim country, then we can add it back later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 9c3296b

label="Claimed Facility Phone Number"
/>
<ClaimInfoSection
value={facility.minimum_order}
Copy link
Contributor

Choose a reason for hiding this comment

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

The model field is minimum_order_quantity but in some places we are using minimum_order. I can't save a value in the the minimum order field and I think the naming inconsistency is the reason.

2019-06-12 17 21 21

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9c3296b

return []

try:
contributor = Contributor.objects.get(admin=user)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using some features of the Django ORM to simplify this a bit

return (FacilityClaim.objects
        .filter(status=FacilityClaim.APPROVED)
        .filter(contributor=user.contributor)
        .values_list('facility__id', flat=True))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! This is in 5d2e4de

data={data.properties.claim_info}
/>
</ShowOnly>
</FeatureFlag>
<div className="control-panel__group">
<div style={detailsSidebarStyles.linkSectionStyle}>
<a
Copy link
Contributor

Choose a reason for hiding this comment

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

The wireframes show conditionally hiding these links if the logged in contributor has claimed the facility, since the do not apply to the claimant. Instead, the wireframes have a link to the profile editing page above the satellite image. Since we already have access to facilityIsClaimedByCurrentUser we should consider implementing this link swapping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handled in be9749d

Not my claimed facility:

Screen Shot 2019-06-13 at 11 34 49 AM

My claimed facility:

Screen Shot 2019-06-13 at 11 34 54 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the verified badge will already also conditionally link to the facility claim form if it is my claimed facility.

disabled={updating}
/>
<InputSection
label="Email"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider creating a follow up issue to add email address validation to this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be trivial to incorporate here, so I can just add it in this PR. I think we want to validate isEmpty(email) || isEmail(email) for this field, and probably disable the save button concurrently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 9c3296b

onSwitchChange={updateFacilityPhoneVisibility}
/>
<InputSection
label="Website"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider creating a follow up issue to add url validation to this field and to render it as an active link in the sidebar (using the same conditional "http://" appending that we use on the contributor profile page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is/will be #587

onChange={updateOfficePhone}
disabled={updating}
/>
{errorUpdating && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider opening an issue to use full_clean on the model to trigger Django's model validation and generate helpful error messages that we can show to the claimant. We do this when parsing uploaded files https://github.com/open-apparel-registry/open-apparel-registry/blob/8fdc09c4d6cac5f4aefc3a313e9c04d84e5ab49f/src/django/api/processing.py#L127

We are currently returning 500 when the claimant enters too many characters into a field.

Screen Shot 2019-06-12 at 8 18 06 PM

We could also make use of maxlength to prevent these types of errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made #589 for handling it. I think we could also use the existing serializer to check somehow.

color="primary"
disabled={updating}
>
Submit
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider "Save" or "Save Changes" instead of "Submit"

Also consider showing some "toast" or similar if there is a 200 response. Right now there is no indication that the save succeeded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Save" is in 86904d2

toast is in cd8cc08

@kellyi
Copy link
Contributor Author

kellyi commented Jun 13, 2019

@jwalgran I believe I've addressed all the feedback above, so this is ready for another look!

I updated the new migration, so testing will need to start from resetdb again.

@kellyi
Copy link
Contributor Author

kellyi commented Jun 13, 2019

I'm going to squash this down again.

@jwalgran
Copy link
Contributor

Thanks for all the revisions. Taking another look.

@jwalgran
Copy link
Contributor

Running into a prop type error when selecting a facility on the map

2019-06-13 09 05 06

Warning: Failed prop type: The prop `data` is marked as required in `FacilityDetailsSidebarClaimedInfo`, but its value is `null`.
    in FacilityDetailsSidebarClaimedInfo (at FacilityDetailSidebar.jsx:221)
    in FacilityDetailSidebar (created by Connect(FacilityDetailSidebar))
    ...

@kellyi
Copy link
Contributor Author

kellyi commented Jun 13, 2019

Fixed the propType error in 381817e

@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch from d53d5c4 to 381817e Compare June 13, 2019 16:11
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.

This is working perfectly. Thanks for all the time put into this implementation.

@kellyi
Copy link
Contributor Author

kellyi commented Jun 13, 2019

Awesome, thanks for all your help with this!

@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch from 381817e to 6b5365c Compare June 13, 2019 16:18
- update model and add migration for editable facility claim profile
fields
- add Redux actions & React components for editable claimed facility
profile form
- adjust FacilityDetailsSerializer to return facility claim info
conditionally
- add FacilityDetailSidebarClaimedInfo component to display claim info
Ensure dashboard claims are always displayed in reverse order by adding
-id sort.
@kellyi kellyi force-pushed the ki/claim-a-facility-profile branch from 6b5365c to b6027e1 Compare June 13, 2019 16:21
@kellyi kellyi merged commit de69c3b into develop Jun 13, 2019
@kellyi kellyi deleted the ki/claim-a-facility-profile branch June 13, 2019 16:27
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