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

Enable contributors to remove individual facility list items from public display #619

Merged
merged 3 commits into from Jun 24, 2019

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Jun 19, 2019

Overview

This PR enables list contributors to remove list items. Removing an item will keep it on a list but suppress it from displaying on the facility details page in any way. I designed this in line with the specs detailed in #594.

Connects #594

Demo

Screen Shot 2019-06-20 at 5 37 38 PM

Screen Shot 2019-06-20 at 5 37 46 PM

Notes

In principle there is no reason why we cannot also remove list items with a status of "POTENTIAL_MATCH". However I did not have implement a UI for doing that, partly because the actions area for those rows is already kind of busy and partly because list items that are not yet matched don't show up on the facility details page anyway.

Testing Instructions

  • get branch then ./scripts/manage resetdb, ./scripts/manage processfixtures, ./scripts/server and then sign in as c6@example
  • in one tab, search for the facility named "Cotia". On its details page verify that there is a link to the contributor page for c6
  • visit the facility lists for c6 and search for "Cotia". Use the UI to remove the facility and verify that the row changes its opacity on success and that you see the "REMOVED" status.
  • try out the status filters and verify that "REMOVED" and the others work correctly
  • look at the details page for "Cotia" and very that the contributor is no longer associated with the facility
  • try removing some other facilities and verify that that also works. You may want to sign in as c2 or c8 and remove facilities from those lists, as you should test out that you can also remove "MATCHED" and "CONFIRMED_MATCH" list items -- and not just "NEW_FACILITY" items.

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 kellyi force-pushed the ki/remove-list-items branch 7 times, most recently from 5c7ca96 to d95d8eb Compare June 20, 2019 21:35
@kellyi kellyi changed the title WIP Ki/remove list items Enable contributors to mark facility list items as "REMOVED" Jun 20, 2019
@kellyi kellyi changed the title Enable contributors to mark facility list items as "REMOVED" Enable contributors to remove facility list items from public display Jun 20, 2019
@kellyi kellyi changed the title Enable contributors to remove facility list items from public display Enable contributors to remove individual facility list items from public display Jun 20, 2019
@kellyi kellyi requested a review from jwalgran June 20, 2019 21:43
@kellyi kellyi marked this pull request as ready for review June 20, 2019 21:44
@jwalgran
Copy link
Contributor

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.

Remove is working as intended and suppressing the contributor association on the details page but we need to also suppress the contributor association when searching for facilities.

Cotia still shows up on http://localhost:6543/?contributors=6

Screen Shot 2019-06-24 at 12 39 37 PM

.filter(facility_list_item=facility_list_item) \
.update(is_active=False)

updated_facility_list_item = FacilityListItem \
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 facility_list_item.refresh_from_db() rather than a filtered get.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Replaced in 7322c56

<Typography
style={facilityListItemsTableStyles.dialogTextStyles}
>
Do you really want to remove this list item?
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider explaining that removed facilities may still appear on the facility map, but they will not be associated with your organization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea -- I adjusted this in 6912094

Screen Shot 2019-06-24 at 4 35 01 PM


import { facilityListItemStatusPropType } from '../util/propTypes';

import { listTableCellStyles } from '../util/styles';

import { makeFacilityDetailLink } from '../util/util';

const propsAreEqual = (prevProps, nextProps) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider explaining in the commit message why we are removing propsAreEqual.

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'll add this when squashing the fixups. We dropped this because we're no longer using React.memo on this component.

&& isEqual(prevProps.hover, nextProps.hover)
&& isEqual(prevProps.newFacility, nextProps.newFacility)
&& isEqual(prevProps.oarID, nextProps.oarID);
const makeTableRowStyles = cond([
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the power that cond and conforms give us, but we should consider that in cases like this where we are mapping 2 values that don't have any complex interactions, a lower-order solution is more compact and arguably more easily understood.

const makeTableRowStyles = ({ handleSelectRow, isRemoved}) => {
    const pointerStyle = isFunction(handleSelectRow) ? { cursor: 'pointer' } : {};
    const opacityStyle = isRemoved ? { opacity: '0.6' } : {};
    return merge(pointerStyle, opacityStyle);
}

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 changed this in 90eb513 to be:

const makeTableRowStyles = ({ handleSelectRow, isRemoved }) => ({
    cursor: isFunction(handleSelectRow) ? 'pointer' : 'auto',
    opacity: isRemoved ? '0.6' : '1.0',
});

{title}
</span>
<Button
variant="contained"
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 a stock button. The full column of blue buttons draws a lot of focus. Contrast these with the approve/reject buttons, which we absolutely need the contributor to click on. The remove buttons are an optional feature that we may want to call less attention to.

Screen Shot 2019-06-24 at 12 33 51 PM

diff --git a/src/app/src/components/FacilityListItemsTableRow.jsx b/src/app/src/components/FacilityListItemsTableRow.jsx
index 55936de..8d0748e 100644
--- a/src/app/src/components/FacilityListItemsTableRow.jsx
+++ b/src/app/src/components/FacilityListItemsTableRow.jsx
@@ -113,7 +113,6 @@ const FacilityListItemsTableRow = ({
                                 {newFacility ? 'NEW_FACILITY' : status}
                             </span>
                             <Button
-                                variant="contained"
                                 color="primary"
                                 onClick={handleRemoveItem}
                                 style={{ marginLeft: '5px', marginRight: '5px' }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good -- I adjusted these buttons in 2a796e6

@kellyi
Copy link
Contributor Author

kellyi commented Jun 24, 2019

Oof, thanks for catching the missing filter on the facilities search endpoint. I added it in 151f6a4 which will suppress matches with is_active=False from appearing in the contributors & contributor types results.

@kellyi
Copy link
Contributor Author

kellyi commented Jun 24, 2019

This is ready for another look!

@kellyi kellyi force-pushed the ki/remove-list-items branch 2 times, most recently from cadef0e to 0ccc557 Compare June 24, 2019 22:03
@kellyi
Copy link
Contributor Author

kellyi commented Jun 24, 2019

Rebased this on develop

@jwalgran jwalgran self-requested a review June 24, 2019 22:05
Kelly Innes added 3 commits June 24, 2019 18:18
Update model & create a migration to add an `is_active` field to
FacilityMatch.
- add remove endpoint for facility list item which updates `is_active`
for each of the list item's facility matches to `False`
- add tests for remove endpoint
- add buttons + logic for removing facility list items
- style removed rows with 0.6 opacity
- exclude removed list items from display on the facility list details
screen
- enable filtering by REMOVED status in the facility list items table
- remove React.memo & propsAreEqual from FacilityListItemsTableRow & let
React figure out the re-rendering conditions directly
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.

Removals are working well. Thanks for the fixups. I used c8@example.com to test pending matches and it works perfectly.

@jwalgran jwalgran assigned kellyi and unassigned jwalgran Jun 24, 2019
@kellyi
Copy link
Contributor Author

kellyi commented Jun 24, 2019

Awesome! Thanks for your help with this!

@kellyi kellyi merged commit 0fe7ea2 into develop Jun 24, 2019
@kellyi kellyi deleted the ki/remove-list-items branch June 24, 2019 22:54
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