Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TTAHUB-3437] Modals should be immediately after the control that spawned them #2465

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/ApprovedReportSpecialButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default function ApprovedReportSpecialButtons({
{showUnlockReports && user && user.permissions && canUnlockReports(user)
? <ModalToggleButton type="button" className="usa-button usa-button--outline no-print" modalRef={modalRef} opener>Unlock report</ModalToggleButton>
: null}
{showUnlockReports && <UnlockModal /> }
</Grid>
{showUnlockReports && <UnlockModal /> }
</>
);
}
Expand Down
152 changes: 75 additions & 77 deletions frontend/src/components/GoalCards/ObjectiveCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,93 +101,91 @@ function ObjectiveCard({
const modalIdentifier = uniqueId('objective-suspend-identifier-');

return (
<>
<ul data-testid="objectiveList" className="ttahub-goal-card__objective-list usa-list usa-list--unstyled padding-2 margin-top-2 bg-base-lightest radius-lg" hidden={!objectivesExpanded}>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Objective </span>
<div>{title}</div>
</li>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Activity reports </span>
<ul className="usa-list usa-list--unstyled">
{activityReports.map((report) => {
const viewOrEditLink = `/activity-reports/view/${report.id}`;
const linkToAr = report.legacyId ? `/activity-reports/legacy/${report.legacyId}` : viewOrEditLink;
return (
<li key={`AR-${report.id}`}>
<Link
to={linkToAr}
>
{report.displayId}
</Link>
</li>
);
})}
</ul>
</li>
{supportType && (
<ul data-testid="objectiveList" className="ttahub-goal-card__objective-list usa-list usa-list--unstyled padding-2 margin-top-2 bg-base-lightest radius-lg" hidden={!objectivesExpanded}>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Objective </span>
<div>{title}</div>
</li>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Activity reports </span>
<ul className="usa-list usa-list--unstyled">
{activityReports.map((report) => {
const viewOrEditLink = `/activity-reports/view/${report.id}`;
const linkToAr = report.legacyId ? `/activity-reports/legacy/${report.legacyId}` : viewOrEditLink;
return (
<li key={`AR-${report.id}`}>
<Link
to={linkToAr}
>
{report.displayId}
</Link>
</li>
);
})}
</ul>
</li>
{supportType && (
<li className="display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 minw-15">Support type </span>
{supportType}
</li>
)}
<li className="display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 minw-15">Grant numbers </span>
{grantNumbers.join(', ')}
</li>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">End date </span>
{endDate}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Topics</span>
{topics.join(', ')}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Reasons</span>
{reasons && displayReasonsList(reasons)}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Objective status </span>
<div>
{(statusChangeError && (
)}
<li className="display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 minw-15">Grant numbers </span>
{grantNumbers.join(', ')}
</li>
<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">End date </span>
{endDate}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Topics</span>
{topics.join(', ')}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Reasons</span>
{reasons && displayReasonsList(reasons)}
</li>

<li className="desktop:display-flex padding-bottom-05 flex-align-start">
<span className="margin-right-3 desktop:text-normal text-bold">Objective status </span>
<div>
{(statusChangeError && (
<Alert type="error" className="margin-top-1">
There was an error updating the status of this objective.
{' '}
For more assistance, please contact support.
</Alert>
))}
<ObjectiveStatusDropdown
currentStatus={localStatus}
goalStatus={goalStatus}
objectiveId={objective.id}
regionId={regionId}
className="line-height-sans-5"
onUpdateObjectiveStatus={onUpdateObjectiveStatus}
forceReadOnly={forceReadOnly}
))}
<ObjectiveStatusDropdown
currentStatus={localStatus}
goalStatus={goalStatus}
objectiveId={objective.id}
regionId={regionId}
className="line-height-sans-5"
onUpdateObjectiveStatus={onUpdateObjectiveStatus}
forceReadOnly={forceReadOnly}
/>
{!(forceReadOnly) && (
<ObjectiveSuspendModal
objectiveId={modalIdentifier}
modalRef={modalRef}
objectiveSuspendReason={localCloseSuspendReason}
onChangeSuspendReason={(e) => setLocalCloseSuspendReason(e.target.value)}
objectiveSuspendInputName={`suspend-objective-${modalIdentifier}-reason`}
objectiveSuspendContextInputName={`suspend-objective-${modalIdentifier}-context`}
objectiveSuspendContext={localCloseSuspendContext}
onChangeSuspendContext={(e) => setLocalCloseSuspendContext(e.target.value)}
onChangeStatus={onChangeStatus}
setError={setSuspendReasonError}
error={suspendReasonError}
/>
</div>
</li>
</ul>
{!(forceReadOnly) && (
<ObjectiveSuspendModal
objectiveId={modalIdentifier}
modalRef={modalRef}
objectiveSuspendReason={localCloseSuspendReason}
onChangeSuspendReason={(e) => setLocalCloseSuspendReason(e.target.value)}
objectiveSuspendInputName={`suspend-objective-${modalIdentifier}-reason`}
objectiveSuspendContextInputName={`suspend-objective-${modalIdentifier}-context`}
objectiveSuspendContext={localCloseSuspendContext}
onChangeSuspendContext={(e) => setLocalCloseSuspendContext(e.target.value)}
onChangeStatus={onChangeStatus}
setError={setSuspendReasonError}
error={suspendReasonError}
/>
)}
</>
)}
</div>
</li>
</ul>
);
}

Expand Down
23 changes: 12 additions & 11 deletions frontend/src/pages/TrainingReports/components/EventCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,7 @@ function EventCard({

return (
<>
<Modal
modalRef={modalRef}
title="Are you sure you want to delete this event?"
modalId={`remove-event-modal-${idForLink}`}
onOk={async () => onDeleteEvent(idForLink, id)}
okButtonText="Delete"
okButtonAriaLabel="delete event"
>
<p>The event and all session reports will be lost.</p>
</Modal>

<article
className="ttahub-event-card usa-card padding-3 radius-lg border width-full maxw-full smart-hub-border-base-lighter margin-bottom-2 position-relative"
data-testid="eventCard"
Expand Down Expand Up @@ -260,12 +251,22 @@ function EventCard({
<p className="usa-prose margin-y-0">{checkForDate(data.endDate)}</p>
</div>
<div className="ttahub-event-card__event-column ttahub-event-card__event-column__menu position-absolute right-0">
{true && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this hard coded ....

Copy link
Collaborator

Choose a reason for hiding this comment

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

doh

{menuItems.length > 0 && (
<ContextMenu
label={contextMenuLabel}
menuItems={menuItems}
/>
)}
<Modal
modalRef={modalRef}
title="Are you sure you want to delete this event?"
modalId={`remove-event-modal-${idForLink}`}
onOk={async () => onDeleteEvent(idForLink, id)}
okButtonText="Delete"
okButtonAriaLabel="delete event"
>
<p>The event and all session reports will be lost.</p>
</Modal>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ttahub/common",
"version": "2.1.6",
"version": "2.1.7",
"description": "The purpose of this package is to reduce code duplication between the frontend and backend projects.",
"main": "src/index.js",
"author": "",
Expand Down