Skip to content

Commit

Permalink
AB#1163 Disable left merge column when pre-selected
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten authored and Chessray committed Jul 9, 2024
1 parent 9da4f95 commit 29ef625
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions client/src/pages/admin/merge/MergeLocations.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const MergeLocations = ({ pageDispatchers }) => {
locationFormat={locationFormat}
setLocationFormat={setLocationFormat}
locationFormatLabel={locationFormatLabel}
disabled={!!initialLeftUuid}
/>
</Col>
<Col md={4} id="mid-merge-loc-col">
Expand Down Expand Up @@ -386,6 +387,7 @@ function getLocationFilters() {
const LocationColumn = ({
align,
label,
disabled,
mergeState,
dispatchMergeActions,
locationFormat,
Expand Down Expand Up @@ -418,6 +420,8 @@ const LocationColumn = ({
fields={Location.allFieldsQuery}
addon={LOCATIONS_ICON}
vertical
disabled={disabled}
showRemoveButton={!disabled}
/>
</ColTitle>
{areAllSet(location) && (
Expand Down Expand Up @@ -644,6 +648,7 @@ const LocationColumn = ({
LocationColumn.propTypes = {
align: PropTypes.oneOf(["left", "right"]).isRequired,
label: PropTypes.string.isRequired,
disabled: PropTypes.bool,
mergeState: PropTypes.object,
dispatchMergeActions: PropTypes.func,
locationFormat: PropTypes.oneOf(Object.keys(Location.LOCATION_FORMATS))
Expand Down
5 changes: 5 additions & 0 deletions client/src/pages/admin/merge/MergeOrganizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const MergeOrganizations = ({ pageDispatchers }) => {
dispatchMergeActions={dispatchMergeActions}
align={ALIGN_OPTIONS.LEFT}
label="Organization 1"
disabled={!!initialLeftUuid}
/>
</Col>
<Col md={4} id="mid-merge-org-col">
Expand Down Expand Up @@ -456,6 +457,7 @@ const organizationsFilters = {
const OrganizationColumn = ({
align,
label,
disabled,
mergeState,
dispatchMergeActions
}) => {
Expand Down Expand Up @@ -488,6 +490,8 @@ const OrganizationColumn = ({
fields={Organization.allFieldsQuery}
addon={ORGANIZATIONS_ICON}
vertical
disabled={disabled}
showRemoveButton={!disabled}
/>
</ColTitle>
{areAllSet(organization) && (
Expand Down Expand Up @@ -856,6 +860,7 @@ const OrganizationCol = styled.div`
OrganizationColumn.propTypes = {
align: PropTypes.oneOf(["left", "right"]).isRequired,
label: PropTypes.string.isRequired,
disabled: PropTypes.bool,
mergeState: PropTypes.object,
dispatchMergeActions: PropTypes.func
}
Expand Down
12 changes: 11 additions & 1 deletion client/src/pages/admin/merge/MergePeople.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const MergePeople = ({ pageDispatchers }) => {
dispatchMergeActions={dispatchMergeActions}
align={ALIGN_OPTIONS.LEFT}
label="Person 1"
disabled={!!initialLeftUuid}
/>
</Col>
<Col md={4} id="mid-merge-per-col">
Expand Down Expand Up @@ -469,7 +470,13 @@ const peopleFilters = {
}
}

const PersonColumn = ({ align, label, mergeState, dispatchMergeActions }) => {
const PersonColumn = ({
align,
label,
disabled,
mergeState,
dispatchMergeActions
}) => {
const person = mergeState[align]
const idForPerson = label.replace(/\s+/g, "")

Expand All @@ -496,6 +503,8 @@ const PersonColumn = ({ align, label, mergeState, dispatchMergeActions }) => {
fields={Person.allFieldsQuery}
addon={PEOPLE_ICON}
vertical
disabled={disabled}
showRemoveButton={!disabled}
/>
</ColTitle>
{areAllSet(person) && (
Expand Down Expand Up @@ -855,6 +864,7 @@ const PersonCol = styled.div`
PersonColumn.propTypes = {
align: PropTypes.oneOf(["left", "right"]).isRequired,
label: PropTypes.string.isRequired,
disabled: PropTypes.bool,
mergeState: PropTypes.object,
dispatchMergeActions: PropTypes.func
}
Expand Down
12 changes: 11 additions & 1 deletion client/src/pages/admin/merge/MergePositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const MergePositions = ({ pageDispatchers }) => {
dispatchMergeActions={dispatchMergeActions}
align={ALIGN_OPTIONS.LEFT}
label="Position 1"
disabled={!!initialLeftUuid}
/>
</Col>
<Col md={4} id="mid-merge-pos-col">
Expand Down Expand Up @@ -429,7 +430,13 @@ function getPositionFilters(mergeState, align) {
}
}

const PositionColumn = ({ align, label, mergeState, dispatchMergeActions }) => {
const PositionColumn = ({
align,
label,
disabled,
mergeState,
dispatchMergeActions
}) => {
const position = mergeState[align]
const hideWhenEmpty =
!Location.hasCoordinates(mergeState[MERGE_SIDES.LEFT]?.location) &&
Expand Down Expand Up @@ -458,6 +465,8 @@ const PositionColumn = ({ align, label, mergeState, dispatchMergeActions }) => {
fields={Position.allFieldsQuery}
addon={POSITIONS_ICON}
vertical
disabled={disabled}
showRemoveButton={!disabled}
/>
</ColTitle>
{areAllSet(position) && (
Expand Down Expand Up @@ -712,6 +721,7 @@ const PositionCol = styled.div`
PositionColumn.propTypes = {
align: PropTypes.oneOf(["left", "right"]).isRequired,
label: PropTypes.string.isRequired,
disabled: PropTypes.bool,
mergeState: PropTypes.object,
dispatchMergeActions: PropTypes.func
}
Expand Down
4 changes: 4 additions & 0 deletions client/tests/webdriver/baseSpecs/showLocation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ describe("Show location page", () => {
expect(
await (await MergeLocations.getLeftLocationField()).getValue()
).to.contain("Antarctica")
// eslint-disable-next-line no-unused-expressions
expect(
await (await MergeLocations.getLeftOrganizationField()).isEnabled()
).to.be.false
})
})
})
4 changes: 4 additions & 0 deletions client/tests/webdriver/baseSpecs/showOrganization.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ describe("Show organization page", () => {
expect(
await (await MergeOrganizations.getLeftOrganizationField()).getValue()
).to.contain("EF 2.2")
// eslint-disable-next-line no-unused-expressions
expect(
await (await MergeOrganizations.getLeftOrganizationField()).isEnabled()
).to.be.false
})
})
})
3 changes: 3 additions & 0 deletions client/tests/webdriver/baseSpecs/showPerson.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ describe("Show person page", () => {
expect(
await (await MergePeople.getLeftPersonField()).getValue()
).to.contain("BRATTON, Creed")
// eslint-disable-next-line no-unused-expressions
expect(await (await MergePeople.getLeftOrganizationField()).isEnabled())
.to.be.false
})
})
})
4 changes: 4 additions & 0 deletions client/tests/webdriver/baseSpecs/showPosition.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ describe("Show position page", () => {
expect(
await (await MergePositions.getLeftPositionField()).getValue()
).to.contain("EF 5.1 Advisor Quality Assurance")
// eslint-disable-next-line no-unused-expressions
expect(
await (await MergePositions.getLeftOrganizationField()).isEnabled()
).to.be.false
})
})
})

0 comments on commit 29ef625

Please sign in to comment.