Enable contributors to remove individual facility list items from public display #619
Conversation
5c7ca96
to
d95d8eb
Compare
d95d8eb
to
7322c56
Compare
Looking at this now. |
There was a problem hiding this 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
src/django/api/views.py
Outdated
.filter(facility_list_item=facility_list_item) \ | ||
.update(is_active=False) | ||
|
||
updated_facility_list_item = FacilityListItem \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
||
import { facilityListItemStatusPropType } from '../util/propTypes'; | ||
|
||
import { listTableCellStyles } from '../util/styles'; | ||
|
||
import { makeFacilityDetailLink } from '../util/util'; | ||
|
||
const propsAreEqual = (prevProps, nextProps) => |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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([ |
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
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' }}
There was a problem hiding this comment.
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
Oof, thanks for catching the missing filter on the facilities search endpoint. I added it in 151f6a4 which will suppress matches with |
This is ready for another look! |
cadef0e
to
0ccc557
Compare
Rebased this on |
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
0ccc557
to
9103513
Compare
There was a problem hiding this 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.
Awesome! Thanks for your help with this! |
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
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
./scripts/manage resetdb
,./scripts/manage processfixtures
,./scripts/server
and then sign in as c6@exampleChecklist
fixup!
commits have been squashed