From 1862bcdf3e7727193ed01a0bbe20a123f1594f14 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Wed, 15 May 2024 14:36:50 -0400 Subject: [PATCH 01/14] #2392 overflow and links --- .../DiffSection/DiffPanel.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx index e3b6304110..5f812b55b8 100644 --- a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx +++ b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx @@ -1,6 +1,6 @@ import { ProjectProposedChangesPreview, WorkPackageProposedChangesPreview, calculateEndDate } from 'shared'; import { Box } from '@mui/system'; -import { Typography } from '@mui/material'; +import { Link, List, ListItem, Typography } from '@mui/material'; import { ChangeBullet, PotentialChangeType, @@ -64,11 +64,25 @@ const DiffPanel: React.FC = ({ ); } else { return ( - + + {detailText.map((bullet) => { + const url = bullet.includes('http') ? bullet.split(': ')[1] : undefined; + return ( + + {url ? ( + <> + {bullet.split(': ')[0]}:{' '} + + {bullet.split(': ')[1]} + + + ) : ( + bullet + )} + + ); + })} + ); } }; From 53bf389955910fab11ebd309707a8a1f7b3e1d0d Mon Sep 17 00:00:00 2001 From: walker-sean Date: Wed, 15 May 2024 17:07:46 -0400 Subject: [PATCH 02/14] #2392 links should be good --- .../ProjectForm/LinksEditView.tsx | 32 +++++++++++-------- .../ProjectForm/ProjectForm.tsx | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx index 84d9150e84..0015fe5332 100644 --- a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx +++ b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx @@ -8,6 +8,7 @@ import { getRequiredLinkTypeNames } from '../../../utils/link.utils'; import { ProjectFormInput } from './ProjectForm'; import { Box } from '@mui/system'; import { NERButton } from '../../../components/NERButton'; +import { useEffect } from 'react'; const LinksEditView: React.FC<{ ls: FieldArrayWithId[]; @@ -17,6 +18,15 @@ const LinksEditView: React.FC<{ remove: UseFieldArrayRemove; }> = ({ ls, register, append, remove, watch }) => { const { isLoading, isError, error, data: linkTypes } = useAllLinkTypes(); + + useEffect(() => { + requiredLinkTypeNames.forEach((linkTypeName) => { + if (links.some((link) => link.linkTypeName === linkTypeName)) return; + append({ linkId: '-1', url: '', linkTypeName }); + }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [linkTypes]); + if (isLoading || !linkTypes) return ; if (isError) return ; @@ -36,8 +46,6 @@ const LinksEditView: React.FC<{ ); }; - const availableOptions = linkTypes.filter((linkType) => !currentLinkTypeNames.includes(linkType.name)); - return ( <> {ls.map((_element, i) => { @@ -50,7 +58,7 @@ const LinksEditView: React.FC<{ value={watch(`links.${i}.linkTypeName`)} > {linkTypes.map((linkType) => ( - + {linkType.name} ))} @@ -66,16 +74,14 @@ const LinksEditView: React.FC<{ ); })} - {availableOptions.length > 0 && ( - append({ linkId: '-1', url: '', linkTypeName: '-1' })} - sx={{ my: 2, width: 'max-content' }} - > - + Add New Link - - )} + append({ linkId: '-1', url: '', linkTypeName: '-1' })} + sx={{ my: 2, width: 'max-content' }} + > + + Add Link + ); }; diff --git a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx index a6fb4de224..29abfc4f87 100644 --- a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx +++ b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx @@ -198,7 +198,7 @@ const ProjectFormContainer: React.FC = ({ - {!project ? 'Links (optional)' : 'Links'} + Links From 0a36453af3b3c5d8d329feca71b7cf9db06cd9f2 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Wed, 15 May 2024 20:56:33 -0400 Subject: [PATCH 03/14] #2392 fixed diff --- .../scope-change-requests.query-args.ts | 3 +- .../migration.sql | 25 ++++++ src/backend/src/prisma/schema.prisma | 50 +++++------ .../src/services/change-requests.services.ts | 84 ++++++++++++++++--- .../change-requests.transformer.ts | 6 ++ .../src/utils/change-requests.utils.ts | 2 + .../DiffSection/DiffSection.tsx | 28 +++++++ .../DiffSection/DiffSectionEdit.tsx | 14 +++- src/shared/src/types/change-request-types.ts | 2 + 9 files changed, 176 insertions(+), 38 deletions(-) create mode 100644 src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql diff --git a/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts b/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts index 41398620ee..582b31c3f5 100644 --- a/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts +++ b/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts @@ -35,7 +35,8 @@ const scopeChangeRequestQueryArgs = Prisma.validator()({ proposedSolutions: proposedSolutionArgs, wbsProposedChanges: { ...wbsProposedChangeQueryArgs - } + }, + wbsOriginalData: wbsProposedChangeQueryArgs } }); diff --git a/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql b/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql new file mode 100644 index 0000000000..9ad1832ee7 --- /dev/null +++ b/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql @@ -0,0 +1,25 @@ +/* + Warnings: + + - You are about to drop the column `wbsProposedChangesId` on the `Scope_CR` table. All the data in the column will be lost. + - A unique constraint covering the columns `[changeRequestAsOriginalDataId]` on the table `Wbs_Proposed_Changes` will be added. If there are existing duplicate values, this will fail. + +*/ +-- DropForeignKey +ALTER TABLE "Wbs_Proposed_Changes" DROP CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey"; + +-- AlterTable +ALTER TABLE "Scope_CR" DROP COLUMN "wbsProposedChangesId"; + +-- AlterTable +ALTER TABLE "Wbs_Proposed_Changes" ADD COLUMN "changeRequestAsOriginalDataId" INTEGER, +ALTER COLUMN "changeRequestId" DROP NOT NULL; + +-- CreateIndex +CREATE UNIQUE INDEX "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_key" ON "Wbs_Proposed_Changes"("changeRequestAsOriginalDataId"); + +-- AddForeignKey +ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey" FOREIGN KEY ("changeRequestId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_fkey" FOREIGN KEY ("changeRequestAsOriginalDataId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 8b6eeeb23a..9c8e2afb82 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -201,17 +201,17 @@ model Message_Info { } model Scope_CR { - scopeCrId Int @id @default(autoincrement()) - changeRequestId Int @unique - changeRequest Change_Request @relation(fields: [changeRequestId], references: [crId]) - what String - why Scope_CR_Why[] - scopeImpact String - timelineImpact Int - budgetImpact Int - proposedSolutions Proposed_Solution[] - wbsProposedChangesId String? - wbsProposedChanges Wbs_Proposed_Changes? + scopeCrId Int @id @default(autoincrement()) + changeRequestId Int @unique + changeRequest Change_Request @relation(fields: [changeRequestId], references: [crId]) + what String + why Scope_CR_Why[] + scopeImpact String + timelineImpact Int + budgetImpact Int + proposedSolutions Proposed_Solution[] + wbsProposedChanges Wbs_Proposed_Changes? @relation(name: "wbsProposedChanges") + wbsOriginalData Wbs_Proposed_Changes? @relation(name: "wbsOriginalData") } model Proposed_Solution { @@ -667,19 +667,21 @@ model Meeting { } model Wbs_Proposed_Changes { - wbsProposedChangesId String @id @default(uuid()) - name String - status WBS_Element_Status - leadId Int? - lead User? @relation(name: "wbsProjectLead", fields: [leadId], references: [userId]) - managerId Int? - manager User? @relation(name: "wbsProjectManager", fields: [managerId], references: [userId]) - links Link[] @relation(name: "proposedChangeLinks") - changeRequest Scope_CR @relation(fields: [changeRequestId], references: [scopeCrId]) - changeRequestId Int @unique - projectProposedChanges Project_Proposed_Changes? @relation(name: "projectProposedChanges") - workPackageProposedChanges Work_Package_Proposed_Changes? @relation(name: "wpProposedChanges") - dateDeleted DateTime? + wbsProposedChangesId String @id @default(uuid()) + name String + status WBS_Element_Status + leadId Int? + lead User? @relation(name: "wbsProjectLead", fields: [leadId], references: [userId]) + managerId Int? + manager User? @relation(name: "wbsProjectManager", fields: [managerId], references: [userId]) + links Link[] @relation(name: "proposedChangeLinks") + changeRequest Scope_CR? @relation(name: "wbsProposedChanges", fields: [changeRequestId], references: [scopeCrId]) + changeRequestId Int? @unique + projectProposedChanges Project_Proposed_Changes? @relation(name: "projectProposedChanges") + workPackageProposedChanges Work_Package_Proposed_Changes? @relation(name: "wpProposedChanges") + dateDeleted DateTime? + changeRequestAsOriginalData Scope_CR? @relation(name: "wbsOriginalData", fields: [changeRequestAsOriginalDataId], references: [scopeCrId]) + changeRequestAsOriginalDataId Int? @unique } model Project_Proposed_Changes { diff --git a/src/backend/src/services/change-requests.services.ts b/src/backend/src/services/change-requests.services.ts index a229f3e53b..abcf0cd652 100644 --- a/src/backend/src/services/change-requests.services.ts +++ b/src/backend/src/services/change-requests.services.ts @@ -102,7 +102,7 @@ export default class ChangeRequestsService { activationChangeRequest: true, scopeChangeRequest: scopeChangeRequestQueryArgs, wbsElement: { - include: { workPackage: workPackageQueryArgs, project: true } + include: { workPackage: workPackageQueryArgs, project: true, links: true } } } }); @@ -174,21 +174,85 @@ export default class ChangeRequestsService { // we don't want to have merge conflictS on the wbs element thus we check if there are unreviewed or open CRs on the wbs element await validateNoUnreviewedOpenCRs(foundCR.wbsElementId); - // must accept and review a change request before using the workpackage and project services - await prisma.change_Request.update({ - where: { crId: foundCR.crId }, - data: { - accepted: true, - dateReviewed: new Date() - } - }); - const associatedProject = foundCR.wbsElement.project; const associatedWorkPackage = foundCR.wbsElement.workPackage; const { wbsProposedChanges } = foundCR.scopeChangeRequest; const { workPackageProposedChanges } = wbsProposedChanges; const { projectProposedChanges } = wbsProposedChanges; + // must accept and review a change request before using the workpackage and project services + await prisma.scope_CR.update({ + where: { changeRequestId: foundCR.crId }, + data: { + changeRequest: { + update: { + accepted: true, + dateReviewed: new Date() + } + }, + wbsOriginalData: { + create: { + name: foundCR.wbsElement.name, + status: foundCR.wbsElement.status, + leadId: foundCR.wbsElement.leadId, + managerId: foundCR.wbsElement.managerId, + links: { + connect: foundCR.wbsElement.links.map((link) => ({ + linkId: link.linkId + })) + }, + projectProposedChanges: projectProposedChanges + ? { + create: { + budget: associatedProject!.budget, + summary: associatedProject!.summary, + rules: associatedProject!.rules, + goals: { + connect: associatedProject!.goals.map((goal) => ({ descriptionId: goal.descriptionId })) + }, + features: { + connect: associatedProject!.features.map((feature) => ({ descriptionId: feature.descriptionId })) + }, + otherConstraints: { + connect: associatedProject!.otherConstraints.map((constraint) => ({ + descriptionId: constraint.descriptionId + })) + }, + teams: { + connect: associatedProject!.teams.map((team) => ({ teamId: team.teamId })) + }, + carNumber: associatedProject!.wbsElement.carNumber + } + } + : undefined, + workPackageProposedChanges: + workPackageProposedChanges && associatedWorkPackage + ? { + create: { + startDate: associatedWorkPackage.startDate, + duration: associatedWorkPackage.duration, + blockedBy: { + connect: associatedWorkPackage.blockedBy.map((wbsNumber) => ({ wbsNumber })) + }, + expectedActivities: { + connect: associatedWorkPackage.expectedActivities.map((activity) => ({ + descriptionId: activity.descriptionId + })) + }, + deliverables: { + connect: associatedWorkPackage.deliverables.map((deliverable) => ({ + descriptionId: deliverable.descriptionId + })) + }, + stage: associatedWorkPackage.stage + } + } + : undefined + } + } + } + }); + if (workPackageProposedChanges) { await applyWorkPackageProposedChanges( wbsProposedChanges, diff --git a/src/backend/src/transformers/change-requests.transformer.ts b/src/backend/src/transformers/change-requests.transformer.ts index 4b62c8bade..eb9eeaca34 100644 --- a/src/backend/src/transformers/change-requests.transformer.ts +++ b/src/backend/src/transformers/change-requests.transformer.ts @@ -106,6 +106,12 @@ const changeRequestTransformer = ( proposedSolutions: changeRequest.scopeChangeRequest ? changeRequest.scopeChangeRequest?.proposedSolutions.map(proposedSolutionTransformer) ?? [] : undefined, + originalProjectData: changeRequest.scopeChangeRequest?.wbsOriginalData?.projectProposedChanges + ? projectProposedChangesTransformer(changeRequest.scopeChangeRequest?.wbsOriginalData) + : undefined, + originalWorkPackageData: changeRequest.scopeChangeRequest?.wbsOriginalData?.workPackageProposedChanges + ? workPackageProposedChangesTransformer(changeRequest.scopeChangeRequest?.wbsOriginalData) + : undefined, // activation cr fields projectLead: changeRequest.activationChangeRequest?.projectLead ? userTransformer(changeRequest.activationChangeRequest?.projectLead) diff --git a/src/backend/src/utils/change-requests.utils.ts b/src/backend/src/utils/change-requests.utils.ts index ad25f51ae5..daaca709f5 100644 --- a/src/backend/src/utils/change-requests.utils.ts +++ b/src/backend/src/utils/change-requests.utils.ts @@ -27,6 +27,7 @@ import scopeChangeRequestQueryArgs, { workPackageProposedChangesQueryArgs } from '../prisma-query-args/scope-change-requests.query-args'; import projectQueryArgs from '../prisma-query-args/projects.query-args'; +import linkQueryArgs from '../prisma-query-args/links.query-args'; export const convertCRScopeWhyType = (whyType: Scope_CR_Why_Type): ChangeRequestReason => ({ @@ -464,6 +465,7 @@ export type ChangeRequestWithChanges = Change_Request & { wbsElement: WBS_Element & { workPackage?: Prisma.Work_PackageGetPayload; project?: Prisma.ProjectGetPayload; + links: Prisma.LinkGetPayload[]; }; }; diff --git a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx index e1d6a33b48..d17a77162c 100644 --- a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx +++ b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx @@ -45,6 +45,32 @@ const DiffSection: React.FC = ({ changeRequest }) => { } : undefined; + const originalProjectData: ProjectProposedChangesPreview | undefined = changeRequest.originalProjectData && { + name: changeRequest.originalProjectData.name, + summary: changeRequest.originalProjectData.summary, + lead: changeRequest.originalProjectData.lead, + manager: changeRequest.originalProjectData.manager, + teams: changeRequest.originalProjectData.teams, + budget: changeRequest.originalProjectData.budget, + goals: changeRequest.originalProjectData.goals, + features: changeRequest.originalProjectData.features, + rules: changeRequest.originalProjectData.rules, + otherConstraints: changeRequest.originalProjectData.otherConstraints, + links: changeRequest.originalProjectData.links + }; + + const originalWorkPackageData: WorkPackageProposedChangesPreview | undefined = changeRequest.originalWorkPackageData && { + name: changeRequest.originalWorkPackageData.name, + stage: changeRequest.originalWorkPackageData.stage, + lead: changeRequest.originalWorkPackageData.lead, + manager: changeRequest.originalWorkPackageData.manager, + startDate: changeRequest.originalWorkPackageData.startDate, + duration: changeRequest.originalWorkPackageData.duration, + blockedBy: changeRequest.originalWorkPackageData.blockedBy, + expectedActivities: changeRequest.originalWorkPackageData.expectedActivities, + deliverables: changeRequest.originalWorkPackageData.deliverables + }; + const workPackageProposedChangesPreview: WorkPackageProposedChangesPreview | undefined = workPackageProposedChanges ? { name: workPackageProposedChanges.name, @@ -72,6 +98,8 @@ const DiffSection: React.FC = ({ changeRequest }) => { )} diff --git a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSectionEdit.tsx b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSectionEdit.tsx index 1c20acbb03..6f0322708f 100644 --- a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSectionEdit.tsx +++ b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSectionEdit.tsx @@ -24,10 +24,18 @@ import DiffPanel from './DiffPanel'; interface DiffSectionEditProps { projectProposedChanges?: ProjectProposedChangesPreview; workPackageProposedChanges?: WorkPackageProposedChangesPreview; + originalProjectData?: ProjectProposedChangesPreview; + originalWorkPackageData?: WorkPackageProposedChangesPreview; wbsNum: WbsNumber; } -const DiffSectionEdit: React.FC = ({ projectProposedChanges, workPackageProposedChanges, wbsNum }) => { +const DiffSectionEdit: React.FC = ({ + projectProposedChanges, + workPackageProposedChanges, + originalProjectData, + originalWorkPackageData, + wbsNum +}) => { const { data: projects, isLoading: projectsIsLoading, isError: projectsIsError, error: projectsError } = useAllProjects(); const { data: workPackages, @@ -48,8 +56,8 @@ const DiffSectionEdit: React.FC = ({ projectProposedChange const originalMap: Map = new Map(); const proposedMap: Map = new Map(); - const projectAsChanges = projectToProposedChangesPreview(project); - const workPackageAsChanges = workPackageToProposedChangesPreview(workPackage); + const projectAsChanges = originalProjectData ?? projectToProposedChangesPreview(project); + const workPackageAsChanges = originalWorkPackageData ?? workPackageToProposedChangesPreview(workPackage); if (isOnProject) { for (var projectKey in projectProposedChanges) { diff --git a/src/shared/src/types/change-request-types.ts b/src/shared/src/types/change-request-types.ts index 69612adb4c..7bca4e6c2e 100644 --- a/src/shared/src/types/change-request-types.ts +++ b/src/shared/src/types/change-request-types.ts @@ -43,6 +43,8 @@ export interface StandardChangeRequest extends ChangeRequest { proposedSolutions: ProposedSolution[]; projectProposedChanges?: ProjectProposedChanges; workPackageProposedChanges?: WorkPackageProposedChanges; + originalProjectData?: ProjectProposedChanges; + originalWorkPackageData?: WorkPackageProposedChanges; } export interface ProposedSolution { From 529becd090440ceadb2ebc4144e52de1b7c7d480 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Thu, 16 May 2024 23:13:51 -0400 Subject: [PATCH 04/14] #2392 fix build, fix description bullets --- .../src/prisma-query-args/change-requests.query-args.ts | 9 ++++++++- src/backend/src/prisma-query-args/projects.query-args.ts | 7 ++++--- src/backend/src/utils/description-bullets.utils.ts | 2 +- src/backend/tests/test-data/change-requests.test-data.ts | 3 +-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/backend/src/prisma-query-args/change-requests.query-args.ts b/src/backend/src/prisma-query-args/change-requests.query-args.ts index 300c235140..6c5eea78de 100644 --- a/src/backend/src/prisma-query-args/change-requests.query-args.ts +++ b/src/backend/src/prisma-query-args/change-requests.query-args.ts @@ -1,10 +1,17 @@ import { Prisma } from '@prisma/client'; import scopeCRArgs from './scope-change-requests.query-args'; +import projectQueryArgs from './projects.query-args'; +import workPackageQueryArgs from './work-packages.query-args'; export const changeRequestQueryArgs = Prisma.validator()({ include: { submitter: true, - wbsElement: true, + wbsElement: { + include: { + project: projectQueryArgs, + workPackage: workPackageQueryArgs + } + }, reviewer: true, changes: { where: { diff --git a/src/backend/src/prisma-query-args/projects.query-args.ts b/src/backend/src/prisma-query-args/projects.query-args.ts index b7e11aa8b6..2a041240e9 100644 --- a/src/backend/src/prisma-query-args/projects.query-args.ts +++ b/src/backend/src/prisma-query-args/projects.query-args.ts @@ -2,6 +2,7 @@ import { Prisma } from '@prisma/client'; import taskQueryArgs from './tasks.query-args'; import linkQueryArgs from './links.query-args'; import { assemblyQueryArgs, materialQueryArgs } from './bom.query-args'; +import descriptionBulletQueryArgs from './description-bullets.query-args'; const projectQueryArgs = Prisma.validator()({ include: { @@ -23,9 +24,9 @@ const projectQueryArgs = Prisma.validator()({ } }, teams: { include: { members: true, head: true, leads: true, teamType: true } }, - goals: { where: { dateDeleted: null } }, - features: { where: { dateDeleted: null } }, - otherConstraints: { where: { dateDeleted: null } }, + goals: { where: { dateDeleted: null }, ...descriptionBulletQueryArgs }, + features: { where: { dateDeleted: null }, ...descriptionBulletQueryArgs }, + otherConstraints: { where: { dateDeleted: null }, ...descriptionBulletQueryArgs }, workPackages: { where: { wbsElement: { diff --git a/src/backend/src/utils/description-bullets.utils.ts b/src/backend/src/utils/description-bullets.utils.ts index 9ebd888fb4..70ede3e757 100644 --- a/src/backend/src/utils/description-bullets.utils.ts +++ b/src/backend/src/utils/description-bullets.utils.ts @@ -64,7 +64,7 @@ export const descriptionBulletToChangeListValue = ( ): ChangeListValue => { return { element: descriptionBullet, - comparator: `${descriptionBullet.id}`, + comparator: `${descriptionBullet.detail}`, displayValue: descriptionBullet.detail }; }; diff --git a/src/backend/tests/test-data/change-requests.test-data.ts b/src/backend/tests/test-data/change-requests.test-data.ts index 71971e6f24..e06995d64f 100644 --- a/src/backend/tests/test-data/change-requests.test-data.ts +++ b/src/backend/tests/test-data/change-requests.test-data.ts @@ -40,8 +40,7 @@ export const prismaScopeChangeRequest1: PrismaScopeCR = { what: 'redesign whip', scopeImpact: 'huge', timelineImpact: 10, - budgetImpact: 1000, - wbsProposedChangesId: null + budgetImpact: 1000 }; export const whipExpectedActivites: PrismaDescriptionBullet = { From bb8800ae9a323d256f7e8a1554572846d629fb85 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Mon, 20 May 2024 11:54:07 -0400 Subject: [PATCH 05/14] #2392 helper function --- .../DiffSection/DiffSection.tsx | 62 ++----------------- src/frontend/src/utils/diff-page.utils.ts | 40 ++++++++++++ 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx index d17a77162c..c981cbac3c 100644 --- a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx +++ b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffSection.tsx @@ -1,9 +1,10 @@ import { Box } from '@mui/system'; import InfoBlock from '../../../components/InfoBlock'; -import { ProjectProposedChangesPreview, StandardChangeRequest, WorkPackageProposedChangesPreview, isProject } from 'shared'; +import { StandardChangeRequest, isProject } from 'shared'; import { displayEnum } from '../../../utils/pipes'; import DiffSectionCreate from './DiffSectionCreate'; import DiffSectionEdit from './DiffSectionEdit'; +import { projectProposedChangesToPreview, workPackageProposedChangesToPreview } from '../../../utils/diff-page.utils'; interface DiffSectionProps { changeRequest: StandardChangeRequest; @@ -29,61 +30,10 @@ const DiffSection: React.FC = ({ changeRequest }) => { ? ChangeRequestAction.EDIT_PROJECT : ChangeRequestAction.EDIT_WORK_PACKAGE; - const projectProposedChangesPreview: ProjectProposedChangesPreview | undefined = projectProposedChanges - ? { - name: projectProposedChanges.name, - summary: projectProposedChanges.summary, - lead: projectProposedChanges.lead, - manager: projectProposedChanges.manager, - teams: projectProposedChanges.teams, - budget: projectProposedChanges.budget, - goals: projectProposedChanges.goals, - features: projectProposedChanges.features, - rules: projectProposedChanges.rules, - otherConstraints: projectProposedChanges.otherConstraints, - links: projectProposedChanges.links - } - : undefined; - - const originalProjectData: ProjectProposedChangesPreview | undefined = changeRequest.originalProjectData && { - name: changeRequest.originalProjectData.name, - summary: changeRequest.originalProjectData.summary, - lead: changeRequest.originalProjectData.lead, - manager: changeRequest.originalProjectData.manager, - teams: changeRequest.originalProjectData.teams, - budget: changeRequest.originalProjectData.budget, - goals: changeRequest.originalProjectData.goals, - features: changeRequest.originalProjectData.features, - rules: changeRequest.originalProjectData.rules, - otherConstraints: changeRequest.originalProjectData.otherConstraints, - links: changeRequest.originalProjectData.links - }; - - const originalWorkPackageData: WorkPackageProposedChangesPreview | undefined = changeRequest.originalWorkPackageData && { - name: changeRequest.originalWorkPackageData.name, - stage: changeRequest.originalWorkPackageData.stage, - lead: changeRequest.originalWorkPackageData.lead, - manager: changeRequest.originalWorkPackageData.manager, - startDate: changeRequest.originalWorkPackageData.startDate, - duration: changeRequest.originalWorkPackageData.duration, - blockedBy: changeRequest.originalWorkPackageData.blockedBy, - expectedActivities: changeRequest.originalWorkPackageData.expectedActivities, - deliverables: changeRequest.originalWorkPackageData.deliverables - }; - - const workPackageProposedChangesPreview: WorkPackageProposedChangesPreview | undefined = workPackageProposedChanges - ? { - name: workPackageProposedChanges.name, - stage: workPackageProposedChanges.stage, - lead: workPackageProposedChanges.lead, - manager: workPackageProposedChanges.manager, - startDate: workPackageProposedChanges.startDate, - duration: workPackageProposedChanges.duration, - blockedBy: workPackageProposedChanges.blockedBy, - expectedActivities: workPackageProposedChanges.expectedActivities, - deliverables: workPackageProposedChanges.deliverables - } - : undefined; + const projectProposedChangesPreview = projectProposedChangesToPreview(projectProposedChanges); + const originalProjectData = projectProposedChangesToPreview(changeRequest.originalProjectData); + const originalWorkPackageData = workPackageProposedChangesToPreview(changeRequest.originalWorkPackageData); + const workPackageProposedChangesPreview = workPackageProposedChangesToPreview(workPackageProposedChanges); return ( diff --git a/src/frontend/src/utils/diff-page.utils.ts b/src/frontend/src/utils/diff-page.utils.ts index ada89cd74e..b151687111 100644 --- a/src/frontend/src/utils/diff-page.utils.ts +++ b/src/frontend/src/utils/diff-page.utils.ts @@ -2,12 +2,14 @@ import { DescriptionBullet, Link, Project, + ProjectProposedChanges, ProjectProposedChangesPreview, TeamPreview, User, WbsElementStatus, WbsNumber, WorkPackage, + WorkPackageProposedChanges, WorkPackageProposedChangesPreview, WorkPackageStage, wbsPipe @@ -164,3 +166,41 @@ export const workPackageToProposedChangesPreview = ( deliverables: workPackage.deliverables }; }; + +export const projectProposedChangesToPreview = ( + proposedChanges: ProjectProposedChanges | undefined +): ProjectProposedChangesPreview | undefined => { + return ( + proposedChanges && { + name: proposedChanges.name, + summary: proposedChanges.summary, + lead: proposedChanges.lead, + manager: proposedChanges.manager, + teams: proposedChanges.teams, + budget: proposedChanges.budget, + goals: proposedChanges.goals, + features: proposedChanges.features, + rules: proposedChanges.rules, + otherConstraints: proposedChanges.otherConstraints, + links: proposedChanges.links + } + ); +}; + +export const workPackageProposedChangesToPreview = ( + proposedChanges: WorkPackageProposedChanges | undefined +): WorkPackageProposedChangesPreview | undefined => { + return ( + proposedChanges && { + name: proposedChanges.name, + stage: proposedChanges.stage, + lead: proposedChanges.lead, + manager: proposedChanges.manager, + startDate: proposedChanges.startDate, + duration: proposedChanges.duration, + blockedBy: proposedChanges.blockedBy, + expectedActivities: proposedChanges.expectedActivities, + deliverables: proposedChanges.deliverables + } + ); +}; From 4ec70ae5966271c4a865d3209ccfa82227b2fb23 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Tue, 21 May 2024 16:32:43 -0400 Subject: [PATCH 06/14] #2392 helper method and fixed useeffect --- .../src/services/change-requests.services.ts | 47 ++++++++++--------- .../ProjectForm/LinksEditView.tsx | 15 +++--- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/backend/src/services/change-requests.services.ts b/src/backend/src/services/change-requests.services.ts index abcf0cd652..583847de56 100644 --- a/src/backend/src/services/change-requests.services.ts +++ b/src/backend/src/services/change-requests.services.ts @@ -201,30 +201,31 @@ export default class ChangeRequestsService { linkId: link.linkId })) }, - projectProposedChanges: projectProposedChanges - ? { - create: { - budget: associatedProject!.budget, - summary: associatedProject!.summary, - rules: associatedProject!.rules, - goals: { - connect: associatedProject!.goals.map((goal) => ({ descriptionId: goal.descriptionId })) - }, - features: { - connect: associatedProject!.features.map((feature) => ({ descriptionId: feature.descriptionId })) - }, - otherConstraints: { - connect: associatedProject!.otherConstraints.map((constraint) => ({ - descriptionId: constraint.descriptionId - })) - }, - teams: { - connect: associatedProject!.teams.map((team) => ({ teamId: team.teamId })) - }, - carNumber: associatedProject!.wbsElement.carNumber + projectProposedChanges: + projectProposedChanges && associatedProject + ? { + create: { + budget: associatedProject.budget, + summary: associatedProject.summary, + rules: associatedProject.rules, + goals: { + connect: associatedProject.goals.map((goal) => ({ descriptionId: goal.descriptionId })) + }, + features: { + connect: associatedProject.features.map((feature) => ({ descriptionId: feature.descriptionId })) + }, + otherConstraints: { + connect: associatedProject.otherConstraints.map((constraint) => ({ + descriptionId: constraint.descriptionId + })) + }, + teams: { + connect: associatedProject.teams.map((team) => ({ teamId: team.teamId })) + }, + carNumber: associatedProject.wbsElement.carNumber + } } - } - : undefined, + : undefined, workPackageProposedChanges: workPackageProposedChanges && associatedWorkPackage ? { diff --git a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx index 0015fe5332..47be334bc2 100644 --- a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx +++ b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx @@ -8,7 +8,7 @@ import { getRequiredLinkTypeNames } from '../../../utils/link.utils'; import { ProjectFormInput } from './ProjectForm'; import { Box } from '@mui/system'; import { NERButton } from '../../../components/NERButton'; -import { useEffect } from 'react'; +import { useEffect, useMemo } from 'react'; const LinksEditView: React.FC<{ ls: FieldArrayWithId[]; @@ -19,21 +19,22 @@ const LinksEditView: React.FC<{ }> = ({ ls, register, append, remove, watch }) => { const { isLoading, isError, error, data: linkTypes } = useAllLinkTypes(); + const requiredLinkTypeNames = useMemo(() => { + return linkTypes ? getRequiredLinkTypeNames(linkTypes) : []; + }, [linkTypes]); + + const links = watch('links'); + useEffect(() => { requiredLinkTypeNames.forEach((linkTypeName) => { if (links.some((link) => link.linkTypeName === linkTypeName)) return; append({ linkId: '-1', url: '', linkTypeName }); }); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [linkTypes]); + }, [append, linkTypes, links, requiredLinkTypeNames]); if (isLoading || !linkTypes) return ; if (isError) return ; - const requiredLinkTypeNames = getRequiredLinkTypeNames(linkTypes); - - const links = watch('links'); - const currentLinkTypeNames = links.map((link) => link.linkTypeName); /* Checks whether the link at the given index is of a required type and does not already exist */ From 90d4e0955e19f0bca1a1a72e1acd54efebcebfbc Mon Sep 17 00:00:00 2001 From: walker-sean Date: Thu, 23 May 2024 15:24:52 -0400 Subject: [PATCH 07/14] #2392 fixed project reviews --- .../src/services/change-requests.services.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/backend/src/services/change-requests.services.ts b/src/backend/src/services/change-requests.services.ts index 583847de56..56d9b72972 100644 --- a/src/backend/src/services/change-requests.services.ts +++ b/src/backend/src/services/change-requests.services.ts @@ -46,6 +46,7 @@ import { import { changeRequestQueryArgs } from '../prisma-query-args/change-requests.query-args'; import { validateBlockedBys } from '../utils/projects.utils'; import scopeChangeRequestQueryArgs from '../prisma-query-args/scope-change-requests.query-args'; +import projectQueryArgs from '../prisma-query-args/projects.query-args'; export default class ChangeRequestsService { /** @@ -102,7 +103,7 @@ export default class ChangeRequestsService { activationChangeRequest: true, scopeChangeRequest: scopeChangeRequestQueryArgs, wbsElement: { - include: { workPackage: workPackageQueryArgs, project: true, links: true } + include: { workPackage: workPackageQueryArgs, project: projectQueryArgs, links: true } } } }); @@ -208,16 +209,10 @@ export default class ChangeRequestsService { budget: associatedProject.budget, summary: associatedProject.summary, rules: associatedProject.rules, - goals: { - connect: associatedProject.goals.map((goal) => ({ descriptionId: goal.descriptionId })) - }, - features: { - connect: associatedProject.features.map((feature) => ({ descriptionId: feature.descriptionId })) - }, + goals: { create: associatedProject.goals.map((goal) => ({ detail: goal.detail })) }, + features: { create: associatedProject.features.map((feature) => ({ detail: feature.detail })) }, otherConstraints: { - connect: associatedProject.otherConstraints.map((constraint) => ({ - descriptionId: constraint.descriptionId - })) + create: associatedProject.otherConstraints.map((constraint) => ({ detail: constraint.detail })) }, teams: { connect: associatedProject.teams.map((team) => ({ teamId: team.teamId })) From 10793c64e12e1e7729888c5f949c93d7b6ab31f7 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Thu, 23 May 2024 15:27:37 -0400 Subject: [PATCH 08/14] #2392 not creating new description bullets --- src/backend/src/services/change-requests.services.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backend/src/services/change-requests.services.ts b/src/backend/src/services/change-requests.services.ts index 56d9b72972..7b5ffb3f2f 100644 --- a/src/backend/src/services/change-requests.services.ts +++ b/src/backend/src/services/change-requests.services.ts @@ -209,10 +209,14 @@ export default class ChangeRequestsService { budget: associatedProject.budget, summary: associatedProject.summary, rules: associatedProject.rules, - goals: { create: associatedProject.goals.map((goal) => ({ detail: goal.detail })) }, - features: { create: associatedProject.features.map((feature) => ({ detail: feature.detail })) }, + goals: { connect: associatedProject.goals.map((goal) => ({ descriptionId: goal.descriptionId })) }, + features: { + connect: associatedProject.features.map((feature) => ({ descriptionId: feature.descriptionId })) + }, otherConstraints: { - create: associatedProject.otherConstraints.map((constraint) => ({ detail: constraint.detail })) + connect: associatedProject.otherConstraints.map((constraint) => ({ + descriptionId: constraint.descriptionId + })) }, teams: { connect: associatedProject.teams.map((team) => ({ teamId: team.teamId })) From 6d6d3ac3711db55ee2f87538c410168479db8442 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Thu, 23 May 2024 15:37:31 -0400 Subject: [PATCH 09/14] #2392 fixed links thing --- .../ProjectForm/LinksEditView.tsx | 19 +++++++++++-------- .../ProjectForm/ProjectForm.tsx | 11 +++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx index 47be334bc2..e08f8085ba 100644 --- a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx +++ b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/LinksEditView.tsx @@ -16,7 +16,8 @@ const LinksEditView: React.FC<{ watch: UseFormWatch; append: UseFieldArrayAppend; remove: UseFieldArrayRemove; -}> = ({ ls, register, append, remove, watch }) => { + enforceRequired?: boolean; +}> = ({ ls, register, append, remove, watch, enforceRequired }) => { const { isLoading, isError, error, data: linkTypes } = useAllLinkTypes(); const requiredLinkTypeNames = useMemo(() => { @@ -26,11 +27,13 @@ const LinksEditView: React.FC<{ const links = watch('links'); useEffect(() => { - requiredLinkTypeNames.forEach((linkTypeName) => { - if (links.some((link) => link.linkTypeName === linkTypeName)) return; - append({ linkId: '-1', url: '', linkTypeName }); - }); - }, [append, linkTypes, links, requiredLinkTypeNames]); + if (enforceRequired) { + requiredLinkTypeNames.forEach((linkTypeName) => { + if (links.some((link) => link.linkTypeName === linkTypeName)) return; + append({ linkId: '-1', url: '', linkTypeName }); + }); + } + }, [append, enforceRequired, linkTypes, links, requiredLinkTypeNames]); if (isLoading || !linkTypes) return ; if (isError) return ; @@ -55,7 +58,7 @@ const LinksEditView: React.FC<{ - {!isRequired(i) && ( + {(!enforceRequired || !isRequired(i)) && ( remove(i)} sx={{ mx: 1, my: 0 }}> diff --git a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx index 29abfc4f87..f8daf563ad 100644 --- a/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx +++ b/src/frontend/src/pages/ProjectDetailPage/ProjectForm/ProjectForm.tsx @@ -198,9 +198,16 @@ const ProjectFormContainer: React.FC = ({ - Links + {!!project ? 'Links' : 'Links (optional)'} - + {!project ? 'Goals (optional)' : 'Goals'} From df9b760c54196688df11a1cb31a7b12433744826 Mon Sep 17 00:00:00 2001 From: walker-sean Date: Sat, 25 May 2024 15:35:54 -0400 Subject: [PATCH 10/14] #2392 fixed light theme --- .../DiffSection/DiffPanel.tsx | 12 +++++++--- .../DiffSection/DiffSectionCreate.tsx | 8 ++++--- .../DiffSection/DiffSectionEdit.tsx | 7 ++++-- src/frontend/src/utils/diff-page.utils.ts | 22 +++++++++---------- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx index 5f812b55b8..794b7427c4 100644 --- a/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx +++ b/src/frontend/src/pages/ChangeRequestDetailPage/DiffSection/DiffPanel.tsx @@ -1,11 +1,11 @@ import { ProjectProposedChangesPreview, WorkPackageProposedChangesPreview, calculateEndDate } from 'shared'; import { Box } from '@mui/system'; -import { Link, List, ListItem, Typography } from '@mui/material'; +import { Link, List, ListItem, Typography, useTheme } from '@mui/material'; import { ChangeBullet, PotentialChangeType, changeBulletDetailText, - potentialChangeBackgroundMap + getPotentialChangeBackground } from '../../../utils/diff-page.utils'; import { labelPipe } from '../../../utils/pipes'; @@ -20,6 +20,8 @@ const DiffPanel: React.FC = ({ workPackageProposedChanges, potentialChangeTypeMap }) => { + const theme = useTheme(); + const changeBullets: ChangeBullet[] = []; for (var projectKey in projectProposedChanges) { if (projectProposedChanges.hasOwnProperty(projectKey)) { @@ -99,7 +101,11 @@ const DiffPanel: React.FC = ({ ) : ( = ({ projectProposedChanges, workPackageProposedChanges }) => { + const theme = useTheme(); + const isCreateProject = !!projectProposedChanges; const potentialChangeTypeMap: Map = new Map(); delete workPackageProposedChanges?.lead; @@ -35,7 +37,7 @@ const DiffSectionCreate: React.FC = ({ projectProposedCh borderRadius="10px" p={1.4} mb={3} - sx={{ backgroundColor: potentialChangeBackgroundMap.get(PotentialChangeType.ADDED) }} + sx={{ backgroundColor: getPotentialChangeBackground(PotentialChangeType.ADDED, theme) }} > = ({ error: workPackagesError } = useAllWorkPackages(); + const theme = useTheme(); + if (projectsIsLoading || workPackagesIsLoading || !projects || !workPackages) return ; if (projectsIsError) return ; if (workPackagesIsError) return ; @@ -111,7 +114,7 @@ const DiffSectionEdit: React.FC = ({ return ( - + = ({ - + = new Map([ - [PotentialChangeType.ADDED, '#51915c'], - [PotentialChangeType.REMOVED, '#8a4e4e'], - [PotentialChangeType.SAME, '#2C2C2C'] -]); - -export const potentialChangeHighlightMap: Map = new Map([ - [PotentialChangeType.ADDED, '#43a854'], - [PotentialChangeType.REMOVED, '#ba5050'], - [PotentialChangeType.SAME, '#2C2C2C'] -]); +export const getPotentialChangeBackground = (potentialChangeType: PotentialChangeType, theme: Theme) => { + switch (potentialChangeType) { + case PotentialChangeType.ADDED: + return '#51915c'; + case PotentialChangeType.REMOVED: + return '#8a4e4e'; + case PotentialChangeType.SAME: + return theme.palette.background.paper; + } +}; export const valueChanged = (original: ProposedChangeValue, proposed: ProposedChangeValue) => { console.log(typeof original, typeof proposed, original, proposed); From 272fd3ee8b5fabe1694d23dff0f06ce3b7c4f219 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Sat, 25 May 2024 15:45:22 -0400 Subject: [PATCH 11/14] #2392 Merge Conflicts --- .../change-requests.query-args.ts | 9 +++- .../scope-change-requests.query-args.ts | 3 +- .../migration.sql | 25 ----------- .../migration.sql | 13 ++++-- src/backend/src/prisma/schema.prisma | 3 +- .../src/services/change-requests.services.ts | 43 +++++++++---------- 6 files changed, 39 insertions(+), 57 deletions(-) delete mode 100644 src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql rename src/backend/src/prisma/migrations/{20240518160744_init => 20240525194034_init}/migration.sql (98%) diff --git a/src/backend/src/prisma-query-args/change-requests.query-args.ts b/src/backend/src/prisma-query-args/change-requests.query-args.ts index b04053b7f8..a5cb186ab5 100644 --- a/src/backend/src/prisma-query-args/change-requests.query-args.ts +++ b/src/backend/src/prisma-query-args/change-requests.query-args.ts @@ -12,8 +12,13 @@ export const getChangeRequestQueryArgs = (organizationId: string) => wbsElement: { include: { workPackage: getWorkPackageQueryArgs(organizationId), - project: true, - descriptionBullets: true + project: { + include: { + teams: true + } + }, + descriptionBullets: true, + links: true } }, reviewer: getUserQueryArgs(organizationId), diff --git a/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts b/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts index 4fa4c88515..37ac49ebbc 100644 --- a/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts +++ b/src/backend/src/prisma-query-args/scope-change-requests.query-args.ts @@ -48,6 +48,7 @@ export const getScopeChangeRequestQueryArgs = (organizationId: string) => include: { why: true, proposedSolutions: getProposedSolutionQueryArgs(organizationId), - wbsProposedChanges: getWbsProposedChangeQueryArgs(organizationId) + wbsProposedChanges: getWbsProposedChangeQueryArgs(organizationId), + wbsOriginalData: getWbsProposedChangeQueryArgs(organizationId) } }); diff --git a/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql b/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql deleted file mode 100644 index 9ad1832ee7..0000000000 --- a/src/backend/src/prisma/migrations/20240515230546_add_original_data_to_scope_cr/migration.sql +++ /dev/null @@ -1,25 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `wbsProposedChangesId` on the `Scope_CR` table. All the data in the column will be lost. - - A unique constraint covering the columns `[changeRequestAsOriginalDataId]` on the table `Wbs_Proposed_Changes` will be added. If there are existing duplicate values, this will fail. - -*/ --- DropForeignKey -ALTER TABLE "Wbs_Proposed_Changes" DROP CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey"; - --- AlterTable -ALTER TABLE "Scope_CR" DROP COLUMN "wbsProposedChangesId"; - --- AlterTable -ALTER TABLE "Wbs_Proposed_Changes" ADD COLUMN "changeRequestAsOriginalDataId" INTEGER, -ALTER COLUMN "changeRequestId" DROP NOT NULL; - --- CreateIndex -CREATE UNIQUE INDEX "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_key" ON "Wbs_Proposed_Changes"("changeRequestAsOriginalDataId"); - --- AddForeignKey -ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey" FOREIGN KEY ("changeRequestId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_fkey" FOREIGN KEY ("changeRequestAsOriginalDataId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/migrations/20240518160744_init/migration.sql b/src/backend/src/prisma/migrations/20240525194034_init/migration.sql similarity index 98% rename from src/backend/src/prisma/migrations/20240518160744_init/migration.sql rename to src/backend/src/prisma/migrations/20240525194034_init/migration.sql index d0979d056a..ecc27c64b4 100644 --- a/src/backend/src/prisma/migrations/20240518160744_init/migration.sql +++ b/src/backend/src/prisma/migrations/20240525194034_init/migration.sql @@ -131,7 +131,6 @@ CREATE TABLE "Scope_CR" ( "scopeImpact" TEXT NOT NULL, "timelineImpact" INTEGER NOT NULL, "budgetImpact" INTEGER NOT NULL, - "wbsProposedChangesId" TEXT, CONSTRAINT "Scope_CR_pkey" PRIMARY KEY ("scopeCrId") ); @@ -559,8 +558,9 @@ CREATE TABLE "Wbs_Proposed_Changes" ( "status" "WBS_Element_Status" NOT NULL, "leadId" INTEGER, "managerId" INTEGER, - "changeRequestId" INTEGER NOT NULL, + "changeRequestId" INTEGER, "dateDeleted" TIMESTAMP(3), + "changeRequestAsOriginalDataId" INTEGER, CONSTRAINT "Wbs_Proposed_Changes_pkey" PRIMARY KEY ("wbsProposedChangesId") ); @@ -570,7 +570,6 @@ CREATE TABLE "Project_Proposed_Changes" ( "projectProposedChangesId" TEXT NOT NULL, "budget" INTEGER NOT NULL, "summary" TEXT NOT NULL, - "rules" TEXT[], "wbsProposedChangesId" TEXT NOT NULL, "carId" TEXT, @@ -806,6 +805,9 @@ CREATE UNIQUE INDEX "Schedule_Settings_userId_key" ON "Schedule_Settings"("userI -- CreateIndex CREATE UNIQUE INDEX "Wbs_Proposed_Changes_changeRequestId_key" ON "Wbs_Proposed_Changes"("changeRequestId"); +-- CreateIndex +CREATE UNIQUE INDEX "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_key" ON "Wbs_Proposed_Changes"("changeRequestAsOriginalDataId"); + -- CreateIndex CREATE UNIQUE INDEX "Project_Proposed_Changes_wbsProposedChangesId_key" ON "Project_Proposed_Changes"("wbsProposedChangesId"); @@ -1188,7 +1190,10 @@ ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_leadId_f ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_managerId_fkey" FOREIGN KEY ("managerId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey" FOREIGN KEY ("changeRequestId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestId_fkey" FOREIGN KEY ("changeRequestId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Wbs_Proposed_Changes" ADD CONSTRAINT "Wbs_Proposed_Changes_changeRequestAsOriginalDataId_fkey" FOREIGN KEY ("changeRequestAsOriginalDataId") REFERENCES "Scope_CR"("scopeCrId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "Project_Proposed_Changes" ADD CONSTRAINT "Project_Proposed_Changes_wbsProposedChangesId_fkey" FOREIGN KEY ("wbsProposedChangesId") REFERENCES "Wbs_Proposed_Changes"("wbsProposedChangesId") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 2bd2ab2c75..bacedb9734 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -749,7 +749,7 @@ model Wbs_Proposed_Changes { manager User? @relation(name: "wbsmanager", fields: [managerId], references: [userId]) links Link[] @relation(name: "proposedChangeLinks") changeRequest Scope_CR? @relation(name: "wbsProposedChanges", fields: [changeRequestId], references: [scopeCrId]) - changeRequestId Int @unique + changeRequestId Int? @unique projectProposedChanges Project_Proposed_Changes? @relation(name: "projectProposedChanges") workPackageProposedChanges Work_Package_Proposed_Changes? @relation(name: "wpProposedChanges") proposedDescriptionBulletChanges Description_Bullet[] @relation(name: "proposedDescriptionBulletChanges") @@ -762,7 +762,6 @@ model Project_Proposed_Changes { projectProposedChangesId String @id @default(uuid()) budget Int summary String - rules String[] teams Team[] @relation(name: "proposedProjectTeams") wbsProposedChanges Wbs_Proposed_Changes @relation(name: "projectProposedChanges", fields: [wbsProposedChangesId], references: [wbsProposedChangesId]) wbsProposedChangesId String @unique diff --git a/src/backend/src/services/change-requests.services.ts b/src/backend/src/services/change-requests.services.ts index 52354d3d5d..acff8e2572 100644 --- a/src/backend/src/services/change-requests.services.ts +++ b/src/backend/src/services/change-requests.services.ts @@ -199,33 +199,40 @@ export default class ChangeRequestsService { create: { name: foundCR.wbsElement.name, status: foundCR.wbsElement.status, - leadId: foundCR.wbsElement.leadId, - managerId: foundCR.wbsElement.managerId, + lead: { + connect: { + userId: foundCR.wbsElement.leadId ?? undefined + } + }, + manager: { + connect: { + userId: foundCR.wbsElement.managerId ?? undefined + } + }, links: { connect: foundCR.wbsElement.links.map((link) => ({ linkId: link.linkId })) }, + proposedDescriptionBulletChanges: { + connect: foundCR.wbsElement.descriptionBullets.map((descriptionBullet) => ({ + descriptionId: descriptionBullet.descriptionId + })) + }, projectProposedChanges: projectProposedChanges && associatedProject ? { create: { budget: associatedProject.budget, summary: associatedProject.summary, - rules: associatedProject.rules, - goals: { connect: associatedProject.goals.map((goal) => ({ descriptionId: goal.descriptionId })) }, - features: { - connect: associatedProject.features.map((feature) => ({ descriptionId: feature.descriptionId })) - }, - otherConstraints: { - connect: associatedProject.otherConstraints.map((constraint) => ({ - descriptionId: constraint.descriptionId - })) - }, teams: { connect: associatedProject.teams.map((team) => ({ teamId: team.teamId })) }, - carNumber: associatedProject.wbsElement.carNumber + car: { + connect: { + carId: associatedProject.carId + } + } } } : undefined, @@ -238,16 +245,6 @@ export default class ChangeRequestsService { blockedBy: { connect: associatedWorkPackage.blockedBy.map((wbsNumber) => ({ wbsNumber })) }, - expectedActivities: { - connect: associatedWorkPackage.expectedActivities.map((activity) => ({ - descriptionId: activity.descriptionId - })) - }, - deliverables: { - connect: associatedWorkPackage.deliverables.map((deliverable) => ({ - descriptionId: deliverable.descriptionId - })) - }, stage: associatedWorkPackage.stage } } From 2e9c7382e485c5d038c39ea0ed785d50c3d2239c Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Sat, 25 May 2024 15:53:13 -0400 Subject: [PATCH 12/14] #2392 Fix Tsc --- src/frontend/src/utils/diff-page.utils.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/utils/diff-page.utils.ts b/src/frontend/src/utils/diff-page.utils.ts index e37445918a..fbc3b24b4a 100644 --- a/src/frontend/src/utils/diff-page.utils.ts +++ b/src/frontend/src/utils/diff-page.utils.ts @@ -174,10 +174,7 @@ export const projectProposedChangesToPreview = ( manager: proposedChanges.manager, teams: proposedChanges.teams, budget: proposedChanges.budget, - goals: proposedChanges.goals, - features: proposedChanges.features, - rules: proposedChanges.rules, - otherConstraints: proposedChanges.otherConstraints, + descriptionBullets: proposedChanges.descriptionBullets, links: proposedChanges.links } ); @@ -195,8 +192,7 @@ export const workPackageProposedChangesToPreview = ( startDate: proposedChanges.startDate, duration: proposedChanges.duration, blockedBy: proposedChanges.blockedBy, - expectedActivities: proposedChanges.expectedActivities, - deliverables: proposedChanges.deliverables + descriptionBullets: proposedChanges.descriptionBullets } ); }; From cdad5e7322374ca7da07cdd369a109f6ddd83351 Mon Sep 17 00:00:00 2001 From: Peyton-McKee Date: Sat, 25 May 2024 15:55:29 -0400 Subject: [PATCH 13/14] #2392 Change Back to Id --- src/backend/src/utils/description-bullets.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/src/utils/description-bullets.utils.ts b/src/backend/src/utils/description-bullets.utils.ts index 93343dec63..12e0324a10 100644 --- a/src/backend/src/utils/description-bullets.utils.ts +++ b/src/backend/src/utils/description-bullets.utils.ts @@ -66,7 +66,7 @@ export const descriptionBulletToChangeListValue = ( ): ChangeListValue => { return { element: descriptionBullet, - comparator: `${descriptionBullet.detail}`, + comparator: `${descriptionBullet.id}`, displayValue: descriptionBullet.detail }; }; From e97290228e3caf2ab87b0cf2b6dc9f85a67f74c4 Mon Sep 17 00:00:00 2001 From: RChandler234 <29521172+RChandler234@users.noreply.github.com> Date: Sat, 25 May 2024 16:00:25 -0400 Subject: [PATCH 14/14] #2392 - add detail comparator back in --- src/backend/src/utils/description-bullets.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/src/utils/description-bullets.utils.ts b/src/backend/src/utils/description-bullets.utils.ts index 12e0324a10..93343dec63 100644 --- a/src/backend/src/utils/description-bullets.utils.ts +++ b/src/backend/src/utils/description-bullets.utils.ts @@ -66,7 +66,7 @@ export const descriptionBulletToChangeListValue = ( ): ChangeListValue => { return { element: descriptionBullet, - comparator: `${descriptionBullet.id}`, + comparator: `${descriptionBullet.detail}`, displayValue: descriptionBullet.detail }; };